我正在使用oracle 10g来创建表,但它显示“ORA-00922:缺少或无效选项”,并且在.nextval
的底部序列行的查询中,它显示红色标记行,从很长一段时间寻找它。
CREATE TABLE "TICKET_TABLE" (
"TKT_NUMBER" NUMBER NOT NULL ENABLE,
"TKT_STATUS" VARCHAR2(10),
"TKT_CLIENT" VARCHAR2(10),
"TKT_ASSIGN" VARCHAR2(15),
"TKT_PROJ" VARCHAR2(15),
"TKT_SUB" VARCHAR2(100),
"TKT_BODY" VARCHAR2(200),
"USER_NAME" VARCHAR2(15) NOT NULL ENABLE,
CONSTRAINT "TICKET_TABLE_PK" PRIMARY KEY ("TKT_NUMBER") ENABLE) /
CREATE OR REPLACE TRIGGER "BI_TICKET_TABLE"
before insert on "TICKET_TABLE" for each row
begin
select "TICKET_SEQ".nextval into :NEW.TKT_NUMBER from dual;
end;
/ ALTER TRIGGER "BI_TICKET_TABLE" ENABLE /
答案 0 :(得分:0)
使用不带双引号的序列名称
select TICKET_SEQ.nextval
答案 1 :(得分:0)
您可能忘记了创建序列“TICKET_SEQ” 尝试使用以下格式的查询,
创建表“TICKET_TABLE” ( “TKT_NUMBER”NUMBER NOT NOT NULL ENABLE, “TKT_STATUS”VARCHAR2(10), “TKT_CLIENT”VARCHAR2(10), “TKT_ASSIGN”VARCHAR2(15), “TKT_PROJ”VARCHAR2(15), “TKT_SUB”VARCHAR2(100), “TKT_BODY”VARCHAR2(200), “USER_NAME”VARCHAR2(15)NOT NULL ENABLE, 约束“TICKET_TABLE_PK”主键(“TKT_NUMBER”)启用 );
创建序列“TICKET_SEQ”minvalue 1 maxvalue 100 increment BY 1以10开始;
SET定义OFF;
之前创建或替换TRIGGER“BI_TICKET_TABLE”
为每行BEGIN插入“TICKET_TABLE”
SELECT TICKET_SEQ.nextval INTO:NEW.TKT_NUMBER FROM dual;
END;
ALTER TRIGGER“BI_TICKET_TABLE”ENABLE;