1。创建生成器
CREATE SEQUENCE GEN_TESTTABLE_ID
2。创建触发器
CREATE TRIGGER testtable_bi FOR testtable
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.id IS NULL) THEN
NEW.id = GEN_ID(gen_testtable_id,1);
END
三。创建过程
CREATE PROCEDURE sp_gen_testtable_id
RETURNS (id INTEGER)
AS
BEGIN
id = GEN_ID(gen_testtable_id, 1);
SUSPEND;
END
在Firebird 3中,您可以使用Identity主键
create table t1 (
id integer generated by default as identity primary key
)
Also a useful answer link