查库中的所有表
select table_name
from information_schema.tables
where table_schema='数据库名称' and table_type='base table';
查库中的某些表
select table_name
from information_schema.tables
where table_schema='数据库名称' and information_schema.tables.TABLE_NAME LIKE '%表名%';
删除数据库表方法:拼接删除sql导出到文件,再执行文件即可,其中-Ne是执行这个SQL语句的选项,-N代表输出SQL语句执行结果中不带第一行的字段名称,-e表示要执行SQL语句
mysql -uroot -pPwd -Ne "use dbname;select concat('drop table if exists dbname.', table_name,';') from information_schema.tables where table_schema = 'dbname'" > /Users/ming/Desktop/drop.sql
最后:
select into outfile只能在MySQL服务器上执行,客户端上无法执行;
mysql -Ne “runsql” > test.txt可以将SQL语句执行后输出为文件
mysql -N < runsql.sql > test.txt可以执行sql文件中的内容,然后将结果输出到文件;
mysql -N的选项,表示输出时不带表头