mysql 查询数据库中所有表的信息

查询数据库中的所有表格信息:

SELECT table_name, table_comment, create_time, update_time FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE())
ORDER BY create_time DESC

查询某个表格某一列的信息:

SELECT column_name, (CASE WHEN (is_nullable = 'no'  &&  column_key != 'PRI') THEN '1' ELSE NULL END) AS is_required, 
(CASE WHEN column_key = 'PRI' THEN '1' ELSE '0' END) AS is_pk, ordinal_position AS sort, column_comment, 
(CASE WHEN extra = 'auto_increment' THEN '1' ELSE '0' END) AS is_increment, column_type
FROM information_schema.columns WHERE table_schema = (SELECT DATABASE()) AND table_name = ('sys_config')
ORDER BY ordinal_position

SHOW FULL FIELDS FROM `user`

你可能感兴趣的:(mysql)