How To View All Columns in an Existing Table


How To View All Columns in an Existing Table? - Oracle DBA FAQ - Managing Oracle Database Tables



If you have an existing table and want to know how many columns are in the table and how they are defined, you can use the system view USER_TAB_COLUMNS as shown in the following tutorial exercise:

SQL> COL data_type FORMAT A12;
SQL> SELECT column_name, data_type, data_length 
  FROM user_tab_columns WHERE table_name = 'EMPLOYEES';
------------------------------ ------------ -----------
EMPLOYEE_ID                    NUMBER                22
FIRST_NAME                     VARCHAR2              20
LAST_NAME                      VARCHAR2              25
EMAIL                          VARCHAR2              25
PHONE_NUMBER                   VARCHAR2              20
HIRE_DATE                      DATE                   7
JOB_ID                         VARCHAR2              10
SALARY                         NUMBER                22
COMMISSION_PCT                 NUMBER                22
MANAGER_ID                     NUMBER                22
DEPARTMENT_ID                  NUMBER                22

2007-05-03, 8007👍, 0💬