Skip to content

Instantly share code, notes, and snippets.

@muedsa
Created December 4, 2018 06:03
Show Gist options
  • Save muedsa/ffadc69fb99386084efc50a3c9e8bc32 to your computer and use it in GitHub Desktop.
Save muedsa/ffadc69fb99386084efc50a3c9e8bc32 to your computer and use it in GitHub Desktop.
Oracle Import table structure
select t1.COLUMN_ID 序号,
t1.COLUMN_NAME 列名,
decode(t1.DATA_TYPE,
'NUMBER',
decode(t1.DATA_PRECISION,
null,
decode(t1.DATA_SCALE, 0, 'INTEGER', 'NUMBER'),
'NUMBER'),
t1.DATA_TYPE) 数据类型,
decode(t1.DATA_TYPE, 'NUMBER', t1.DATA_PRECISION, 'DATE', '', t1.DATA_LENGTH) 长度,
t1.DATA_SCALE 小数位,
decode(t3.constraint_type, 'P', '是', '') 主键,
decode(t1.NULLABLE, 'Y', '是', '否') 允许空,
t1.DATA_DEFAULT 默认值,
t2.comments 说明
from USER_TAB_COLS T1
LEFT JOIN USER_COL_COMMENTS T2
ON T1.TABLE_NAME = T2.table_name
AND T1.COLUMN_NAME = T2.COLUMN_NAME
LEFT JOIN user_constraints T3
ON T1.COLUMN_NAME = T3.constraint_name
WHERE T1.TABLE_NAME = upper('YOUR_TABLE_NAME')
order by t1.COLUMN_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment