Search code examples
visual-studio-codeoracle-sqldeveloper

How can I see the sql statement of a view (db resides on AWS)


I've just installed the vscode extension (Oracle Developer Tools for VS Code (SQL and PLSQL) ) and successfully connected the db.

The db resides on AWS.

I can connect the db and just wanted to test it by opening an existing view.

But, it just lets me "describe" the view. So I can see the columns but I need to edit the query statement.

What's missing? Or is the problem the AWS part?

I usually use SQL Developer but I'm furthermore interested in backing up the work via git commits. And I like the way "git graph" extensions presents the changes.


Solution

  • With help from someone of the Oracle community I managed to get it working.

    Basic query is:

    select
    dbms_metadata.get_ddl('VIEW', 'VIEW_NAME', 'VIEW_OWNER') 
    from
    dual;
    

    So, in my case it is:

    select
    dbms_metadata.get_ddl('VIEW', 'ALL_DATA_WAREHOUSE_BOSTON', 'WHB') 
    from
    dual;
    

    Owner is the name you fill in when connection to the database, which is the key/value pair (username/password).

    If you are not sure who the owner of the view is, check it with this query:

    select owner from ALL_VIEWS where VIEW_NAME ='ALL_DATA_WAREHOUSE_BOSTON';