I've searched through all of the responses on SQL Developer and I haven't found a response that matches this question. I need to be able to see the SQL for a table/view etc by clicking on the sql tab, but for now it simply shows me a blank screen. Has anyone else solved this? It works fine in toad and I can see the code but we have a new server and I can't connect to it with toad. Any help would be nice.
3 Answers
It's blank because the query used to obtain the SQL behind the view requires database privileges that your account lacks.
DBMS_METADATA is a very powerful package used by the database whenever DDL for an an existing object is required. SQL Developer uses this for many features in the GUI, including this 'SQL' page.
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
)
When this query fails, the screen remains blank.
If you merely want to grab the SQL SELECT statement behind the view, see the "Details" page and inspect the TEXT and TEXT_VC columns.
If you need the SQL panel to work, ask your DBAs to grant you higher dictionary privs, or consider:
- publishing HTML data models for your production schemas, so that folks that need the information can grab it, w/o having to use the database itself
- keeping the source code in your apps in Source Control repos, so that folks that need the information can grab it, w/o having to use the database itself
When i connect to SQL Developer and type alter the session set current_schema=xyz then i am connect as if i was that user. When i open the branche other users, and navigate to a table of user xyz, and click table A_TABLE, then i see the definition of that table in the columns tab and i have several other tabs, such as data to show the data in the table. So far so good. But when i navigate to the SQL tab (on the far right of the tabs) i would expect to see the DLL of the table, but this tab stays empty. (this is also posted in another thread, but no good solution)
Is there a way to get this working ? Probably tab in the backend looks in user_tables and user_tab_columns to generatie the DLL. And since i did an alter session, the table are probably in the all_tables view.
It works fine when i log in and click my own tables, but not that of other users. Same think with view definitions. Also right clicking on the object and choose quick DLL results in empty file/worksheet of clipboard.
In short, can the tab SQL only work for schema owners of dba's or can it also work when using alter session set current_schema = xyz
Not sure exactly what you mean, but: 1. Can you connect to your db using Sqldev? Can you expand the list of schema objects and see your tables? 2. If so then when you open a sql worksheet, yes it is blank., this is where you type your sql statement and execute it. Type the FROM clause first, then go back and add the select clause and sql dev will show a drop down list of columns for the tables you can select from w/o typing the col names. 3. If you want to see you table data, simply double click the table in the tree browser on the left. You can also build queries graphically though drag and drop. But, normal behavior of the SQL worksheet window is to display blank, so not sure exactly what you expecting to happen.
If you select a view and right click and select Export DDL and Select Save to Worksheet, then the DDL is pasted into a worksheet: Example: CREATE TABLE "HR"."COUNTRIES" ( "COUNTRY_ID" CHAR(2 BYTE) CONSTRAINT "COUNTRY_ID_NN" NOT NULL ENABLE, "COUNTRY_NAME" VARCHAR2(40 BYTE), "REGION_ID" NUMBER, CONSTRAINT "COUNTRY_C_ID_PK" PRIMARY KEY ("COUNTRY_ID") ENABLE, CONSTRAINT "COUNTR_REG_FK" FOREIGN KEY ("REGION_ID") REFERENCES "HR"."REGIONS" ("REGION_ID") ENABLE ) ORGANIZATION INDEX NOCOMPRESS PCTFREE 10 INITRANS 2 MAXTRANS 255 LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "USERS" PCTTHRESHOLD 50;
SQL DDL statements show the 'code' to create the schema object.
-
Maybe I was misinformed by our dba (not exactly an uncommon occurrence), he told me if I selected on a view then selected the SQL tab that it would show the underlying code for the view. To me it is just blank even though when I see it on his computer it shows code. I've never really needed that tab before so I'm not as familiar with it. I learned Oracle SQL through command-line and have never been great with the gui editors. Commented Oct 19, 2010 at 20:28
-
-
right click the view and select EXPORT DDL -> Save to Worksheet.– JoeCommented Oct 19, 2010 at 20:47
-