When we attempt to create the salary table with this command:
1.CREATE TABLE salary
2.(employee_id NUMBER(9)
3.CONSTRAINT salary_pk PRIMARY KEY,
4.1995_salaryNUMBER(8.2),
5.manager_name VARCHAR2(25)
6.CONSTRAINT mgr_name_nn NOT NULL,
7.Ssalary_96NUMBER(8,2));
Which two lines of this statement will return errors?
Answers
Answer:
1. 1995_salaryNUMBER(8.2),
2. Ssalary_96NUMBER(8,2)
These lines will give error .
Explanation:
- Column Names or Attribute name can contain only alphanumeric characters and must begin with an alphabetic character or an underscore (_). Hence, 1995_salaryNUMBER(8.2) will give an error.
- Ssalary_96NUMBER(8,2) will give an error as there is no gap between attribute name and data type Number.
The actual error-free command will be like this:
CREATE TABLE salary
(employee_id NUMBER(9)
CONSTRAINT salary_pk PRIMARY KEY,
salary_1995 NUMBER(8.2),
manager_name VARCHAR2(25)
CONSTRAINT mgr_name_nn NOT NULL,
Ssalary_96 NUMBER(8,2));
#SPJ3
Answer:
The correct answer is option 1 & 7.
Explanation:
From the above statements, we know that,
1995_salaryNUMBER
Here, the attribute name and column name will only support the alphanumerical characters. They are represented by underscore(_) and alphabetic character.
Therefore, it will show error.
Ssalary_96NUMBER(8,2)
When there is no spaces between a data type number and attribute name it will show error.
Syntax for the following is as follows:
CREATE TABLE salary
(employee_id NUMBER(9)
CONSTRAINT salary_pk PRIMARY KEY,
salary_1995 NUMBER(8.2),
manager_name VARCHAR2(25)
CONSTRAINT mgr_name_nn NOT NULL,
Ssalary_96 NUMBER(8,2));
Therefore, from the above syntax we can conclude that, the syntax will give correct salary table in the data.
#SPJ3