DBMS 1 - 11
DBMS 1 - 11
TRAINING
LAB MANUAL
DATABASE
MANAGEMENT
SYSTEM
TRAINING
1
LIST OF EXPERIMENTS
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
2
Study & Implementation of
7. Sub queries
Views
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.
1. CREATE:
(a)CREATE TABLE: This is used to create a new relation (table)
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.
c) ALTER TABLE..DROP ..... This is used to remove any field of existing relations.
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;
6
LAB PRACTICE ASSIGNMENT:
7
Experiment No:2
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 :
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‘;
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.
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
11