oracle查询表字段信息(包含注释)

SQL

SELECT
    T1.*, T2.COMMENTS
FROM
    (
        SELECT
            COLUMN_NAME,
            DATA_TYPE,
            DATA_LENGTH,
            DATA_DEFAULT,
            NULLABLE,
            COLUMN_ID
        FROM
            all_tab_columns
        WHERE
            table_name = 'table_name'
        ORDER BY
            COLUMN_ID ASC
    ) T1
LEFT JOIN (
    SELECT
        *
    FROM
        USER_COL_COMMENTS
    WHERE
        TABLE_NAME = 'table_name'
) T2 ON T1.COLUMN_NAME = T2.COLUMN_NAME;

表介绍

ALL_TAB_COLUMNS:表字段详细信息
USER_COL_COMMENTS:表空间里面注释,字段,对应表名称。

你可能感兴趣的:(oracle)