Firebird 本身是没有自增型字段,但可以通过序列键产生器和触发器共同来实现,步骤如下:
CREATE TABLE my_table (
my_number integer not null primary key
)
CREATE GENERATOR my_generator
CREATE TRIGGER my_before_trigger FOR my_table
BEFORE INSERT
AS
BEGIN
IF (NEW.my_number IS NULL)
THEN NEW.my_number = GEN_ID(my_generator, 1);
END