查询mysql数据库中所有表名并删除数据

查询mysql数据库中所有表名并删除数据

查询数据库中所有表名
select table_name from information_schema.tables where table_schema='csdb' and table_type='base table';

查询指定数据库中指定表的所有字段名column_name
select column_name from information_schema.columns where table_schema='csdb' and table_name='users'

清除mysql表中数据
delete from 表名;
truncate table 表名;
不带where参数的delete语句可以删除mysql表中所有内容,使用truncate table也可以清空mysql表中所有内容。
效率上truncate比delete快,但truncate删除后不记录mysql日志,不可以恢复数据。
delete的效果有点像将mysql表中所有记录一条一条删除到删完,
而truncate相当于保留mysql表的结构,重新创建了这个表,所有的状态都相当于新表。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-06-07
drop database 库1