查看格式:
oracle:
SELECT
tc.column_name AS "columnName",
cc.comments AS "comments",
tc.data_type AS "dataType",
tc.data_length AS "dataLength",
tc.nullable AS "nullable",
(
SELECT
COUNT (*)
FROM
user_cons_columns U,
user_constraints c
WHERE
U .constraint_name = c.constraint_name
AND c.constraint_type = 'P'
AND U .table_name = tc.table_name
AND U .column_name = tc.column_name
) AS "primaryKey"
FROM
user_tab_columns tc,
user_col_comments cc
WHERE
tc.table_name = cc.table_name
AND tc.column_name = cc.column_name
AND tc.table_name = 'SYS_TASK';
mysql:
SELECT
COLUMN_NAME AS "columnName",
COLUMN_COMMENT AS "comments",
DATA_TYPE AS "dataType",
CHARACTER_MAXIMUM_LENGTH AS "dataLength",
(case when IS_NULLABLE='NO' then 'N' else 'Y' end) AS "nullable",
(case when COLUMN_KEY='PRI' then '1' else '0' end) AS "primaryKey"
FROM
information_schema.`COLUMNS`
WHERE
TABLE_SCHEMA = 'mgl'
AND TABLE_NAME = 'SYS_TASK';