Skip to main content

Posts

Showing posts with the label insert

18. ADDING CHECK CONSTRAINT WHILE INSERTING.

Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER NOT NULL EMP_NAME VARCHAR2(30) JOB_ID VARCHAR2(20) SAL NUMBER MGR_ID NUMBER DEPARTMENT_ID NUMBER You want to create a SQL script file that contains an INSERT statement. When the script is run, the INSERT statement should insert a row with the specified values into the EMPLOYEES table. The INSERT statement should pass values to the table columns as specified below: EMPLOYEE_ID: Next value from the sequence EMP_ID_SEQEMP_NAME and JOB_ID: As specified by the user during run time, through substitution variables SAL: 2000 MGR_ID: No value DEPARTMENT_ID: Supplied by the user during run time throughsubstitutionvariable. The INSERT statement should fail if the user supplies a value other than20 or 50. Which INSERT statement meets the above requirements? A. INSERT INTO employees VALUES (emp_id_seq.NEXTVAL, '&ename', '&jobid', 2000, NULL,&did); B. INSERT INTO employees VALUES (emp_id_seq.NEXTVAL, '...

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 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