我在使用Oracle 11g执行以下sql查询时遇到错误
ALTER TABLE table add column_col integer DEFAULT table_seq.nextval not null;
Error report -
ORA-00984: column not allowed here
00984. 00000 - "column not allowed here"
答案 0 :(得分:1)
该语法不适用于11g。这是12的新功能。你需要一个触发器:
CREATE OR REPLACE TRIGGER "TRIGGERNAME" BEFORE INSERT ON <<TABLENAME>>
FOR EACH ROW
WHEN (new."COLUMNNAME" IS NULL)
BEGIN
SELECT table_seq.nextval
INTO :new."COLUMNNAME"
FROM dual;
END;
/