HiveBrain v1.2.0
Get Started
← Back to all entries
debugMinor

Unable to describe table in oracle

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
tableoracleunabledescribe

Problem

I'm trying to get the description of a table in oracle because I need to know what foreign keys does it have and which tables they refer to.
I'm using desc
but all I get is "ORA-00900: invalid SQL statement"
Any idea why?
Thanks.

Solution

I suspect that you did not execute this command with sqlplus. Not every sql program can handle the desc command.

You can either use sqlplus or get the table definition with the following SQL command:

SELECT dbms_metadata.get_ddl (object_type, object_name, owner)
FROM   all_objects
WHERE  owner = ''
  AND  object_name LIKE '%';


This will give you the complete table definition with all column definitions.

Code Snippets

SELECT dbms_metadata.get_ddl (object_type, object_name, owner)
FROM   all_objects
WHERE  owner = '<owner>'
  AND  object_name LIKE '<whatever_table>%';

Context

StackExchange Database Administrators Q#87141, answer score: 6

Revisions (0)

No revisions yet.