0% found this document useful (0 votes)
1 views6 pages

DBMS Lab7

The document outlines a series of SQL commands for manipulating a database, including creating a replica of the Employee table, dropping a column, adding new columns, modifying data types, and renaming tables. It also includes instructions for adding attributes to existing tables and changing column names while maintaining data types. The commands demonstrate basic SQL Data Definition Language (DDL) operations for managing database schema.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views6 pages

DBMS Lab7

The document outlines a series of SQL commands for manipulating a database, including creating a replica of the Employee table, dropping a column, adding new columns, modifying data types, and renaming tables. It also includes instructions for adding attributes to existing tables and changing column names while maintaining data types. The commands demonstrate basic SQL Data Definition Language (DDL) operations for managing database schema.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

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;

You might also like