mysql触发器的使用
2017-10-11 11:18
393 查看
use t14test
show tables
drop table if exists uuidTest
create table uuidTest(
testId VARCHAR(36) not NULL DEFAULT '1',
testData VARCHAR(32),
PRIMARY KEY(`testId`)
)
/*创建触发器*/
/*
* terminal创建存储过程需要定义分隔符
* delimiter //
* */
create trigger tri_auto_uuid
before insert
on uuidTest
for each ROW
BEGIN
if new.testId = '1' THEN set new.testId = (select uuid());
end if;
END
/*删除触发器*/
drop trigger if exists tri_auto_uuid
/*插入数据*/
insert into uuidTest(testData)VALUES('一条数据')
select * from uuidTest
show tables
drop table if exists uuidTest
create table uuidTest(
testId VARCHAR(36) not NULL DEFAULT '1',
testData VARCHAR(32),
PRIMARY KEY(`testId`)
)
/*创建触发器*/
/*
* terminal创建存储过程需要定义分隔符
* delimiter //
* */
create trigger tri_auto_uuid
before insert
on uuidTest
for each ROW
BEGIN
if new.testId = '1' THEN set new.testId = (select uuid());
end if;
END
/*删除触发器*/
drop trigger if exists tri_auto_uuid
/*插入数据*/
insert into uuidTest(testData)VALUES('一条数据')
select * from uuidTest
相关文章推荐
- MySQL触发器的使用
- mysql 储存过程、触发器的创建、删除及使用
- MySQL触发器的正确使用与案例分析
- MySql_数据库触发器的使用
- mysql触发器的使用和语法
- 触发器、存储过程的使用(针对Mysql)
- MySQL触发器的使用
- 在mysql中使用触发器完整示例
- 积分触发器 mysql 触发器的使用
- Mysql中的触发器简单介绍及使用案例
- mysql 触发器的使用
- MySQL5.6 触发器的使用(条件分支、变量的使用)
- MySQL 5.6 if与end if在触发器中的使用
- mysql触发器使用
- mysql中触发器的使用详解
- mysql触发器的使用
- MySql 中的 触发器使用
- Mysql中的触发器简单介绍及使用案例
- Mysql 触发器的使用
- mysql 触发器的使用