SELECT
    ORDINAL_POSITION AS '序号',
    COLUMN_NAME AS '列名',
    DATA_TYPE AS '数据类型',
    character_maximum_length AS '长度',
IF
    ( numeric_scale = 0, '', numeric_scale ) AS '小数位',
IF
    ( COLUMN_KEY = 'PRI', '√', '' ) AS '主键',
IF
    ( extra = 'auto_increment', '√', '' ) AS '自增',
IF
    ( IS_NULLABLE = 'YES', '√', '' ) AS '允许空',
IF
    ( COLUMN_DEFAULT = 'CURRENT_TIMESTAMP', '', COLUMN_DEFAULT ) AS '默认值',
    COLUMN_COMMENT AS '列说明' 
FROM
    information_schema.`COLUMNS` 
WHERE
    table_schema = 'labour' 
    AND table_name = 't_attendance' 
    AND COLUMN_COMMENT != '无用' 
    AND COLUMN_COMMENT != '弃用' 
    AND COLUMN_COMMENT != '迁移用' 
ORDER BY
    ORDINAL_POSITION

 

posted on 2021-09-03 21:24  入梦炼心  阅读(130)  评论(0编辑  收藏  举报