码迷,mamicode.com
首页 > 数据库 > 详细

mysql常用操作

时间:2018-02-27 23:44:45      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:har   rem   prim   ima   innodb   call   post   int   查看   

创建表

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常用操作

标签:har   rem   prim   ima   innodb   call   post   int   查看   

原文地址:https://www.cnblogs.com/solk/p/8480143.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!