我的数据库出了问题。我创建了表:
CREATE TABLE TOURNAMENT
(
TOURNAMENT_ID INTEGER NOT NULL,
DATE DATE NOT NULL,
CITY VARCHAR2 (100 CHAR) NOT NULL,
PRIZEPOOL NUMBER (18,2) NOT NULL,
COUNTRY VARCHAR2 (100 CHAR) NOT NULL,
ARENA VARCHAR2 (100 CHAR),
SHOP_ID INTEGER,
PRODUCTION_ID INTEGER NOT NULL
);
ALTER TABLE TOURNAMENT ADD CONSTRAINT TOURNAMENT_PK PRIMARY KEY ( TOURNAMENT_ID ) ;
当我尝试插入一行:
prompt Tabulka TOURNAMENT
insert into TOURNAMENT (TOURNAMENT_ID, DATE, CITY, PRIZEPOOL, COUNTRY, ARENA, SHOP_ID, PRODUCTION_ID)
values (1, 08-OCT-2015, 'Moscow', 15000, 'Russia', NULL, 1, 3);
我收到错误消息:
ORA-00984:此处不允许列
有人知道这可能意味着什么吗?
答案 0 :(得分:3)
这应该有效 -
CREATE TABLE TOURNAMENT
(
TOURNAMENT_ID INTEGER NOT NULL ,
TOURNAMENT_DATE DATE NOT NULL ,
CITY VARCHAR2 (100 CHAR) NOT NULL ,
PRIZEPOOL NUMBER (18,2) NOT NULL ,
COUNTRY VARCHAR2 (100 CHAR) NOT NULL ,
ARENA VARCHAR2 (100 CHAR) ,
SHOP_ID INTEGER ,
PRODUCTION_ID INTEGER NOT NULL
) ;
ALTER TABLE TOURNAMENT ADD CONSTRAINT TOURNAMENT_PK PRIMARY KEY ( TOURNAMENT_ID ) ;
insert into TOURNAMENT (TOURNAMENT_ID, TOURNAMENT_DATE, CITY, PRIZEPOOL, COUNTRY, ARENA, SHOP_ID, PRODUCTION_ID) values (1, TO_DATE('08-OCT-2015','DD-MON-YYYY'), 'Moscow', 15000, 'Russia', NULL, 1, 3);
答案 1 :(得分:2)
你正在以错误的方式写日期值;一种方式可以是ANSI格式:
INSERT INTO TOURNAMENT(
TOURNAMENT_ID,
DATE_,
CITY,
PRIZEPOOL,
COUNTRY,
ARENA,
SHOP_ID,
PRODUCTION_ID
)
VALUES (
1,
DATE '2015-10-08',
'Moscow',
15000,
'Russia',
NULL,
1,
3
);
或者,如果您想保留所显示的格式,请使用to_date
:
to_date('08-OCT-2015', 'DD-MON-YYYY')
此外,DATE
是一个保留字,你最好避免使用它来命名表格列。