Page 160 - Informatics_Practices_Fliipbook_Class12
P. 160
On executing the above statement, we get the result as given in Table 11.6b:
Field Type Null Key Default Extra
ID char(5) NO PRI NULL
FName varchar(20) NO NULL
LName varchar(20) NO NULL
Gender char(1) NO NULL
Address varchar(30) YES NULL
City varchar(20) YES NULL
Pin_Code char(6) YES NULL
DOB date YES NULL
Salary int(11) NO NULL
Dept_No int(11) YES NULL
Phone decimal(10,0) YES 9999999999
MOBILE decimal(10,0) YES 9999999999
EMAIL varchar(50) YES NULL
Table 11.6b: Structure of EMPLOYEE table after modifying Dept_No
Drop Attributes
To drop an attribute from a table, we use the ALTER TABLE statement with the DROP keyword. The syntax of the
ALTER TABLE DROP statement is as follows:
ALTER TABLE table_name DROP attribute;
For example, to drop the attributes Phone, Mobile, and EMAIL from the EMPLOYEE table, we can execute
the following SQL statements:
ALTER TABLE EMPLOYEE DROP Phone;
ALTER TABLE EMPLOYEE DROP Mobile;
ALTER TABLE EMPLOYEE DROP EMAIL;
As before, we describe the modified table EMPLOYEE as follows:
DESC EMPLOYEE;
On executing the above statement, we get the result as given in Table 11.6c:
Field Type Null Key Default Extra
ID char(5) NO PRI NULL
FName varchar(20) NO NULL
LName varchar(20) NO NULL
Gender char(1) NO NULL
Address varchar(30) YES NULL
City varchar(20) YES NULL
Pin_Code char(6) YES NULL
DOB date YES NULL
Salary int(11) NO NULL
Dept_No int(11) YES NULL
Table 11.6c: Structure of EMPLOYEE table after dropping the Phone attribute
146 Touchpad Informatics Practices-XII

