10

Can someone explain things a little better to me? How do I show the structure of a table? I run the select * from table; and of course it displays all that's in the table. But, I am being asked to show the structure of the table. What does that mean, and what is the command?

Here's my table below.

SQL> select * from dept;

DEPTNO DNAME          LOC
---------- -------------- -------------
    10 ACCOUNTING     NEW YORK
    20 RESEARCH       DALLAS
    30 SALES          CHICAGO
    40 OPERATIONS     BOSTON

 SQL>
bobs
  • 21,844
  • 12
  • 67
  • 78
user770022
  • 2,899
  • 19
  • 52
  • 79

3 Answers3

22

Try this out: describe table_name

ajshort
  • 3,684
  • 5
  • 29
  • 43
sribin
  • 221
  • 2
  • 2
19

To list columns and data types, I typically use

SELECT COLUMN_NAME, DATA_TYPE FROM ALL_TAB_COLUMNS WHERE TABLE_NAME='your_table_name';

It's been a while since I've worked with Oracle though. ALL_TAB_COLUMNS might actually be ALL_TAB_COLS.

If you need to display the full CREATE TABLE statement, see How to get Oracle create table statement in SQL*Plus

Community
  • 1
  • 1
Michael Berkowski
  • 267,341
  • 46
  • 444
  • 390
1

You can use sqlplus command describe <SCHEMA_OWNER.TABLE>

https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12019.htm

27P
  • 1,183
  • 16
  • 22