Borgaro
Borgaro

Reputation: 26

(Oracle Database 11g) unique constraint violated coming in INSERT/UPDATE

Why do i still get a error even I made my value unique? What I did was first to create the table including the primary keys, and insert the values inside the tables and now I'm trying to add the foreign keys and that's where the problem starts to occur, when I try to alter the table DEPT_Table

create table DEPT_Table(
Dname varchar(15),
Dnumber varchar(6),
Mgr_num varchar(10),
EMP_START_DATE date);

and insert this

insert into DEPT_Table values ('HRAdmin','DTHRA1','MHRA111',TO_DATE('1/8/2017','MM/DD/YYYY'));

and try to connect it to my DEPT_Loc

create table Dept_Loc(
  Dnumber varchar(8),
  DLocation varchar(8));
insert into Dept_Loc values('DLHRA1','BLDG1F2');

It still gets a error, I already tried to make my values unique as possible and each of the respective Departments are named "DTHRA1" for the Dept_Tables and "DLHRA1" for the department location but it still gets the error ORA-00001: unique constraint violated

what can i do to fix this?

Upvotes: 0

Views: 82

Answers (1)

Ed Bangga
Ed Bangga

Reputation: 13006

Seems there's no "DLHRA1" in your primary table. I think you are referring to "DTHRA1"

insert into Dept_Loc values('DTHRA1','BLDG1F2');

Upvotes: 2

Related Questions