- Oracle
SELECT 'CRM' AS SRC_CODE, -- 系统标识 自己定
A.OWNER,
A.TABLE_NAME AS TABLE_NAME,
A.COLUMN_NAME AS COL_NAME,
D.COMMENTS AS COL_DESC,
A.column_id AS COL_ID,
A.data_type AS COL_DATA_TYPE,
CASE WHEN data_type LIKE '%NUMBER%' THEN COALESCE(data_precision, 38)
ELSE data_length END AS COL_DATA_LENGTH,
CASE WHEN data_type LIKE '%NUMBER%' THEN COALESCE(data_scale, 10)
ELSE data_scale END AS COL_DATA_SCALE,
to_char(sysdate,'yyyy-mm-dd') as DATA_DT_SRC
FROM all_tab_columns A
LEFT JOIN ALL_COL_COMMENTS D
ON A.OWNER=D.OWNER AND A.TABLE_NAME=D.TABLE_NAME AND A.COLUMN_NAME=D.COLUMN_NAME
WHERE A.OWNER IN ('crm') -- 用户名 自己定
order by A.OWNER ,A.TABLE_NAME,A.column_id
- SqlServer
SELECT
'CRM' AS SRC_SYS -- 系统名 自己定
,'crm' AS SRC_OWNER -- 用户名 自己定
,A.name AS TABLE_NAME
,B.name AS COL_NAME
,cast(ETP.value as varchar(500)) as COL_DESC
,B.colid AS COL_ID
,t.name as COL_DATA_TYPE
,COLUMNPROPERTY(B.id,B.name,'PRECISION') AS COL_DATA_LENGTH
,isnull(COLUMNPROPERTY(B.id,B.name,'Scale'),0) AS COL_DATA_SCALE
,convert(char(10),getdate(),120) AS DATA_DT_SRC
from SysObjects A
LEFT JOIN syscolumns B
ON A.id=B.id
LEFT JOIN systypes t
on B.xusertype = t.xusertype
LEFT JOIN sys.extended_properties ETP
ON ETP.major_id = B.id AND ETP.minor_id = B.colid AND ETP.name ='MS_Description'
and B.id=ETP.major_id
WHERE A.xtype='U'
- DB2
SELECT
'CRM' AS SRC_SYS -- 系统名 自己定
,'crm' AS SRC_OWNER -- 用户名 自己定
,A.TBNAME AS TABLE_NAME
,A.NAME AS COL_NAME
,A.REMARKS AS COL_DESC
,A.COLNO
,A.COLTYPE
,A.LENGTH
,A.SCALE
,char(current date,iso)
FROM SYSIBM.SYSCOLUMNS A
WHERE TBCREATOR = 'CRM' -- 用户名 自己定
AND TYPENAME NOT LIKE '%LOB'
ORDER BY TBNAME,COLNO
- Mysql
SELECT
'CRM' AS SRC_CODE, -- 系统名 自己定
A.TABLE_SCHEMA AS OWNER,
A.TABLE_NAME AS TABLE_NAME,
D.COLUMN_NAME AS COL_NAME,
D.COLUMN_COMMENT AS COL_DESC,
D.ORDINAL_POSITION AS COL_ID,
D.DATA_TYPE AS COL_DATA_TYPE,
D.CHARACTER_MAXIMUM_LENGTH AS COL_DATA_LENGTH,
D.NUMERIC_SCALE AS COL_DATA_SCALE,
date_format(now(), '%Y-%m-%d') AS DATA_DT_SRC
FROM information_schema.TABLES A
LEFT JOIN information_schema.COLUMNS D
ON A.TABLE_NAME = D.TABLE_NAME
AND A.TABLE_SCHEMA = D.TABLE_SCHEMA
WHERE A.TABLE_SCHEMA = 'CRM' -- 自己定
ORDER BY A.TABLE_SCHEMA,A.TABLE_NAME