1.查询数据库中所有表名
select table_name from information_schema.tables where table_schema='csdb' and table_type='base table';
2.查询指定数据库中指定表的所有字段名column_name
select column_name from information_schema.columns where table_schema='csdb' and table_name='users'
3.查出对应表的外键。组装删除外键的SQL语句
select CONCAT('alter table ', TABLE_NAME ,' drop foreign key ', CONSTRAINT_NAME , ';') from INFORMATION_SCHEMA.KEY_COLUMN_USAGE u
where u.CONSTRAINT_SCHEMA ='csdb'
and table_name like 'r_%' AND CONSTRAINT_NAME LIKE 'FK%';
4.查询数据库的版本
select version();