赞
踩
目前B站正在直播Mysql、Oracle实战,详情请关注公众号:IT邦德
1 关于约束的数据字典
mysql> select DISTINCT a.CONSTRAINT_TYPE from information_schema.table_constraints a;
mysql> select * from information_schema.table_constraints a where CONSTRAINT_SCHEMA='db1';
2 查询表和列
--最齐全的信息查询 SELECT a.TABLE_NAME "表", a.COLUMN_NAME "列", a.COLUMN_TYPE "类型", a.COLUMN_DEFAULT "默认值", a.IS_NULLABLE "是否为空", a.CHARACTER_SET_NAME "表字符集", a.COLLATION_NAME "校验字符集", CONCAT_WS(',',a.COLUMN_COMMENT,a.COLUMN_KEY, a.EXTRA) "列备注", b.TABLE_COMMENT "表备注" , b.ENGINE "引擎" FROM information_schema.COLUMNS a,information_schema.TABLES b WHERE a.TABLE_SCHEMA=b.TABLE_SCHEMA AND a.TABLE_SCHEMA='db1' AND a.TABLE_NAME=b.TABLE_NAME order by a.ORDINAL_POSITION;
3 查询索引信息
SELECT
TABLE_SCHEMA,
TABLE_NAME,
NON_UNIQUE,
INDEX_NAME,
SEQ_IN_INDEX,
COLUMN_NAME,
INDEX_TYPE,
CONCAT(COMMENT,INDEX_COMMENT) INDEX_COMMENT
FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_SCHEMA = 'db1'
ORDER BY TABLE_SCHEMA,TABLE_NAME,INDEX_NAME,SEQ_IN_INDEX;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。