Home » SQL & PL/SQL » SQL & PL/SQL » Sql Insert with PK and Fk
Sql Insert with PK and Fk [message #192107] Mon, 11 September 2006 00:02 Go to next message
selvakumar_82
Messages: 138
Registered: October 2005
Location: chennai
Senior Member
Hi Friends

I have a question, kinldy tell me the solution for this...

I have 2 tables i.e t1 and t2;

In t1 i have

eid as a primary key for this table

did as a foreign key ref dept id of t2 table

and in t2 i have

did as a primary key

eid as a foreign key ---ref primary key of emp t1 table

I want to insert values in these tables

without disable the constraints level.............?

kinldy any one share ur answers

Thanx and regards

Selva.R
Re: Sql Insert with PK and Fk [message #192110 is a reply to message #192107] Mon, 11 September 2006 00:16 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
You will need deferrable constraints
Re: Sql Insert with PK and Fk [message #192197 is a reply to message #192107] Mon, 11 September 2006 07:27 Go to previous messageGo to next message
goudelly
Messages: 52
Registered: August 2006
Location: India
Member

Hi,

Your tables are like this :

create table t1(did number(2), dname varchar2(30),
constraint t1_pk primary key (did));

create table t2(eid number, ename varchar2(30), did number(2),
constraint t2_pk primary key (eid),
constraint t2_fk foreign key(did) references t1(did));

insert into t1 values(10, 'abcd');

insert into t2 values(1,'xyz',10);

I think this may sort out the your problem

thanks,

Mohan Reddy G

Re: Sql Insert with PK and Fk [message #192198 is a reply to message #192197] Mon, 11 September 2006 07:28 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
table t1 doesn't have a fk to t2 as the OP indicated..
Previous Topic: SQL Time-out
Next Topic: Date in Group By Clause
Goto Forum:
  


Current Time: Wed Dec 07 04:44:35 CST 2016

Total time taken to generate the page: 0.06793 seconds