CREATE TABLE IF NOT EXISTS "job" (
"id" INTEGER IDENTITY,
"jobId" BIGINT ,
"jobName" VARCHAR(100) ,
"jobNameU" VARCHAR(100) GENERATED ALWAYS AS (UPPER("jobName")),
PRIMARY KEY ("jobNameU")
);
使用before insert触发器有一个更好的解决方案,该触发器不需要额外生成的列:
CREATE TABLE IF NOT EXISTS "job" (
"id" INTEGER IDENTITY,
"jobId" BIGINT ,
"jobName" VARCHAR(100) ,
PRIMARY KEY ("jobName")
);
CREATE TRIGGER makeUpper BEFORE INSERT ON "job" REFERENCING NEW ROW AS NEW
FOR EACH ROW
SET NEW."jobName" = UPPER(NEW."jobName")
2条答案
按热度按时间wfypjpf41#
对于hsqldb,生成列的解决方案(类似于mysql解决方案)是:
使用before insert触发器有一个更好的解决方案,该触发器不需要额外生成的列:
6psbrbz92#
可以使用计算/生成列:
dbfiddle演示