71. Examples - 4

Alter Command

1. Add a column "Telephone_no" of data type 'number' and size ='10' to the 
   employee table.
Q. alter table employee add(telephone_no number(10));


2. Add a column "country" of datatype 'char' and size='15' to the
   client_mast table.
Q. alter table client_mast add (country char(15));


3. Increase the size of "description" 20 to 25 in product_mast table.
Q. alter table product_mast modify (description varchar2(25));


4. Modify the "product_no" key as a primary key from product_mast table.
Q. alter table product_mast add primary key(product_no);


5. Drop the primary key of client_mast table.
Q. alter table client_mast drop primary key;


6. Define the "deptno" as not null constraint from dept table.
Q. alter table depttable modify deptno not null;


7. Display empno, ename, and annual salary of each employee from employee table
   with a column name "Annual Salary" on the basis of basic_sal.
Q.  select empno as "Employee Number", ename as "Employee 
    Name", basic_sal*12 as "Annual salary"  from employee;


8. Add two columns"HOD" and "Strength" of datatype varchar2 and size=15 to the
   dept table.
Q. alter table depttable add (hod varchar2(15),strength varchar2(15));


9. Add a check constraint for deptno field to the dept table check deptno from 
   the 'D001', 'D002' and 'D003'. 

Q.


No comments:

Post a Comment