MySQL:
SELECT
COLUMN_NAME 字段名称,
COLUMN_TYPE 字段类型,
COLUMN_DEFAULT 默认值,
CHARACTER_MAXIMUM_LENGTH AS 最大长度,
(
CASE
WHEN is_nullable = 'NO' THEN
'否'
ELSE
'是'
END
) AS 是否可空,
(
CASE
WHEN column_key = 'PRI' THEN
'是'
ELSE
'否'
END
) AS 是否主键,
COLUMN_COMMENT 描述
FROM
INFORMATION_SCHEMA. COLUMNS
WHERE
table_schema = 'running'-- 数据库名称
AND table_name = 'sys_dict_type' -- 表名称
Oracle:
SELECT
--uc.table_name 表名,
--utc.comments 表说明,
uc.column_name 字段名,
ucc.comments 字段说明,
uc.data_type 数据类型,
uc.data_length 长度,
uc.nullable 是否为空,
uc.data_default 默认值
FROM cols uc, user_col_comments ucc, user_tab_comments utc
WHERE uc.table_name = ucc.table_name
AND uc.column_name = ucc.column_name
AND uc.table_name = utc.table_name
AND uc.table_name = 'REP_SUBSTANCE_MESSAGE' --XXX(一定要注意表名大写)
ORDER BY uc.table_name, uc.column_id