Skip to main content

Posts

Showing posts with the label insert into

Question 16.Inserting more than 1 row/table with single query.

Can we insert more than 1 row with 1 qyery in same table/diff tables? Yes, we insert more than 1 row with 1 qyery by using the following method? syntax INSERT ALL INTO tablename1 (fieldlist) VALUES (valuelist) INTO tablename2 (fieldlist) VALUES (valuelist) INTO tablename3 (fieldlist) VALUES (valuelist) SELECT * FROM DUAL; Example: insert all into student (sno, name) values (1, 'Raja') into student (sno, name) values (2 'Ravi') into student (sno, name) values (3, 'Balu') select * from dual; We can use more than 1 table also. insert all into student (sno, name) values (1, 'Raja') into student (sno, name) values (2 'Ravi') into emp (eno, name) values (1, 'Mani') select * from dual; Interview quesitions and answers, objective type questions with answers : http://atchaya.com/ora/orahome.html Oracle forum : http://atchaya.wikidot.com/forum/c-91091/discussion-about-oracle

Question 13: DDL and Commit

I have updated some tables and before commit if I will give one DDL command means what will happen? For example CREATE TABLE test(fldname number(10)); insert into test (fldname) values (10); insert into test (fldname) values (20); After that without giving Commit statement, I issued one DDL command CREATE TABLE test1( sno number(10)) What aobut the previous inserts? Is it committed or not? explain. Answer: I checked this and found the following 3 points. Point No. 1: If we give a DDL command with syntax error means it will not commit and gives the error. For example the following statement CREATE TABLE test(fldname number(10), ); note that the comma, gives "invalid identifier.. " error and without committing the INSERT statements. Point No. 2: If the given DDL command executes without any error means it will auto commit the INSERT statements. Point No. 3: If we give a DDL command without any syntax error and that statement not execute also auto commit the INSERT st...

Question 10. Inserting Rows

How many number of rows, I can insert into a table simultaenously? Answer : Method 1: If you want to insert multiple rows with a single INSERT statement, you can use a subquery instead of the VALUES clause. Rows returned from the subquery will be inserted the target table. Example: INSERT INTO tablename1 SELECT fieldnamelist FROM tablename WHERE condition