Which INSERT statement is valid?

Examine the structure of the EMPLOYEES table:

Which INSERT statement is valid?

Examine the structure of the EMPLOYEES table:

Which INSERT statement is valid?

A.
INSERT INTO employees (employee_id, first_name, last_name, hire_date) VALUES ( 1000, ,,John, ,,Smith,
,,01/01/01);

B.
INSERT INTO employees(employee_id, first_name, last_name, hire_date) VALUES ( 1000, ,,John, ,,Smith,
01 January 01);

C.
INSERT INTO employees(employee_id, first_name, last_name, Hire_date) VALUES ( 1000, ,,John, ,,Smith,
To_date(,,01/01/01));

D.
INSERT INTO employees(employee_id, first_name, last_name, hire_date) VALUES ( 1000, ,,John, ,,Smith,
01-Jan-01);

Explanation:
It is the only statement that has a valid date; all other will result in an error.
Answer A is incorrect, syntax error, invalid date format



Leave a Reply 4

Your email address will not be published. Required fields are marked *


Daniel

Daniel

Lol, are you KIDDING????. THINK!!!!!
B is correct

mhassan

mhassan

Question is wrong. B,D are correct.

Tested. Two inserts are working

SQL> create table Q40_1z0060 (employee_id number, first_name varchar2(25), last_name varchar2(25), hire_date date);

Table created.

A)

SQL> insert into Q40_1z0060 (employee_id, first_name, last_name, hire_date) VALUES ( 1000, ‘John’, ‘Smith’, ’01/01/01′);
insert into Q40_1z0060 (employee_id, first_name, last_name, hire_date) VALUES ( 1000, ‘John’, ‘Smith’, ’01/01/01′)
*
ERROR at line 1:
ORA-01843: not a valid month

B)

SQL> insert into Q40_1z0060 (employee_id, first_name, last_name, hire_date) VALUES ( 1000, ‘John’, ‘Smith’, ’01 January 01′);

1 row created.

C)

SQL> insert into Q40_1z0060 (employee_id, first_name, last_name, hire_date) VALUES ( 1000, ‘John’, ‘Smith’, To_date(’01/01/01′));
insert into Q40_1z0060 (employee_id, first_name, last_name, hire_date) VALUES ( 1000, ‘John’, ‘Smith’, To_date(’01/01/01′))
*
ERROR at line 1:
ORA-01843: not a valid month

D)

SQL> insert into Q40_1z0060 (employee_id, first_name, last_name, hire_date) VALUES ( 1000, ‘John’, ‘Smith’, ’01-Jan-01′);

1 row created.

SQL>

Francisco

Francisco

only c is completely wrong because is missing the mask.
The other ones can execute properly if the the nls parameters are set accordingly , personal never use that syntax ( always use the to_date to ensure it will work everywhere).

Stefano

Stefano

A is invalid
B is correct if you use ’01 january 01′ instead of 01 january 01
C is invalid
D is correct if you use ’01-jan-01′ instead of 01-jan-01