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

mysql高级

时间:2019-06-29 14:49:50      阅读:105      评论:0      收藏:0      [点我收藏+]

标签:存储   dex   int   update   bsp   primary   insert   values   log   

 

BEFORE INSERT,BEFORE DELETE,BEFORE UPDATE
AFTER INSERT,AFTER DELETE,AFTER UPDATE


创建触发器
mysql> create table log(id int primary key auto_increment not null,
-> time datetime);

mysql> delimiter ||
mysql> create trigger demo after update
-> on student for each row
-> begin
-> insert into log values(now());
-> end
-> ||

创建存储过程
mysql> delimiter ||
mysql> create procedure delete_stu(in stuid int)
-> begin
-> delete from student where id = stuid
-> ;
-> end
-> ||
Query OK, 0 rows affected (0.29 sec)

mysql> delimiter;


mysql> create view v_stu(vid, vname) as select id, name from student;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from v_stu;


// 查看表中索引
mysql> show index from student;

// 创建索引
mysql> create index stu_index on student(index);

// 删除索引
mysql> drop index stu_index on student;

 

mysql高级

标签:存储   dex   int   update   bsp   primary   insert   values   log   

原文地址:https://www.cnblogs.com/ldsice/p/11106421.html

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