首页 > 数据库技术 > 详细

mysql常用操作

时间:2018-02-27 22:51:46      阅读:225      评论:0      收藏:0      [点我收藏+]

创建表

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!