1

I am using sql developer version 21.( Recently installed) I can't access the view sqls/ definition from the view tab. I can accessor see the view text from " details" tab but not from the "Sql" tab. I don't have admin privilege. The same user can view view sqls from sqldeveloper version 18...

1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Feb 1, 2022 at 19:04

2 Answers 2

3

In older versions of SQL Developer we had a 'try to generate DDL' method for when DBMS_METADATA.GET_DLL() wasn't available.

This wasn't a maintainable position. The 'internal generator' has multiple issues, and we decided to deprecate it.

In order to see the DDL for an object, you need for the DBMS_METADATA package to be available to your user, for said object.

What SQL Developer runs to get you the DDL for a VIEW, is approx:

SELECT
    dbms_metadata.get_ddl(
        'VIEW',
        :name,
        :owner
    )
FROM
    dual
UNION ALL
SELECT
    dbms_metadata.get_ddl(
        'TRIGGER',
        trigger_name,
        owner
    )
FROM
    dba_triggers
WHERE
        table_owner = :owner
    AND table_name = :name
UNION ALL
SELECT
    dbms_metadata.get_dependent_ddl(
        'COMMENT',
        table_name,
        owner
    )
FROM
    (
        SELECT
            table_name,
            owner
        FROM
            dba_col_comments
        WHERE
                owner = :owner
            AND table_name = :name
            AND comments IS NOT NULL
        UNION
        SELECT
            table_name,
            owner
        FROM
            sys.dba_tab_comments
        WHERE
                owner = :owner
            AND table_name = :name
            AND comments IS NOT NULL
    )

In a development environment, a developer should have full access to their application, and I would extend that to the data dictionary. It's another reason I advocate developers have their own private database (Docker/VirtualBox/Cloud/whatever).

If that fails, consult your data model.

If you don't have a data model, that's another problem.

If that fails, you do have workaround of checking the Details panel for a view to get the underlying SQL.

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks a lot. So if I understand currently, in version 21 the Sql tab won't function for user with limited access. Right? Thanks for the last workaround it works but being so used to finding the definition from tab I am not yet comfortable. Also from which version does this doesn't work. If I try with v 20 will it have the tab working correctly.?
Yes, you need higher privs in the database, talk to your DBA.
Will the Sql definition work in version 20 or 19 ? As it happens I can't have full access to this db ( pre production- as per my role) so I need a sql developer version which can show me the view definition.
i'd grab 20.4.1 and try that oracle.com/tools/downloads/sqldev-downloads-2041.html -- ask your dba to publish the data model for preprod somewhere so this info can be grabbed
2

Just FYI, I searched for an answer to this problem and found no actual solutions. thatjeffsmith was correct that earlier versions of SQLDeveloper do not have this issue or requirement of higher privs to view the SQL tab. However, the link he provided was version 20.4 and it sill did not display the SQL tab correctly. I reverted back to 3.1.07 (which I happened to be using prior to upgrading my laptop) and using the same login to the same instance it does display the SQL for views, full definition, without issue. This is against a 12c Oracle database.

4 Comments

how do you mean no actual solutions?
All I meant is that I found no solutions that worked for me to modify/configure version 21 and make it behave as other versions had, meaning displaying the actual DDL of a view in the SQL tab. I found your suggestion helpful,, but the version you posted still did not behave as I expected, showing only a blank screen in the SQL tab. Reverting to the version I was using prior to the laptop replacement worked for me.
just because you dont' like the answer doesn't mean it's not the answer - the software will never operate the way you want it to as described
I liked the answer just fine, it actually helped me get to where I needed to be, which was a functional SQL tab in SQL Developer. It just did so in a circuitous manner and I wanted to point out the version differences for those seeking a solution to the same problem.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.