Which is the valid CREATE TABLE statement?
- CREATE TABLE emp9$# (emp_no NUMBER(4));
- CREATE TABLE 9emp$# (emp_no NUMBER(4));
-
CREATE TABLE emp*123 (emp_no NUMBER(4));
- CREATE TABLE emp9$# (emp_no NUMBER(4), date DATE);
In Oracle SQL, table names must start with a letter (A-Z or a-z), not a digit. They can contain letters, digits, and special characters like $, #, and _. Option A starts with 'e' (a letter) and uses allowed special characters, making it valid. Option B starts with digit 9, which is invalid. Option C contains '*' which is not allowed in table names.
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) CREATE TABLE emp9$# (emp_no NUMBER(4)) - This option is valid. It creates a table called "emp9$#" with a column named "emp_no" of data type "NUMBER(4)".
Option B) CREATE TABLE 9emp$# (emp_no NUMBER(4)) - This option is incorrect. The table name cannot start with a number. Therefore, this statement is not valid.
Option C) CREATE TABLE emp*123 (emp_no NUMBER(4)) - This option is incorrect. The table name cannot contain special characters like "*", so this statement is not valid.
Option D) CREATE TABLE emp9$# (emp_no NUMBER(4), date DATE) - This option is valid. It creates a table called "emp9$#" with two columns named "emp_no" of data type "NUMBER(4)" and "date" of data type "DATE".
The correct answer is Option A. This option is correct because it follows the rules for creating a valid table name and column definition.