mysql之表操作
对库内所有表操作
表的大小
select TABLE_name,concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size,
concat(truncate(sum(max_data_length)/1024/1024,2),'MB') as max_data_size,
concat(truncate(sum(data_free)/1024/1024,2),'MB') as data_free,
concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size
from information_schema.tables where TABLE_SCHEMA = 'zilong_report' GROUP BY table_name ;
某库下的所有表
select table_name from information_schema.tables where table_schema = 'databasename'
对单表操作
改名
rename table tablenameold to tablenamenew; # 改表名
alter table student change column columnnameold columnnamenew varchar(20); # 改列名 varchar(20) 是改后字段的类型
表结构信息
DESCRIBE tablename #更多地用于获取表结构信息;