RDBMS Practicals
RDBMS Practicals
Subject:RDBMS lab L T P
Subject Code: CSG151 0 0 2
Internal Marks: 50
External Marks: 50
Total Marks: 100
Working with Null Values, Matching a Pattern from a Table, Ordering the
3 Result of a Query, Aggregate Functions, Grouping the Result of a Query,
Update and Delete Statements.
Set Operators, Nested Queries, Joins, and Sequences.
4
Objectives of Lab:
Sr.
Expected Learning Apparatus Date of
No Experiment Signature
Outcome Required Experiment
.
Installation of Students will be
Structured Query able to installation
1 Language (SQL) of Structured Query
Server / Oracle. Language (SQL)
Server / Oracle One personal
WAP for Creating Students will be computer
Tables, Retrieval of able to perform (32bit/64 bit,
Rows using Select Creating Tables, 2GB/4GB
Statement, Conditional Retrieval of Rows RAM, 1 GB
Retrieval of Rows, using Select disk space),
2 Alter and Drop Statement, Licensed
Statements. Conditional version of
Retrieval of Rows, window 7,
Alter and Drop Turbo C++
Statements.
.
3 WAP which show Student will be able
Working with Null to perform on
Values, Matching a Ordering the Result
Pattern from a Table, of a Query,
Ordering the Result of Aggregate
a Query, Aggregate Functions, Grouping
Functions, Grouping the Result of a
the Result of a Query, Query, Update and
Update and Delete Delete Statements
Statements.
WAP to show the
working of Set Student will be able
4 Operators, Nested to Joins, and
Queries, Joins, and Sequences
Sequences.
WAP to show the
working of Views, Student will be able
Indexes, Database to PRFORM Grant
Security and and Revoke
5
Privileges: Grant and Commands, Commit
Revoke Commands, and Rollback
Commit and Rollback Commands..
Commands.
WAP to show the
working of PL/SQL
(Procedural Language
extension to Structured
Query Language)
Architecture,
Student will be able
Assignments and
6 to make programs
Expressions, Writing
on Structured Query
PL/SQL ( Procedural
Language
Language extension to
Structured Query
Language) Code,
Referencing Non-
SQL( Structured Query One personal
Language) parameters. computer
WAP to show the (32bit/64 bit,
working of Stored Students will be 2GB/4GB
Procedures and able to create RAM, 1 GB
7 Exception Handling. programs on Stored disk space),
Procedures and Licensed
Exception Handling. version of
window 7,
WAP to show the SQL
working of Triggers Students will be
and Cursor able to perform of
Management in Triggers and Cursor
8
PL/SQL (Procedural Management in
Language extension to PL/SQL (Procedural
Structured Query Language extension
Language).
RDBMS LAB MANNUAL
Introduction:
What is SQL?
Once the software is downloaded, the following files will be available based on your download
(32 or 64 bit) option.
ENU\x86\SQLFULL_x86_ENU_Core.box
ENU\x86\SQLFULL_x86_ENU_Install.exe
ENU\x86\SQLFULL_x86_ENU_Lang.box
OR
ENU\x86\SQLFULL_x64_ENU_Core.box
ENU\x86\SQLFULL_x64_ENU_Install.exe
ENU\x86\SQLFULL_x64_ENU_Lang.box
Step 4 − Once we click on 'setup' application, the following screen will open.
Step 5 − Click Installation which is on the left side of the above screen.
Step 6 − Click the first option of the right side seen on the above screen. The following screen
will open.
Step 7 − Click OK and the following screen pops up.
Step 8 − Click Next to get the following screen.
Step 9 − Make sure to check the product key selection and click Next.
Step 10 − Select the checkbox to accept the license option and click Next.
Step 11 − Select SQL Server feature installation option and click Next.
Step 15 − Select service account names and start-up types for the above listed services and click
Collation.
Step 16 − Make sure the correct collation selection is checked and click Next.
Step 17 − Make sure authentication mode selection and administrators are checked and click
Data Directories.
Step 18 − Make sure to select the above directory locations and click Next. The following
screen appears.
Step 19 − Click Next on the above screen.
Step 20 − Click Next on the above screen to the get the following screen.
Step 21 − Make sure to check the above selection correctly and click Install.
Installation is successful as shown in the above screen. Click Close to finish.
Operator Description
+ Add
- Subtract
* Multiply
/ Divide
% Modulo
Operator Description
| Bitwise OR
^ Bitwise exclusive OR
Operator Description
= Equal to
Operator Description
+= Add equals
-= Subtract equals
*= Multiply equals
/= Divide equals
%= Modulo equals
Operator Description
4. Aim: Write Functions: Numeric, String Handling, Date And Aggregate Functions
In Sql.
Objectives: Student Able To Understand Functions: Numeric, String Handling, Date,
Aggregate In Sql.
Outcome: Student Able To Perform Functions: Numeric, String Handling, Date, Aggregate
In Sql.
Function Description
QUOTENAME Returns a Unicode string with delimiters added to make the string a valid SQ
identifier
REPLACE Replaces all occurrences of a substring within a string, with a new substring
STUFF Deletes a part of a string and then inserts another part into the string, starting
TRANSLATE Returns the string from the first argument after the characters specified in th
translated into the characters specified in the third argument.
TRIM Removes leading and trailing spaces (or other specified characters) from a st
UNICODE Returns the Unicode value for the first character of the input expression
Function Description
POWER Returns the value of a number raised to the power of another number
Function Description
DATEADD Adds a time/date interval to a date and then returns the date
DATEDIFF Returns the difference between two dates
DATEFROMPARTS Returns a date from the specified parts (year, month, and day values)
GETUTCDATE Returns the current database system UTC date and time
MONTH Returns the month part for a specified date (a number from 1 to 12)
Function Description
CURRENT_USER Returns the name of the current user in the SQL Server database
ISNULL Return a specified value if the expression is NULL, otherwise return the exp
SESSION_USER Returns the name of the current user in the SQL Server database
Transaction Control Language(TCL) commands are used to manage transactions in the database.
These are used to manage the changes made to the data in a table by DML statements. It also
allows statements to be grouped together into logical transactions.
COMMIT command
COMMIT command is used to permanently save any transaction into the database.
When we use any DML command like INSERT, UPDATE or DELETE, the changes made by
these commands are not permanent, until the current session is closed, the changes made by
these commands can be rolled back.
To avoid that, we use the COMMIT command to mark the changes as permanent.
Following is commit command's syntax,
COMMIT;
ROLLBACK command
This command restores the database to last commited state. It is also used
with SAVEPOINT command to jump to a savepoint in an ongoing transaction.
If we have used the UPDATE command to make some changes into the database, and realise that
those changes were not required, then we can use the ROLLBACK command to rollback those
changes, if they were not commited using the COMMIT command.
Following is rollback command's syntax,
ROLLBACK TO savepoint_name;
SAVEPOINT command
SAVEPOINT command is used to temporarily save a transaction so that you can rollback to that
point whenever required.
Following is savepoint command's syntax,
SAVEPOINT savepoint_name;
In short, using this command we can name the different states of our data in any table and then
rollback to that state using the ROLLBACK command whenever required.
id name
1 Abhi
2 Adam
4 Alex
Lets use some SQL queries on the above table and see the results.
INSERT INTO class VALUES(5, 'Rahul');
COMMIT;
SAVEPOINT A;
SAVEPOINT B;
INSERT INTO class VALUES(7, 'Bravo');
SAVEPOINT C;
id name
1 Abhi
2 Adam
4 Alex
5 Abhijit
6 Chris
7 Bravo
Now let's use the ROLLBACK command to roll back the state of data to the savepoint B.
ROLLBACK TO B;
id name
1 Abhi
2 Adam
4 Alex
5 Abhijit
6 Chris
Now let's again use the ROLLBACK command to roll back the state of data to the savepoint A
ROLLBACK TO A;
id name
1 Abhi
2 Adam
4 Alex
5 Abhijit
So now you know how the commands COMMIT, ROLLBACK and SAVEPOINT works.