1. Create a replica of Employee table with all the records in it.
create database if not exists db;
use db;
create table employeee
(
Address varchar(150),
);
2. Drop column ‘Address’ from it.
alter table employeee drop Address;
3. Add columns ‘House No’ character ,’Street No’ numeric,
’Area’ character ,’City’ character in it with the respective
data types.
alter table employeee add
(
House_no varchar(150),
Street_no int primary key,
Area varchar (150),
city varchar(150)
);
4. Change the data type of ‘House No’ from character to
numeric.
alter table employeee modify House_no int ;
5. Create the Data Definitions for each of the relations shown
below, using SQL DDL. Assume the following attributes and
data types:
6. How would you add an attribute, CLASS, to the STUDENT
table?
ALTER TABLE STUDENT
ADD ClassID CHAR(8),
ADD CONSTRAINT fk_Class FOREIGN KEY (ClassID) REFERENCES CLASS(ClassID);
desc student;
7. Write a SQL statement to rename the table department to
dept (with both methods).
rename table department to dept;
alter table department rename dept;
show tables;
8. Write a SQL statement to add a column regionId to the
table locations.
alter table location add (regionID int);
desc location;
9. Write a SQL statement to change the name of the column
state_province to state in locations table, keeping the data
type and size same.
alter table locations change column state_province state varchar(20);
desc locations;