查询字段长度,精度等
-- 表中文名称 (数据库)表名称 字段中文名称 "字段名称(数据库)" 数据类型 长度 精度 是否主键 是否可为空
SELECT
MAX(atc.COMMENTS) 表中文名称,
t.table_name 表名,
T.COLUMN_COMMENT 字段注释,
T.COLUMN_NAME 列名,
T.COLUMN_TYPE 字段类型,
T.DATA_LENGTH 字段长度,
T.DATA_SCALE 字段精度,
CASE WHEN INSTR(B.CONSTRAINT_TYPE,'P') > 0 THEN '是' ELSE NULL END AS 是否主键, --是否主键
DECODE(T.NULLABLE, 'N', T.NULLABLE, NULL) 是否为空,
t.NUM_ROWS 条数
FROM (SELECT UB.TABLESPACE_NAME AS DATABASE_NAME,
UTC.TABLE_NAME AS TABLE_NAME,
UTC.COLUMN_NAME AS COLUMN_NAME,
UTC.DATA_LENGTH AS DATA_LENGTH,
UTC.DATA_TYPE AS COLUMN_TYPE,
UTC.DATA_SCALE AS DATA_SCALE,
UCC.COMMENTS AS COLUMN_COMMENT,
UTC.COLUMN_ID,
UTC.NULLABLE,
ub.NUM_ROWS
FROM ALL_TABLES UB
LEFT JOIN ALL_TAB_COLUMNS UTC
ON UB.TABLE_NAME = UTC.TABLE_NAME
LEFT JOIN ALL_COL_COMMENTS UCC
ON UTC.COLUMN_NAME = UCC.COLUMN_NAME
AND UTC.TABLE_NAME = UCC.TABLE_NAME) T
LEFT JOIN (SELECT UCC.TABLE_NAME AS TABLE_NAME,
UCC.COLUMN_NAME AS COLUMN_NAME,
TO_CHAR(WM_CONCAT(UC.CONSTRAINT_TYPE)) AS CONSTRAINT_TYPE
FROM ALL_CONS_COLUMNS UCC
LEFT JOIN ALL_CONSTRAINTS UC
ON UCC.CONSTRAINT_NAME = UC.CONSTRAINT_NAME
GROUP BY UCC.TABLE_NAME, UCC.COLUMN_NAME) B
ON T.TABLE_NAME = B.TABLE_NAME
AND T.COLUMN_NAME = B.COLUMN_NAME
LEFT JOIN all_TAB_COMMENTS atc
ON atc.TABLE_NAME = t.table_name
WHERE T.TABLE_NAME = 'CS_ORDER'
GROUP BY
t.table_name ,
T.COLUMN_COMMENT ,
T.COLUMN_NAME ,
T.COLUMN_TYPE ,
T.DATA_LENGTH ,
T.DATA_SCALE ,
CASE WHEN INSTR(B.CONSTRAINT_TYPE,'P') > 0 THEN '是' ELSE NULL END,
DECODE(T.NULLABLE, 'N', T.NULLABLE, NULL) ,
t.NUM_ROWS
SELECT REGEXP_SUBSTR('2491756,2491757,2491758,2491759,2491760,2491761,2491762',
'([^,]+)',
1,
ROWNUM) STR
FROM DUAL
CONNECT BY ROWNUM < (LENGTH(REGEXP_REPLACE('2491756,2491757,2491758,2491759,2491760,2491761,2491762',
'[^,]',
'')) + 2)