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

DB - Lab Manual 04

The lab manual for Database Systems Lab outlines objectives for students to understand and apply DDL and DML commands, identify SQL data types, and work with primary keys. It provides definitions and examples of DDL and DML commands, common SQL data types, and a lab task involving the creation of a database and tables. Students are expected to perform various SQL operations, including creating, modifying, and querying data in a structured format.

Uploaded by

fatu9489
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 views11 pages

DB - Lab Manual 04

The lab manual for Database Systems Lab outlines objectives for students to understand and apply DDL and DML commands, identify SQL data types, and work with primary keys. It provides definitions and examples of DDL and DML commands, common SQL data types, and a lab task involving the creation of a database and tables. Students are expected to perform various SQL operations, including creating, modifying, and querying data in a structured format.

Uploaded by

fatu9489
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/ 11

Database Systems Lab

Lab Manual 04

Session: Spring-2025
Instructor: SHEZA SHABIR

Department of Informatics & Systems


School of System & Technology
University of Management & Technology Lahore Pakistan
Objective: (CLO1, CLO2, CLO3)

By the end of this lab, students should be able to:

• Understand and apply DDL and DML commands


• Identify and use common SQL data types
• Define and apply primary keys
• Create tables using CREATE
• Modify tables using ALTER, DROP, ADD
• Insert, update, select, and delete data using DML

1. What is DDL (Data Definition Language)?

DDL is used to define and modify database structures like tables.

Common DDL Commands:

• CREATE – To create a new table or database


• ALTER – To modify an existing table
• DROP – To delete a table or database

2. What is DML (Data Manipulation Language)?

DML is used to manage data in the tables.

Common DML Commands:

• INSERT – To add new data


• UPDATE – To change existing data
• DELETE – To remove data
• SELECT – To read data

3. Common SQL Data Types

Here are some basic ones you’ll use often:

Data Type Description


INT Whole numbers (e.g. 1, 2)
FLOAT Decimal numbers (e.g. 2.5)
VARCHAR(n) Text up to n characters
DATE Date (e.g. 2025-04-20)
BOOLEAN True or False values
4. What is a Primary Key?

A primary key is a column (or set of columns) that:

• Uniquely identifies each row


• Cannot be NULL
• Only one per table

Example: A student_id column that uniquely identifies each student.

Types of SQL Commands

SQL commands are categorized into the following types:

1. DDL (Data Definition Language): These commands are used to define and modify the
structure of database objects like tables.

Example: CREATE, ALTER, DROP.

Create Database Statement:


Create Table Statement:

2. Drop Command:
3. Alter Command:

4.
5. DML (Data Manipulation Language): These commands are used to manipulate and interact
with data within the tables.

Example: INSERT, UPDATE, DELETE, SELECT.

• The SQL Insert into the statement:

The INSERT INTO statement is used to insert new records in a table.

Syntax:

INSERT INTO table_name (column1, column2, column3, ...)


VALUES (value1, value2, value3, ...);

• Select Command:
Lab Task

This is your task. Follow the steps below:

1. Create a database.
➤ Name of the database: Write your own name here (e.g., AreebaDB)
2. Create the following five tables in SQL Server:
• Show all books where price is more than 400.
• Show all members whose name starts with 'A'.
• Show all issued books with return date before '2025-04-22'.
• Show all authors from 'USA'’
• Show category where name is 'Networking'.
• Drop categories table.

You might also like