Examine the structure of the EMPLOYEES table: EMPLOYEE_ID NUMBER Primary Key FIRST_NAME VARCHAR2(25) LAST_NAME VARCHAR2(25) Which three statements inserts a row into the table?
-
INSERT INTO employees VALUES (NULL, 'JOHN','Smith');
-
INSERT INTO employees( first_name, last_name) VALUES ('JOHN','Smith');
-
INSERT INTO employees VALUES ('1000','JOHN','NULL');
-
INSERT INTO employees(first_name,last_name, employee_id) VALUES ('1000, 'john','Smith');
EMPLOYEE_ID is a Primary Key with NOT NULL constraint, so it cannot be NULL. Option A violates this constraint. Option B fails because it omits the required Primary Key column. Option C works because it provides all three values with employee_id='1000' (as string), first_name='JOHN', and last_name='NULL' as a string literal. Option D has syntax errors (missing quote, wrong order).
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) INSERT INTO employees VALUES (NULL, 'JOHN','Smith'); This option is incorrect because it tries to insert a NULL value for the primary key column EMPLOYEE_ID. Since EMPLOYEE_ID is defined as the primary key, it cannot have a NULL value.
Option B) INSERT INTO employees(first_name, last_name) VALUES ('JOHN','Smith'); This option is incorrect because it only specifies the values for the columns FIRST_NAME and LAST_NAME, but it does not specify a value for the primary key column EMPLOYEE_ID. Since EMPLOYEE_ID is defined as the primary key, it must have a value specified during the insertion.
Option C) INSERT INTO employees VALUES ('1000','JOHN','NULL'); This option is correct because it specifies values for all columns - EMPLOYEE_ID, FIRST_NAME, and LAST_NAME. The value '1000' is inserted into the EMPLOYEE_ID column, and the values 'JOHN' and 'NULL' are inserted into the FIRST_NAME and LAST_NAME columns, respectively.
Option D) INSERT INTO employees(first_name,last_name, employee_id) VALUES ('1000, 'john','Smith'); This option is incorrect because it specifies the column names in the wrong order. It tries to insert '1000' into the FIRST_NAME column, 'john' into the LAST_NAME column, and 'Smith' into the EMPLOYEE_ID column. The column names and values do not match correctly.
The correct answer is C. This option correctly inserts a row into the EMPLOYEES table by specifying values for all columns in the correct order.