創建procedure,循環insert一定量數據 ##use test ##drop procedure pro1;
DELIMITER // create procedure pro1() begin declare i int; set i=1; while i<100000 do insert into test.cc(id,name) values(i, "aa"); set i=i+1; end while; end;//
2、獨立表空間下,可以自定義表的存儲位置,(有時將部分熱表放在不同的磁盤可有效地提升IO性能) create table test(id int) data directory='c:/software'; create table test1(id int,name varchar(20),primary key (id)) data directory='c:/software';
3、獨立表空間下,可以回收表空間碎片(比如一個非常大的delete操作之后釋放的空間)
1)創建測試表 DELIMITER // create procedure pro_test1() begin declare i int;
表大小:test1.ibd 368KB
2)delete后表大小: mysql> delete from test1; test1.ibd 384KB
3)回收表空間 mysql> alter table test1 engine=innodb; test1.ibd 96KB
mysql> select table_name, (data_length+index_length)/1024/1024 as total_mb, table_rows from information_schema.tables where table_schema='test' and table_name='TEST1';