1. 程式人生 > >mysql常用操作

mysql常用操作

常用操作 iter OS har nod all arc roc default

創建表

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;

mysql常用操作