0% found this document useful (0 votes)
4 views2 pages

Experiment 6: DDL Commands in SQL: Lab Objective

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Experiment 6: DDL Commands in SQL: Lab Objective

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Experiment 6: DDL Commands in SQL

Lab Objective:
This lab aims to equip students with practical skills in using Data Definition Language
(DDL) commands in SQL. Students will learn to create, modify, and delete tables,
understanding how these operations are essential for managing database schemas.

Prerequisites:
●​ A foundational understanding of relational databases and SQL syntax.
●​ Familiarity with basic SQL operations such as selecting and inserting data.
●​ Access to an SQL environment (e.g., MySQL, PostgreSQL, SQL Server).

Lab Exercises:
1. Creating a Table
CREATE TABLE Students (
StudentID INT PRIMARY KEY NOT NULL,
FirstName VARCHAR(50) NOT NULL,
LastName VARCHAR(50) NOT NULL,
DateOfBirth DATE NOT NULL,
Email VARCHAR(100) UNIQUE NOT NULL
);

●​ The StudentID column is the Primary Key to ensure uniqueness.


●​ The Email column is Unique and Not Null, preventing duplicate or null email
entries.
●​ The DateOfBirth column ensures every student has a valid birth date.

2. Altering a Table

Adding a New Column


ALTER TABLE Students ADD PhoneNumber VARCHAR(15);

●​ This adds a PhoneNumber column to store students' contact details.


Modifying a Column Constraint
ALTER TABLE Students MODIFY Email VARCHAR(100) NOT NULL;

●​ This ensures that the Email column cannot contain null values.

3. Dropping a Table
DROP TABLE Students;

●​ This completely removes the Students table from the database.

Outcome:
Upon completing this lab, students will:

●​ Be proficient in creating tables with specific constraints.


●​ Understand how to alter tables to add or modify columns.
●​ Be able to delete tables from a database, understanding the implications of this
operation.

You might also like