我创建了一个表为fllow:
CREATE TABLE"COMMODITY"
(COM_NO VARCHAR2(10) NOT NULL,
COM_NAME VARCHAR2(100) NOT NULL,
SHOP_NO VARCHAR2(10)NOT NULL,
FRU_NO VARCHAR2(10)NOT NULL,
COM_PRICE NUMBER(10)NOT NULL,
COM_WEIGHT VARCHAR2(30)NOT NULL,
COM_REMARKS CLOB NOT NULL,
COM_PIC1 BLOB,
COM_PIC2 BLOB,
COM_PIC3 BLOB,
COM_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
COM_STATUS VARCHAR2(10) NOT NULL,
COM_STORE NUMBER(10) NOT NULL,
COM_SCORE NUMBER(2,1)NOT NULL,
COM_PEO NUMBER(10)NOT NULL,
CONSTRAINT COM_COM_NO_PK PRIMARY KEY (COM_NO),
CONSTRAINT COM_SHOP_NO_FK FOREIGN KEY (SHOP_NO) REFERENCES SHOP(SHOP_NO),
CONSTRAINT COM_FRU_NO_FK FOREIGN KEY (FRU_NO) REFERENCES FRUIT(FRU_NO)
);
AND序列是
CREATE SEQUENCE COM_NO_SEQ
INCREMENT BY 1
START WITH 1
NOMAXVALUE
NOCACHE
NOCYCLE;
我正在尝试执行以下操作:
INSERT INTO COMMODITY VALUES('COM'||LPAD(TO_CHAR(COM_NO_SEQ.NEXTVAL),7,'0'),'平安蘋果','SHO0000001','FRU0000001',1200,'一箱約1斤','好吃的蘋果喔我是CLOB','24-6月-17 03.22.39','上架',80,0,0);
我将值赋给所有列为NOT NULL的列。但仍然存在ORA-00947的问题:没有足够的值。
Plz告诉我为什么?
答案 0 :(得分:2)
您应该在insert语句中提供列名,如以下示例所示。如果您没有提供映射值的列列表,那么Oracle需要表中所有列的值。
如果省略列列表,则values_clause或query必须指定表中所有列的值 INSERT Staement
SQL> create table tt1 (id number not null, name varchar2(20));
Table created.
SQL> insert into tt1 values('Joe');
insert into tt1 values('Joe')
*
ERROR at line 1:
ORA-00947: not enough values
SQL> insert into tt1 values(1);
insert into tt1 values(1)
*
ERROR at line 1:
ORA-00947: not enough values
SQL> insert into tt1(id) values(1);
1 row created.