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