-1

谁能向我解释为什么我在运行以下命令时出现 00904 错误,我需要在表中插入 100 行,但我不知道为什么会出现错误

 drop table DWH_ITEM_DIM;
 CREATE TABLE DWH_ITEM_DIM(
 ITEM_ID NUMBER NOT NULL,
 ITEM_NAME VARCHAR2(5) NOT NULL,
 ITEM_TYPE VARCHAR2(1) NOT NULL,
 ITEM_COST NUMBER(10,2) NOT NULL,
 ITEM_PRICE NUMBER(10,2) NOT NULL,
 ITEM_FOR_SALE VARCHAR2(1) NOT NULL,
 CONSTRAINT ITEM_ID_PK PRIMARY KEY (ITEM_ID));

  DROP SEQUENCE DWH_ITE_SEQ;
 CREATE SEQUENCE DWH_ITE_SEQ
 START WITH 1
 INCREMENT BY 1
 NOCACHE
 NOCYCLE;

 TRUNCATE TABLE DWH_ITEM_DIM;
 INSERT INTO DWH_ITEM_DIM
 SELECT DWH_ITE_SEQ.NEXTAVL AS ITEM_ID,
 DBMS_RANDOM.STRING('U',5) AS ITEM_NAME,
 DBMS_RANDOM.STRING('U',1) AS ITEM_TYPE,
 ROUND(dbms_random.value(LOW =>25,HIGH =>300),2) AS ITEM_COST,
 ROUND(dbms_random.value(LOW =>25,HIGH =>300),2) AS ITEM_PRICE,
 DBMS_RANDOM.STRING('U',1) AS ITEM_FOR_SALE
 FROM DUAL
 CONNECT BY LEVEL <= 100;
 COMMIT;

当我运行它时,“脚本输出”是:

table DWH_ITEM_DIM dropped.
table DWH_ITEM_DIM created.
sequence DWH_ITE_SEQ dropped.
sequence DWH_ITE_SEQ created.
table DM.DWH_ITEM_DIM truncated.

Error starting at line 19 in command:
INSERT INTO DM.DWH_ITEM_DIM
 SELECT DWH_ITE_SEQ.NEXTAVL AS ITEM_ID,
 DBMS_RANDOM.STRING('U',5) AS ITEM_NAME,
 DBMS_RANDOM.STRING('U',1) AS ITEM_TYPE,
 ROUND(dbms_random.value(LOW =>25,HIGH =>300),2) AS ITEM_COST,
 ROUND(dbms_random.value(LOW =>25,HIGH =>300),2) AS ITEM_PRICE,
 DBMS_RANDOM.STRING('U',1) AS ITEM_FOR_SALE
 FROM DUAL
 CONNECT BY LEVEL <= 100
Error at Command Line:20 Column:8
Error report:
SQL Error: ORA-00904: "DWH_ITE_SEQ"."NEXTAVL": invalid identifier
00904. 00000 -  "%s: invalid identifier"
*Cause:    
*Action:
commited. 

我不知道为什么?请帮助我,我是甲骨文的新手

4

2 回答 2

3

尝试NEXTVAL代替NEXTAVL.

于 2013-03-20T19:35:17.623 回答
3

这是一个错字,更改NEXTAVLNEXTVAL

于 2013-03-20T19:35:26.587 回答