0% found this document useful (0 votes)
35 views3 pages

Exp 2-1

The document outlines an experiment focused on using SQL Data Definition Language (DDL) statements to create, alter, drop, rename, and truncate database tables. It includes objectives, theoretical background, common DDL commands, and step-by-step examples for practical application. The expected outcomes emphasize students' ability to manage relational tables and understand the implications of each command.

Uploaded by

smkodole06
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)
35 views3 pages

Exp 2-1

The document outlines an experiment focused on using SQL Data Definition Language (DDL) statements to create, alter, drop, rename, and truncate database tables. It includes objectives, theoretical background, common DDL commands, and step-by-step examples for practical application. The expected outcomes emphasize students' ability to manage relational tables and understand the implications of each command.

Uploaded by

smkodole06
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

Experiment No.

2
Title: Use DDL Statements to Crete, Alter, Drop, Rename, Truncate Tables
Aim:
To understand and practice the use of SQL Data Definition Language (DDL) statements for
creating, modifying, and managing relational database tables.
Objectives:
 To learn the syntax and usage of SQL DDL commands.
 To create database tables using the CREATE statement.
 To modify table structure using the ALTER statement.
 To delete entire tables using the DROP statement.
 To reset table data using the TRUNCATE command.
 To change the name of tables using the RENAME command.
 To perform hands-on activities and understand the impact of each command.
Theory:
What is DDL?
Data Definition Language (DDL) is a subset of SQL used to define and manage the structure
of database objects such as tables, indexes, and schemas.
Common DDL Commands:

Command Description

CREATE Creates a new table or other database object

ALTER Modifies existing table structure (add, drop, or modify column)

DROP Permanently deletes a table or database structure

RENAME Renames a table or column

TRUNCATE Removes all data from a table but not the table itself

Step-by-Step Execution with Example:


🔹 1. CREATE TABLE
1. CREATE TABLE
Create a table to store laboratory equipment:
sql
CREATE TABLE LabEquipment (
EquipmentID INT PRIMARY KEY,
Name VARCHAR(100),
LabName VARCHAR(100),
PurchaseYear INT,
Status VARCHAR(50)
);
Creates a LabEquipment table to manage equipment inventory in ETC labs.
2. ALTER TABLE
Add a Supplier column to the LabEquipment table:
sql
ALTER TABLE LabEquipment
ADD Supplier VARCHAR(100);
Adds a column to record the equipment supplier.
3. RENAME TABLE
Rename the LabEquipment table to EquipmentList:
sql
RENAME TABLE LabEquipment TO EquipmentList;
Renames an existing table for better clarity.
(In some RDBMS, use: ALTER TABLE LabEquipment RENAME TO EquipmentList;)
4. TRUNCATE TABLE
Remove all records from the EquipmentList (but keep the structure):
sql
TRUNCATE TABLE EquipmentList;
Deletes all data, but retains table schema for future entries.
5. DROP TABLE
Delete the EquipmentList table permanently:
sql
DROP TABLE EquipmentList;
Expected Outcomes:
Upon completing this lab, students will be able to:
✅ Create relational tables with appropriate data types and constraints.
✅ Modify existing table structure using the ALTER statement.
✅ Rename and drop tables effectively and safely.
✅ Understand the difference between TRUNCATE and DELETE.
✅ Apply these DDL commands while working with real-world database schemas.

You might also like