← Workbench · Notes

PL/SQL commands to view the table details

In Oracle PL/SQL, you can use the following commands to view table details:

  1. DESCRIBE or DESC

    DESC table_name;

    Displays columns, data types, and constraints.

  2. USER_TAB_COLUMNS

    SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH
    FROM USER_TAB_COLUMNS
    WHERE TABLE_NAME = 'TABLE_NAME';

    Shows details about columns for tables owned by the user.

  3. ALL_TAB_COLUMNS

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

    Provides column information for tables accessible to the user.

  4. DBMS_METADATA.GET_DDL

    SELECT DBMS_METADATA.GET_DDL('TABLE', 'TABLE_NAME') FROM DUAL;

    Displays the CREATE TABLE statement for table structure details.

To view constraints on the table, you can check here.

Leave a comment

I read every message before it appears here.

Keep reading

See all