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

DBMS 1 - 11

The document is a training lab manual for a Database Management System course, detailing experiments related to SQL commands including DDL, DML, and various functions and operators. It outlines practical assignments for creating and manipulating databases, as well as theoretical explanations of SQL's structure and usage. The manual serves as a guide for students to understand and implement database operations effectively.

Uploaded by

Yashraj Shukla
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)
18 views11 pages

DBMS 1 - 11

The document is a training lab manual for a Database Management System course, detailing experiments related to SQL commands including DDL, DML, and various functions and operators. It outlines practical assignments for creating and manipulating databases, as well as theoretical explanations of SQL's structure and usage. The manual serves as a guide for students to understand and implement database operations effectively.

Uploaded by

Yashraj Shukla
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

DBMS

TRAINING
LAB MANUAL

DATABASE
MANAGEMENT
SYSTEM
TRAINING
1
LIST OF EXPERIMENTS

Course Title: Database Management System Laboratory

S.No Name of the Experiment Page No

Implementation of DDL commands of SQL with suitable examples

1.  Create table
 Alter table
 Drop Table
Implementation of DML commands of SQL with suitable examples

2.  Insert
 Update
 Delete
Implementation of different types of function with suitable examples
 Number function
3.  Aggregate Function
 Character Function
 Conversion Function
 Date Function
Implementation of different types of operators in SQL
 Arithmetic Operators
4.  Logical Operators
 Comparison Operator
 Special Operator
 Set Operation
Implementation of different types of Joins

5.  Inner Join
 Outer Join
 Natural Join etc..
Study and Implementation of

6.  Group By & having clause


 Order by clause
 Indexing

2
Study & Implementation of

7.  Sub queries
 Views

8 Study & Implementation of different types of constraints.

Study & Implementation of Database Backup & Recovery commands.


9
Study & Implementation of Rollback, Commit, Savepoint.

 Creating Database /Table Space


10  Managing Users: Create User, Delete User
 Managing roles:-Grant, Revoke.

11 Study & Implementation of PL/SQL.

12 Study & Implementation of SQL Triggers.

3
Experiment No: 1
SQL (Structured Query Language):
Structured Query Language is a database computer language designed for
managing data in relational database management systems (RDBMS), and originally based
upon Relational Algebra. Its scope includes data query and update, schema creation and
modification, and data access control.
SQL was one of the first languages for Edgar F. Codd's relational model and became the
most widely used language for relational databases.
 IBM developed SQL in mid of 1970’s.
 Oracle incorporated in the year 1979.
 SQL used by IBM/DB2 and DS Database Systems.
 SQL adopted as standard language for RDBS by ASNI in 1989.

There are five types of SQL statements. They are:

1. DATA DEFINITION LANGUAGE (DDL)

2. DATA MANIPULATION LANGUAGE (DML)

3. TRANSATIONAL CONTROL LANGUAGE (TCL)

4. DATA CONTROL LANGUAGE (DCL)

1. DATA DEFINITION LANGUAGE (DDL): The Data Definition Language (DDL) is


used to create and destroy databases and database objects. These commands will primarily be
used by database administrators during the setup and removal phases of a database project.
Let's take a look at the structure and usage of four basic DDL commands:
1. CREATE 2. ALTER 3. DROP 4. RENAME

1. CREATE:
(a)CREATE TABLE: This is used to create a new relation (table)

Syntax: CREATE TABLE <relation_name/table_name >


4
(field_1 data_type(size),field_2 data_type(size), .. . );

Example:
SQL> CREATE TABLE Student (sno NUMBER (3), sname CHAR (10), class CHAR (5));

2. ALTER:
(a) ALTER TABLE ...ADD...: This is used to add some extra fields into existing
relation.

Syntax: ALTER TABLE relation_name ADD (new field_1 data_type(size), new field_2
data_type(size),..);
Example: SQL>ALTER TABLE std ADD (Address CHAR(10));

(b) ALTER TABLE...MODIFY...: This is used to change the width as well as data
type of fields of existing relations.

Syntax: ALTER TABLE relation_name MODIFY (field_1 newdata_type(Size), field_2


newdata_type(Size),... field_newdata_type(Size));

Example:SQL>ALTER TABLE student MODIFY(sname VARCHAR(10),class


VARCHAR(5));

c) ALTER TABLE..DROP ..... This is used to remove any field of existing relations.

Syntax: ALTER TABLE relation_name DROP COLUMN (field_name);

Example:SQL>ALTER TABLE student DROP column (sname);

d) ALTER TABLE..RENAME...: This is used to change the name of fields in


existing relations.

Syntax: ALTER TABLE relation_name RENAME COLUMN (OLD field_name) to


(NEW field_name);

Example: SQL>ALTER TABLE student RENAME COLUMN sname to stu_name;

5
3. DROP TABLE: This is used to delete the structure of a relation. It permanently deletes
the records in the table.
Syntax: DROP TABLE relation_name;
Example: SQL>DROP TABLE std;

4. RENAME: It is used to modify the name of the existing database object.


