1、查看所有的触发器
1 | SELECT * FROM information_schema.`TRIGGERS`; |
2、查询所有的表
1 | SELECT TABLE_NAME table_name,TABLE_COMMENT table_comment FROM INFORMATION_SCHEMA.TABLES where table_schema='myDB' and table_type='BASE TABLE'; //表名(不包含视图)及备注 |
3、查询db1数据库中所有有触发器的表
1 | SELECT DISTINCT EVENT_OBJECT_TABLE FROM information_schema.`TRIGGERS` WHERE EVENT_OBJECT_SCHEMA = "db1"; |
4、查询db1数据库中所有无触发器的表
1 | SELECT A.TABLE_NAME from information_schema.`TABLES` A LEFT JOIN information_schema.`TRIGGERS` B ON A.TABLE_NAME=B.EVENT_OBJECT_TABLE where B.EVENT_OBJECT_TABLE is null and A.TABLE_SCHEMA="db1"; |
5、创建索引
1 | alter table table_name add index index_name (索引字段); -- 创建普通索引 |
6、去除数据表中指定字段的换行符
1 | -- char(10):换行符 char(13):回车符 |
7、修改表引擎
1 | alter table table_name engine=MyISAM; |