tags:

views:

760

answers:

6

Hi!

I tried to execute the DESCRIBE command via a database link, but this was the return message:

DESCRIBE <table>@<database>;
ERROR:                               
------------------------------------ 
ERROR: object <table> does not exist 

1 rows selected

A SELECT on this table works well.

Does Oracle permitts DESCRIBE via a database link?

I'm using the Oracle SQL Developer 1.5.1.

Edit:

Is there another option to describe a table?

Thanks in advance!

+2  A: 

I think DESCRIBE is a SQL*Plus feature. See here.

Otávio Décio
It works with the Oracle SQLDeveloper, too. DESCRIBE works on local tables perfectly.
furtelwart
It is a tool feature, not a SQL feature so that's why it doesn't work on a regular db connection.
Otávio Décio
The other half of the question -- how to get the column information -- using the system views would be a helpful addition to this answer.
S.Lott
+5  A: 

You could do something with the all_tab_columns table to get some table information.

select column_name, data_type from all_tab_columns where table_name = 'TABLE_NAME';
gpojd
Since it is a SQL*Plus replacement it is not surprising that works. What I don't think works is DESCRIBE through a JDBC connection for example.
Otávio Décio
ocdecio: So SQLDeveloper won't get it, because it uses the JDBC?
furtelwart
It will because it implements the DESCRIBE command. If you write a Java program connecting straight to Oracle with jdbc I doubt it will work. In the end it generates something like select * from v$tables as mentioned by MazarD.
Otávio Décio
The only way to prove this is to put a network sniffer and watch what goes back and forth, and then you'll see. Or get the source for yasql.
Otávio Décio
The source for yasql shows that it is checking the "all_tab_columns" table.
gpojd
@gpojd - That was very helpful, thanks.
Otávio Décio
A: 

I can't check it right now, but maybe select * from v$tables@remotedb doesn't give similar information?

MazarD
+1  A: 

You seem to be using PL/SQL Developer.

DESCRIBE is not an SQL command, it's a query tool alias that gets converted into a series of queries to the system tables.

PL/SQL Developer can not describe tables from remote databases, while native SQL*Plus can.

Quassnoi
+1  A: 

The easiest way to get the description of a table on a remote server would be:

CREATE OR REPLACE VIEW TMP_VIEW AS SELECT * FROM TABLE_A@SERVER
/
DESCRIBE TMP_VIEW
/
Please insert `view` after REPLACE, otherwise it won't work.
furtelwart
+1  A: 

just make temporary view, then describe the table using command window.

diand