누구든지이 문제를 해결할 수 있는지 궁금합니다. SQL에서 모든 것을 실행했지만 그 오류가 발생했습니다.PK가 oracle sql에서 위반했습니다
Error report: SQL Error: ORA-00001: unique constraint (GAMES.ATHLETE_PK) violated 00001. 00000 - "unique constraint (%s.%s) violated" *Cause: An UPDATE or INSERT statement attempted to insert a duplicate key. For Trusted Oracle configured in DBMS MAC mode, you may see this message if a duplicate entry exists at a different level. *Action: Either remove the unique restriction or do not insert the key.
한 번에 모든 레코드를 삽입하려고합니다. 시퀀스를 사용하여 새로운 기본 키를 생성 할 수도 있습니다. 나는 하나씩 하나씩 삽입 해 보았습니다. 하지만 한번에 모두 삽입하면 오류가 발생합니다 ...
INSERT ALL
INTO athlete (athlete_no, athlete_name, athlete_birthdate, athlete_birthplace, athlete_born_country, athlete_gender, athlete_height, athlete_weight, athlete_team_country)
VALUES (athlete_no_seq.nextval, 'Michael Phelps', to_date('1985-06-30','yyyy-mm-dd'), 'Towson', 'USA', 'M', 193, 88, 'USA')
INTO athlete (athlete_no, athlete_name, athlete_birthdate, athlete_birthplace, athlete_born_country, athlete_gender, athlete_height, athlete_weight, athlete_team_country)
VALUES (athlete_no_seq.nextval, 'Stephanie Rice', to_date('1988-06-17','yyyy-mm-dd'), 'Brisbane', 'AUS', 'F', 176, 67, 'AUS')
INTO athlete (athlete_no, athlete_name, athlete_birthdate, athlete_birthplace, athlete_born_country, athlete_gender, athlete_height, athlete_weight, athlete_team_country)
VALUES (athlete_no_seq.nextval, 'Rebecca Adlington', to_date('1989-02-17','yyyy-mm-dd'), 'Mansfield', 'GBR', 'F', 179, 870, 'GBR')
INTO athlete (athlete_no, athlete_name, athlete_birthdate, athlete_birthplace, athlete_born_country, athlete_gender, athlete_height, athlete_weight, athlete_team_country)
VALUES (athlete_no_seq.nextval, 'Lee Chong Wei', to_date('1982-10-21','yyyy-mm-dd'), 'Perak', 'MAS', 'M', 170, 60, 'MAS')
INTO athlete (athlete_no, athlete_name, athlete_birthdate, athlete_birthplace, athlete_born_country, athlete_gender, athlete_height, athlete_weight, athlete_team_country)
VALUES (athlete_no_seq.nextval, 'Lin Dan', to_date('1983-10-14','yyyy-mm-dd'), 'Fujian', 'CHN', 'M', 176, 68, 'CHN')
INTO athlete (athlete_no, athlete_name, athlete_birthdate, athlete_birthplace, athlete_born_country, athlete_gender, athlete_height, athlete_weight, athlete_team_country)
VALUES (athlete_no_seq.nextval, 'Peter Gade', to_date('1976-12-14','yyyy-mm-dd'), 'Aalborg', 'DEN', 'M', 183, 73, 'DEN')
INTO competes (athlete_no, discipline_code, sg_gameno)
VALUES (athlete_no_seq.currval, (SELECT discipline_code FROM discipline where discipline_name = 'Swimming'), 30)
INTO competes (athlete_no, discipline_code, sg_gameno)
VALUES (athlete_no_seq.currval, (SELECT discipline_code FROM discipline where discipline_name = 'Swimming'), 30)
INTO competes (athlete_no, discipline_code, sg_gameno)
VALUES (athlete_no_seq.currval, (SELECT discipline_code FROM discipline where discipline_name = 'Swimming'), 30)
INTO competes (athlete_no, discipline_code, sg_gameno)
VALUES (athlete_no_seq.currval, (SELECT discipline_code FROM discipline where discipline_name = 'Swimming'), 30)
INTO competes (athlete_no, discipline_code, sg_gameno)
VALUES (athlete_no_seq.currval, (SELECT discipline_code FROM discipline where discipline_name = 'Swimming'), 30)
INTO competes (athlete_no, discipline_code, sg_gameno)
VALUES (athlete_no_seq.currval, (SELECT discipline_code FROM discipline where discipline_name = 'Swimming'), 30)
INTO venue(venue_no, venue_name, venue_location, venue_usedfrom, venueused_to, venue_seatingcapacity, venue_structure, venue_use)
VALUES(venue_no_seq.nextval, 'Aquatics Centre', 'Olympics Park, East London', to_date('2012-07-28','yyyy-mm-dd'), to_date('2012-10-08','yyyy-mm-dd'), 17500, 'N', 'P')
INTO venue(venue_no, venue_name, venue_location, venue_usedfrom, venueused_to, venue_seatingcapacity, venue_structure, venue_use)
VALUES(venue_no_seq.nextval, 'Wembley Arena', 'North West London', to_date('2012-07-28','yyyy-,mm-dd'), to_date('2012-08-05','yyyy-mm-dd'), 6000, 'E', 'P')
SELECT * FROM dual;
commit;
는 '당신은 다중 테이블 삽입 문의 어떤 부분의 순서를 지정할 수 없습니다': 여기
는 게시 된 데이터와이 테이블을 채울 수있는 한 가지 방법이다 /docs.oracle.com/cd/E11882_01/server.112/e26088/statements_9014.htm#i2080134). 시퀀스에 대한 모든 참조는 동일한 값을 갖습니다. 단일 * 트랜잭션 *이 아닌 단일 * 명령문 *에 모든 것을 삽입해야합니까? –각 요소의 삽입을 단일 트랜잭션으로 처리해야합니다. "하나의 요소를 하나의 트랜잭션으로 처리하는 것"으로 이해하지 못합니다. –
전체 문장을 입력하는 올바른 방법이 무엇인지 알 수 있습니까? –