Oracle__7. Oracle 1Z0-051 Exam - Insert_Update_Delete Statements Flashcards
What happens after these 2 statements? CREATE TABLE orders (order_id NUMBER(10) NOT NULL, customer_id Number(8), order_date DATE DEFAULT SYSDATE); INSERT INTO TABLE (order_id, customer_id, order_date) VALUES (1,null,’05-AUG-2010’)
The record is inserted with a null for the customer_id
What happens after these 2 statements? CREATE TABLE orders (order_id NUMBER(10) NOT NULL, customer_id Number(8), order_date DATE DEFAULT SYSDATE); INSERT INTO TABLE (order_id, customer_id, order_date) VALUES (1,12,null)
The record is inserted with a null for the customer_id and a default date of today’s date
What happens after these 2 statements? CREATE TABLE orders (order_id NUMBER(10) NOT NULL, customer_id Number(8), order_date DATE DEFAULT SYSDATE); INSERT INTO TABLE (order_id, customer_id, order_date) VALUES (null,12,null)
The record is rejected but the is a null for Order_id
Are all fields required in an INSERT INTO statement?
NoBut all fields declared as NOT NULL must be populated in an INSERT statement
Are all columns that have NOT NULL constraints and defaults values required in an INSERT INTO statement?
No. All fields that have defaults declared will automatically be populated on an insert into statement.
What is the syntax for an insert statement if more than one record?
INSERT ALL INTO (field1, field2…) VALUES (exp1, exp2, …) INTO (field1, field2…) VALUES (exp1, exp2, …) INTO (field1, field2…) VALUES (exp1, exp2, …)SELECT * FROM dual;
What is the syntax of an INSERT statement where the field name list can be eliminated?
INSERT INTO table2 SELECT * FROM table1All the field names and data types must match and be in the same order between the 2 tables
What reason would a values clause be used in an insert statement?
to insert records using expressions or hard coded values that are not retrieved from other tables?
Is a constraint only enforced by an INSERT operation on the table?
NoA constraint is also enforced by an UPDATE operation on a table
The default format for a date column is DD-MON-RR, so on an insert can you insert 10-JANUARY-2014?
Yes.Months are implicitly convertedYears are implicitly converted
What will happen with this insert statement? Insert into table (id, statename) values (&id, ‘&statename’);
The user will be prompted for the ID then the statename.
What will happen with this insert statement? insert into table(id, statename) values (&id, ‘&&statename’)
The user will be prompred for the ID and the statename only the first time. The first statename will be remembered to the user will not be prompted for the statename the subsequent inserts.
What can be used in place of the VALUES clause in an INSERT statement?
a select statement
Is there anything incorrect with this INSERT statement? UPDATE employees SET job = ‘IT’, commission = null where employee = 114;
Everything is syntactically correct.
The MERGE command the same as performing what 2 other commands?
UPDATE and INSERTThe Merge command will perform an UPDATE and then an INSERT