0% found this document useful (0 votes)
13 views5 pages

DBMS Lab Manual

The document is a lab manual for Database Management Systems (DBMS) covering various SQL commands including DDL, DML, and constraints. It provides detailed examples of creating, altering, and managing database tables, as well as exercises for students to practice SQL queries. Additionally, it outlines objectives for different experiments related to database design and query execution.

Uploaded by

tagarmy252
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)
13 views5 pages

DBMS Lab Manual

The document is a lab manual for Database Management Systems (DBMS) covering various SQL commands including DDL, DML, and constraints. It provides detailed examples of creating, altering, and managing database tables, as well as exercises for students to practice SQL queries. Additionally, it outlines objectives for different experiments related to database design and query execution.

Uploaded by

tagarmy252
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/ 5

DBMS LAB MANUAL

(DBMS: Database language-DML,DDL,DCL,TCL(write the theory and syntax for each command
present in DDL,DML,DCL,TCL)):

DDL:
Aim: To understand the syntax of basic DDL commands such as

o Create table
o Alter table
▪ Add/Drop attribute
▪ Modify type and size of an attribute
▪ Rename attribute
o Truncate
o Drop

Database used: Student


Table name: student
Students(rollno,name)Add branch
Modify the width of Attribute branch
Modify the datatype of Attribute branch
Rename the attribute
Remove the attribute

mysql> create table students (rollno int,name char(20));

mysql> desc students;

mysql> alter table students add branch char(15);

mysql> desc students;

mysql> alter table students modify branch char(10);

mysql> desc students;

mysql> alter table students modify branch varchar(10);

mysql> desc students;

mysql> alter table students change name sname char(20);

mysql> desc students;

mysql> alter table students drop branch;

mysql> desc students;

mysql> truncate table students;

mysql> drop table students;


DML

Aim: To understand the syntax of basic DML commands such as

o Insert
o Update
o Delete
Database used: Student

mysql> create table students (rollno int, name char (20), branch varchar (20));

mysql> insert into students values(1,'saketh','cse');

mysql> insert into students values(2,'arun','it'),(3,'varun','eee');

mysql> insert into students values(4,'sathish','it'),(4,'sridhar','eee');

mysql> select * from students;

mysql> update students set name='venkat' where rollno=2;


mysql> select * from students;

mysql> update students set name='Vinod’, branch='ece' where rollno=3;

mysql> select * from students;

mysql> update students set name='vamshi' where rollno=4;

mysql> select * from students;

mysql> delete from students where rollno=1;

mysql> select * from students;

mysql> update students set branch='cse';

mysql> select * from students;

mysql> delete from students;

Constraints
Aim: Objective to understand the commands used to impose constraints on a table such as

o Not null
o unique
o primary key
o foreign key
Database used: Bank
Branch ()
Account ()
Loan ()
Customer ()
Depositor ()
Borrower ()

mysql> create table Branch (branch_name varchar (15) , branch city varchar (15) not null,assets
integer not null, primary key(branch_name));

mysql> create table Account (account_number varchar (15), branch_name varchar (15) not
null,balance integer not null, primary key(account_number), foreign key(branch_name)
references Branch(branch_name));

mysql> create table Customer (customer_name varchar(15),customer_street varchar(12) not


null,customer_city varchar(15) not null, customer_ph varchar(10) unique, primary
key(customer_name));

mysql> create table Depositor (customer_name varchar(15),account_number varchar(15),primary


key(customer_name, account_number),foreign key(account_number) references
Account(account_number), foreign key(customer_name) references
Customer(customer_name));

mysql> create table Borrower (customer_name varchar (15), loan_number varchar(15),primary


key (customer_name, loan_number), foreign key(customer_name) references
Customer(customer_name), foreign key(loan_number) references Loan(loan_number));

Adding primary key constraint.

mysql> Create table cust(cust_no integer(10),cust_name varchar(20));


mysql> desc cust;

mysql> Alter table cust add primary key(cust_no);


mysql> desc cust;

Adding foreign key constraint.

mysql> create table cust1(cust_no int(10),cust_name varchar(20));

mysql> desc cust1;

mysql> alter table cust1 add foreign key (cust_no) references cust(cust_no);

mysql> desc cust1;

REMOVING A PRIMARY KEY CONSTRAINT

mysql> alter table cust drop primary key;Query OK,

mysql> desc cust;


Exp No:1

AIM: Write all the SQL queries

(Only syntax)

Exp No: 2

AIM: Analyze the problem and come with the entities in it.

(Write down what is ER Diagram, Components of ER Diagram in detail with 1 example.


Here take reservation database and 4 entities in it-draw only ER Diagram)

Exp No: 3

AIM: Represent all the entities in tabular fashion for reservation Database

(Tables with maximum 2 entries with output i.e. table diagram using SQL queries)

Exp No:4

AIM: Create a Student Database Table and insert datas using all the SQL queries

(Create, insert, update, delete, drop, alter with output i.e. table diagram)

Exp No:5

AIM:Create tables using following constraints:integrity constraint and domain


constraint for college database using department and employee table

(Tables with maximum 2 entries with syntax, query and output i.e. table diagram)

Exp No:6

AIM:Write SQL query using Aggregate Functions for product table

(MIN, MAX, COUNT, SUM, AVG-write theory about aggregate functions with syntax of
each and its use)
(5 to 6 entries in product table with 5 attributes)

Questions to find out queries:


1. Write a query to find the total price of the product
2. Write a query to find the average price of the product
And so on….
Exp No:7

AIM:Write SQL query using Logical Operators for employee table

(AND, OR, NOT, NOR, BETWEEN, IN, LIKE {use all like operation symbols},
EXISTS, ALL, ANY- write theory about Logical operators with syntax of each and its
use)
(5 to 6 entries in employee table with 5 attributes)

Exp No:8

AIM: Write SQL query using Group by Function, Having and Order By Function

(Theory, Syntax and Query)

You might also like