mysql查询表名和注释,根据表名查询表字段
1、查询数据库所有表名和表注释
SELECT
TABLE_NAME AS tableName,
TABLE_COMMENT AS tableComment
FROM
information_schema.`TABLES`
WHERE
TABLE_SCHEMA = 'signal_notification';
下面是增加序号列
SELECT
(@i:=@i+1)"序号",
TABLE_NAME AS tableName,
TABLE_COMMENT AS tableComment
FROM
information_schema.`TABLES` ,(select @i:=0)j
WHERE
TABLE_SCHEMA = 'digital_potal'
2、根据表名查询表字段和表注释
SELECT
column_name,
NULL,
data_type,
column_comment,
IF(column_key='PRI','是','否') AS '主键唯一',
IF(IS_NULLABLE='NO','是','否') AS '非空'
-- column_type
FROM
information_schema.COLUMNS
WHERE
table_name = "user_info"
AND table_schema = 'signal_notification';