mysql常用查看表结构的SQL语句

1.查看表结构:

SELECT column_name,data_type FROM information_schema.columns WHERE table_name='数据库表名';

2.查看表的主键:

SELECT column_name AS 主键 FROM INFORMATION_SCHEMA.`KEY_COLUMN_USAGE` WHERE table_name='数据库表名' AND constraint_name='PRIMARY'

你可能感兴趣的:(数据库)