mysql常用操作
创建表
create table test (
id int(10) not null primary key auto_increment,
md5 varchar(30),
subkey int(15)
)engine=innodb;
修改表
添加列
alter table test add column num int;
修改列
alter table test modify column num int;
删除列
alter table test drop column num;
添加索引
alter table test add index my_index(subkey);
删除索引
alter table test drop index my_index;
查看索引
show index from test;
查看表引擎
show create table test;
创建过程
DROP PROCEDURE IF EXISTS proc1;
DELIMITER $$
CREATE PROCEDURE proc1(in max int)
BEGIN
DECLARE i int default 0;
while i<max do
insert into test(md5,subkey) values(uuid(),ceil(rand()*100000));
set i = i+1;
end while;
END;$$
DELIMITER ;
调用过程
call proc1;