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();