Inserting data into different tables at once in oracle sql 1

Inserting data into different tables at once in oracle sql

INSERT INTO table1 t1, table2 t2 
(t1.tid, t1.date, t1.title, t2.tid, t2.date, t2.user, t2.note)
VALUES (1,'01-JAN-15','title',1,'01-JAN-15','john','test note');

Here is what the above code is Doing:
1. It’s creating a table called table1 with 3 columns: tid, date, and title.
2. It’s creating a table called table2 with 4 columns: tid, date, user, and note.
3. It’s inserting a row into table1 with the values 1, ’01-JAN-15′, and ‘title’.
4. It’s inserting a row into table2 with the values 1, ’01-JAN-15′, ‘john’, and ‘test note’.
5. It’s inserting a row into table1 and table2 with the values 1, ’01-JAN-15′, ‘title’, 1, ’01-JAN-15′, ‘john’, and ‘test note’.

Similar Posts