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 14

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


Amit

Amit

If � means single quote then answer B is fine since when tested inserts 01-Jan-01. Can somebody explain why it is not the correct answer list alongwith answer D?

Bogdan

Bogdan

DROP TABLE ODATA;

CREATE TABLE ODATA
(
ODATA DATE
) ;

INSERT INTO ODATA VALUES(’01 January 01′);

INSERT INTO ODATA VALUES(’01-Jan-01′);

Corect answer B,D;

Cristycool

Cristycool

B is fine anwser!!

bcisneros

bcisneros

B is not correct because you need to cast explicitly the value of the fourth column using TO_DATE function.

atul gupta

atul gupta

it is by default date format of oracle dd-mon-rr so no need to be define to_date()

atul gupta

atul gupta

Ans b is correct

Nikhil

Nikhil

first read the oracle documentation..you have to use to_date function if B is correct

Sagar

Sagar

Assuming the “?” as single quotes, only option B is right. in option D, these quotes are missing, so its not a valid statement.

Josh

Josh

Option B don’t have the symbol ‘-‘ so it isn’t in the default format

Eamon

Eamon

Please note that ‘-‘ is not the only separator.
If the DATE format follows that stated below then you do not need a format mask….

[D|DD] separator1 [MON|MONTH] separator2 [R|RR|YY|YYYY] — The separator1 and separator2 elements may be most punctuation marks, spaces and tabs or evening “nothing”, they can also be different.

JTS

JTS

B is the right answer

TSEKOS

TSEKOS

A , B , C works on my db. D in order to be valid must have the single quotes.

Mr. T

Mr. T

B is the correct answer, assuming the “?” represents single quotes.
D would work, if there were quotes.