Insert a record in two tables

How to insert a record in two tables with single insert statement ?

Questions by janardanneppali   answers by janardanneppali

Showing Answers 1 - 7 of 7 Answers

If there is any parent-child relation between the table, disable it first.

ALTER TABLE emp
DISABLE CONSTRAINT FK_DEPTNO;

/*Inserting data in two tables in a single query*/
INSERT ALL
INTO dept(DEPTNO, DNAME) VALUES (deptno , dname)
INTO emp (EMPNO, DEPTNO) VALUES (empno , deptno)
SELECT 10 empno , 60 deptno, 'Testing' dname
FROM dual;


ALTER TABLE emp
ENABLE CONSTRAINT FK_DEPTNO;

Nazeera Jaffar

  • Sep 30th, 2012
 

Answer:

Code
  1.  

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions