mysql高级

 

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;

 

posted @ 2019-06-29 13:43  love_water  阅读(110)  评论(0编辑  收藏  举报