mysql查询列定义,是否自增等

Posted zhjh256

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql查询列定义,是否自增等相关的知识,希望对你有一定的参考价值。

SELECT
    ORDINAL_POSITION AS Colorder,
    Column_Name AS ColumnName,
    data_type AS TypeName,
    COLUMN_COMMENT AS DeText,
    (
        CASE
        WHEN data_type = float
        OR data_type = double
        OR data_type = decimal THEN
            NUMERIC_PRECISION
        ELSE
            CHARACTER_MAXIMUM_LENGTH
        END
    ) AS length,
    NUMERIC_SCALE AS Scale,
    (
        CASE
        WHEN EXTRA = auto_increment THEN
            1
        ELSE
            0
        END
    ) AS IsIdentity,
    (
        CASE
        WHEN COLUMN_KEY = PRI THEN
            1
        ELSE
            0
        END
    ) AS IsPK,
    (
        CASE
        WHEN IS_NULLABLE = NO THEN
            0
        ELSE
            1
        END
    ) AS CanNull,
    extra,
    COLUMN_DEFAULT AS DefaultVal
FROM
    information_schema. COLUMNS

 

以上是关于mysql查询列定义,是否自增等的主要内容,如果未能解决你的问题,请参考以下文章

mysql 给查询语句中增加一列自增id

mysql 给查询语句中增加一列自增id

MySQL 数据库 增删查改克隆外键 等操作

MySQL 数据库 增删查改克隆外键 等操作

MySQL插入自增列数据的问题

建表时,如何让mysql标识列ID从1开始自动增长