Syntax: RENAME TABLE old_relation_name TO new_relation_name;
Example: SQL>RENAME TABLE std TO std1;

6
LAB PRACTICE ASSIGNMENT:

1. Create a table EMPLOYEE with following schema:

(Emp_no, E_name, E_address, E_ph_no, Dept_no, Dept_name,Job_id , Salary)


2. Add a new column; HIREDATE to the existing relation.
3. Change the datatype of JOB_ID from char to varchar2.
4. Change the name of column/field Emp_no to E_no.
5. Modify the column width of the job field of emp table

7
Experiment No:2

Title : Implementation of DML commands of SQL with suitable examples


 Insert table
 Update table
 Delete Table

Objective :
To understand the different issues involved in the design and implementation of a
database system
To understand and use data manipulation language to query, update, and manage a
database

Theory :

DATA MANIPULATION LANGUAGE (DML): The Data Manipulation Language


(DML) is used to retrieve, insert and modify database information. These commands will be
used by all database users during the routine operation of the database. Let's take a brief look
at the basic DML commands:
1. INSERT 2. UPDATE 3. DELETE
1. INSERT INTO: This is used to add records into a relation. These are three type of
INSERT INTO queries which are as
a) Inserting a single record
Syntax: INSERT INTO < relation/table name> (field_1,field_2……field_n)VALUES
(data_1,data_2, ....... data_n);
Example: SQL>INSERT INTO student(sno,sname,class,address)VALUES
(1,’Ravi’,’M.Tech’,’Palakol’);
b) Inserting a single record
Syntax: INSERT INTO < relation/table name>VALUES (data_1,data_2, ........data_n);
Example: SQL>INSERT INTO student VALUES (1,’Ravi’,’M.Tech’,’Palakol’);

c) Inserting all records from another relation

8
Syntax: INSERT INTO relation_name_1 SELECT Field_1,field_2,field_n
FROM relation_name_2 WHERE field_x=data;
Example: SQL>INSERT INTO std SELECT sno,sname FROM student
WHERE name = ‘Ramu‘;

d) Inserting multiple records


Syntax: INSERT INTO relation_name field_1,field_2, .... field_n) VALUES
(&data_1,&data_2,....... &data_n);
Example: SQL>INSERT INTO student (sno, sname, class,address)
VALUES (&sno,’&sname’,’&class’,’&address’);
Enter value for sno: 101
Enter value for name: Ravi
Enter value for class: M.Tech
Enter value for name: Palakol

2. UPDATE-SET-WHERE: This is used to update the content of a record in a relation.


Syntax: SQL>UPDATE relation name SET Field_name1=data,field_name2=data,
WHERE field_name=data;
Example: SQL>UPDATE student SET sname = ‘kumar’ WHERE sno=1;

3. DELETE-FROM: This is used to delete all the records of a relation but it will retain the
structure of that relation.
a) DELETE-FROM: This is used to delete all the records of relation.
Syntax: SQL>DELETE FROM relation_name;
Example: SQL>DELETE FROM std;
b) DELETE -FROM-WHERE: This is used to delete a selected record from a relation.
Syntax: SQL>DELETE FROM relation_name WHERE condition;
Example: SQL>DELETE FROM student WHERE sno = 2;

5. TRUNCATE: This command will remove the data permanently. But structure will not be
removed.

9
Difference between Truncate & Delete:-
 By using truncate command data will be removed permanently & will not get back
where as by using delete command data will be removed temporally & get back by
using roll back command.
 By using delete command data will be removed based on the condition where as by
using truncate command there is no condition.
 Truncate is a DDL command & delete is a DML command.

Syntax: TRUNCATE TABLE <Table name>


Example TRUNCATE TABLE student;

 To Retrieve data from one or more tables.

1. SELECT FROM: To display all fields for all records.


Syntax : SELECT * FROM relation_name;
Example : SQL> select * from dept;
DEPTNO DNAME LOC
-------- ----------- ----------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON

2. SELECT FROM: To display a set of fields for all records of relation.


Syntax: SELECT a set of fields FROM relation_name;
Example: SQL> select deptno, dname from dept;
DEPTNO DNAME
10 ACCOUNTING
20 RESEARCH
30 SALES
3. SELECT - FROM -WHERE: This query is used to display a selected set of fields for a
selected set of records of a relation.

10
Syntax: SELECT a set of fields FROM relation_name WHERE condition;
Example: SQL> select * FROM dept WHERE deptno<=20;
DEPTNO DNAME LOC
------ ----------- ------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS

LAB PRACTICE ASSIGNMENT:

Create a table EMPLOYEE with following schema:


(Emp_no, E_name, E_address, E_ph_no, Dept_no, Dept_name,Job_id , Salary)

Write SQL queries for following question:


1. Insert aleast 5 rows in the table.
2. Display all the information of EMP table.
3. Display the record of each employee who works in department D10.
4. Update the city of Emp_no-12 with current city as Nagpur.
5. Display the details of Employee who works in department MECH.
6. Delete the email_id of employee James.
7. Display the complete record of employees working in SALES Department.

11

You might also like