我跑的第一个ddl脚本告诉我我有错误。来发现这是因为我的命令之间有空格。我删除了空格,并且假脱机正常,假脱机文件中没有错误消息。现在,我正在尝试将数据插入表中,并且我收到了一堆错误,例如无效日期。即使日期是正确的。我也有其他一些错误。我应该知道一些其他格式问题吗?
SQL> set echo on
SQL> insert into distributor (distributor_id, distributor_name, address, phone)
2 values('1','efd sales','3540 lennox st', '3015899389')
3 /
1 row created.
SQL> insert into distributor (distributor_id, distributor_name, address, phone)
2 values('2','emd sales','3541 lennox st', '3025899389')
3 /
1 row created.
SQL> insert into distributor (distributor_id, distributor_name, address, phone)
2 values('3','emo sales','3542 lennox st', '3035899389')
3 /
1 row created.
SQL> insert into distributor (distributor_id, distributor_name, address, phone)
2 values('4','amd sales','3543 lennox st', '3045899389')
3 /
1 row created.
SQL> insert into distributor (distributor_id, distributor_name, address, phone)
2 values('5','exo sales','3544 lennox st', '3055899389')
3 /
1 row created.
SQL> insert into genre(genre_id,genre)
2 values('1101','horror')
3 /
1 row created.
SQL> insert into genre(genre_id,genre)
2 values('1102','fantasy')
3 /
1 row created.
SQL> insert into genre(genre_id,genre)
2 values('1103','sports')
3 /
1 row created.
SQL> insert into genre(genre_id,genre)
2 values('1104','entertainment')
3 /
1 row created.
SQL> insert into genre(genre_id,genre)
2 values('1105','adventure')
3 /
1 row created.
SQL> insert into movie(movie_id,genre_id,title,release_date,duration,movie_type,rating,rent_price)
2 values('1','1101','fly','02/09/92','45:00','horror','5/10','5.00')
3 /
values('1','1101','fly','02/09/92','45:00','horror','5/10','5.00')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into movie(movie_id, genre_id, title, release_date, duration,movie_type,rating,rent_price)
2 values('2','1102','fly2','02/12/93','45:00','horror','5/10','5.00')
3 /
values('2','1102','fly2','02/12/93','45:00','horror','5/10','5.00')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into movie(movie_id, genre_id, title, release_date, duration,movie_type,rating,rent_price)
2 values('3','1103','fly3','02/12/94','45:00','horror','5/10','5.00')
3 /
values('3','1103','fly3','02/12/94','45:00','horror','5/10','5.00')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into movie(movie_id, genre_id, title, release_date, duration,movie_type,rating,rent_price)
2 values('4','1104','fly4','02/12/95','45:00','horror','5/10','5.00')
3 /
values('4','1104','fly4','02/12/95','45:00','horror','5/10','5.00')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into movie(movie_id, genre_id, title, release_date, duration,movie_type,rating,rent_price)
2 values('5','1105','fly5','02/12/96','45:00','horror','5/10','5.00')
3 /
values('5','1105','fly5','02/12/96','45:00','horror','5/10','5.00')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into sells(transaction_id,distributor_id,movie_id,quantity,purchase_date)
2 values('1','1','1','1','02/10/92')
3 /
values('1','1','1','1','02/10/92')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into sells(transaction_id,distributor_id,movie_id,quantity,purchase_date)
2 values('2','2','1','2','02/10/92')
3 /
values('2','2','1','2','02/10/92')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into sells(transaction_id,distributor_id,movie_id,quantity,purchase_date)
2 values('3','3','1','3','02/10/92')
3 /
values('3','3','1','3','02/10/92')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into sells(transaction_id,distributor_id,movie_id,quantity,purchase_date)
2 values('4','4','1','4','02/10/92')
3 /
values('4','4','1','4','02/10/92')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into sells(transaction_id,distributor_id,movie_id,quantity,purchase_date)
2 values('5','5','1','5','02/10/92')
3 /
values('5','5','1','5','02/10/92')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into dvd(
2 dvd_movie_id, dvd_count
3 )
4 values('1','1')
5 /
1 row created.
SQL> insert into dvd(
2 dvd_movie_id, dvd_count
3 )
4 values('2','2')
5 /
1 row created.
SQL> insert into dvd(
2 dvd_movie_id, dvd_count
3 )
4 values('3','3')
5 /
1 row created.
SQL> insert into dvd(
2 dvd_movie_id, dvd_count
3 )
4 values('4','4')
5 /
1 row created.
SQL> insert into dvd(
2 dvd_movie_id, dvd_count
3 )
4 values('5','5')
5 /
1 row created.
SQL> insert into video(vid_mov_id
2 )
3 values('1')
4 /
1 row created.
SQL> insert into video(vid_mov_id)
2 values('2')
3 /
1 row created.
SQL> insert into video(vid_mov_id)
2 values('3')
3 /
1 row created.
SQL> insert into video(vid_mov_id)
2 values('4')
3 /
1 row created.
SQL> insert into video(vid_mov_id)
2 values('5')
3 /
1 row created.
SQL> insert into director(director_id,NAME,ADDRESS,city,state)
2 values('1','john1','123 buck st','laurel','maryland')
3 /
1 row created.
SQL> insert into director(director_id,NAME,ADDRESS,city,state)
2 values('2','john2','124 buck st','bowie','maryland')
3 /
1 row created.
SQL> insert into director(director_id,NAME,ADDRESS,city,state)
2 values('3','john3','125 buck st','canton','maryland')
3 /
1 row created.
SQL> insert into director(director_id,NAME,ADDRESS,city,state)
2 values('4','john4','126 buck st','wats','maryland')
3 /
1 row created.
SQL> insert into director(director_id,NAME,ADDRESS,city,state)
2 values('5','john5','127 buck st','canne','maryland')
3 /
1 row created.
SQL> insert into movie_director(director_id,movie_id)
2 values('1','1')
3 /
insert into movie_director(director_id,movie_id)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_MOVIE_DIRECTOR) violated -
parent key not found
SQL> insert into movie_director(director_id,movie_id)
2 values('2','2')
3 /
insert into movie_director(director_id,movie_id)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_MOVIE_DIRECTOR) violated -
parent key not found
SQL> insert into movie_director(director_id,movie_id)
2 values('3','3')
3 /
insert into movie_director(director_id,movie_id)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_MOVIE_DIRECTOR) violated -
parent key not found
SQL> insert into movie_director(director_id,movie_id)
2 values('4','4')
3 /
insert into movie_director(director_id,movie_id)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_MOVIE_DIRECTOR) violated -
parent key not found
SQL> insert into movie_director(director_id,movie_id)
2 values('5','5')
3 /
insert into movie_director(director_id,movie_id)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_MOVIE_DIRECTOR) violated -
parent key not found
SQL> insert into member(member_id,first_name,last_name,address)
2 values('1','james1','jones2','12 mirk st')
3 /
1 row created.
SQL> insert into member(member_id,first_name,last_name,address)
2 values('2','james2','jones2','123 mirk st')
3 /
1 row created.
SQL> insert into member(member_id,first_name,last_name,address)
2 values('3','james3','jones2','124 mirk st')
3 /
1 row created.
SQL> insert into member(member_id,first_name,last_name,address)
2 values('4','james4','jones2','125 mirk st')
3 /
1 row created.
SQL> insert into member(member_id,first_name,last_name,address)
2 values('5','james5','jones2','126 mirk st')
3 /
1 row created.
SQL> insert into rental_transaction(rental_id,rental_date,due_date,movie_id,member_id)
2 values('1','08/08/15','08/08/15','1','1')
3 /
values('1','08/08/15','08/08/15','1','1')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into rental_transaction(rental_id,rental_date,due_date,movie_id,member_id)
2 values('2','09/08/15','09/08/15','2','2')
3 /
values('2','09/08/15','09/08/15','2','2')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into rental_transaction(rental_id,rental_date,due_date,movie_id,member_id)
2 values('3','10/08/15','10/08/15','3','3')
3 /
values('3','10/08/15','10/08/15','3','3')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into rental_transaction(rental_id,rental_date,due_date,movie_id,member_id)
2 values('4','11/08/15','11/08/15','4','4')
3 /
values('4','11/08/15','11/08/15','4','4')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into rental_transaction(rental_id,rental_date,due_date,movie_id,member_id)
2 values('5','12/08/15','12/08/15','5','5')
3 /
values('5','12/08/15','12/08/15','5','5')
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> insert into actor(actor_id, full_name)
2 values('1','carl lime')
3 /
1 row created.
SQL> insert into actor(actor_id, full_name)
2 values('2','carl lewis')
3 /
1 row created.
SQL> insert into actor(actor_id, full_name)
2 values('3','john lewis')
3 /
1 row created.
SQL> insert into actor(actor_id, full_name)
2 values('4','carl less')
3 /
1 row created.
SQL> insert into actor(actor_id, full_name)
2 values('5','yerl wise')
3 /
1 row created.
SQL> insert into actor_role(role_type,movie_id,actor_id)
2 values('lead','1','1')
3 /
insert into actor_role(role_type,movie_id,actor_id)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_ACTOR_ROLE) violated - parent
key not found
SQL> insert into actor_role(role_type,movie_id,actor_id)
2 values('lead','2','2')
3 /
insert into actor_role(role_type,movie_id,actor_id)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_ACTOR_ROLE) violated - parent
key not found
SQL> insert into actor_role(role_type,movie_id,actor_id)
2 values('lead','3','3')
3 /
insert into actor_role(role_type,movie_id,actor_id)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_ACTOR_ROLE) violated - parent
key not found
SQL> insert into actor_role(role_type,movie_id,actor_id)
2 values('lead','4','4')
3 /
insert into actor_role(role_type,movie_id,actor_id)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_ACTOR_ROLE) violated - parent
key not found
SQL> insert into actor_role(role_type,movie_id,actor_id)
2 values('lead','5','5')
3 /
insert into actor_role(role_type,movie_id,actor_id)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_ACTOR_ROLE) violated - parent
key not found
SQL> insert into award(award_id,actor_id,director_id,movie_id, award_name,award_type)
2 values('1','1','1','1','oscar','film')
3 /
insert into award(award_id,actor_id,director_id,movie_id, award_name,award_type)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_AWARD) violated - parent key
not found
SQL> insert into award(award_id,actor_id,director_id,movie_id, award_name,award_type)
2 values('2','2','2','2','oscar','film')
3 /
insert into award(award_id,actor_id,director_id,movie_id, award_name,award_type)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_AWARD) violated - parent key
not found
SQL> insert into award(award_id,actor_id,director_id,movie_id, award_name,award_type)
2 values('3','3','3','3','oscar','film')
3 /
insert into award(award_id,actor_id,director_id,movie_id, award_name,award_type)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_AWARD) violated - parent key
not found
SQL> insert into award(award_id,actor_id,director_id,movie_id, award_name,award_type)
2 values('4','4','4','4','oscar','film')
3 /
insert into award(award_id,actor_id,director_id,movie_id, award_name,award_type)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_AWARD) violated - parent key
not found
SQL> insert into award(award_id,actor_id,director_id,movie_id, award_name,award_type)
2 values('5','5','5','5','oscar','film')
3 /
insert into award(award_id,actor_id,director_id,movie_id, award_name,award_type)
*
ERROR at line 1:
ORA-02291: integrity constraint (DAVE.FK_MOVIE_ID_AWARD) violated - parent key
not found
SQL> insert into movie_awd(mov_awd_id)
2 values('1')
3 /
1 row created.
SQL> insert into movie_awd(mov_awd_id)
2 values('2')
3 /
1 row created.
SQL> insert into movie_awd(mov_awd_id)
2 values('3')
3 /
1 row created.
SQL> insert into movie_awd(mov_awd_id)
2 values('4')
3 /
1 row created.
SQL> insert into movie_awd(mov_awd_id)
2 values('5')
3 /
1 row created.
SQL> insert into director_awd(dir_awd_id)
2 values('1')
3 /
1 row created.
SQL> insert into director_awd(dir_awd_id)
2 values('2')
3 /
1 row created.
SQL> insert into director_awd(dir_awd_id)
2 values('3')
3 /
1 row created.
SQL> insert into director_awd(dir_awd_id)
2 values('4')
3 /
1 row created.
SQL> insert into director_awd(dir_awd_id)
2 values('5')
3 /
1 row created.
SQL> insert into act_awd(act_awd_id)
2 values('1')
3 /
1 row created.
SQL> insert into act_awd(act_awd_id)
2 values('2')
3 /
1 row created.
SQL> insert into act_awd(act_awd_id)
2 values('3')
3 /
1 row created.
SQL> insert into act_awd(act_awd_id)
2 values('4')
3 /
1 row created.
SQL> insert into act_awd(act_awd_id)
2 values('5')
3 /
1 row created.
SQL> spool off
答案 0 :(得分:0)
ORA-01843:不是有效月份
'02/12/93'
是 STRING 而不是 DATE 。始终使用 TO_DATE
将文字明确转换为日期以及所需的格式掩码。
如果Oracle成功根据特定于语言环境的NLS_DATE_FORMAT 的完全匹配进行隐式数据类型转换,您可能会很幸运。
让我们重现错误:
SQL> CREATE TABLE t(a DATE);
Table created.
SQL> INSERT INTO t(a) VALUES('02/12/93');
INSERT INTO t(a) VALUES('02/12/93')
*
ERROR at line 1:
ORA-01843: not a valid month
SQL>
客户端设置中的 NLS_DATE_FORMAT 是:
SQL> show parameter nls_date_format;
NAME TYPE VALUE
------------------------------------ ----------- ---------
nls_date_format string DD-MON-RR
因此,我的客户使用的格式'DD-MON-RR'
与'02/12/93'
正确的方法是:
SQL> INSERT INTO t(a) VALUES(to_date('02/12/1993', 'MM/DD/YYYY'));
1 row created.
另外,请注意年份的格式。如果您使用 YY
而不是 YYYY
,那么您正在重新发明 Y2K 错误。使用 RR
格式或更好地使用* YYYY
**并提及4位数的完整年份。
ORA-02291:违反了完整性约束(DAVE.FK_MOVIE_ID_AWARD) - 父密钥 找不到
这意味着在父表中找不到您尝试插入引用为外键的列的值的引用父键。首先,将行插入父表,然后插入子表。
答案 1 :(得分:0)
我建议用户“DD-MON-YYYY'或插入语句中的to_date(日期,格式)格式。