DBMS LAB MANUAL(1)
DBMS LAB MANUAL(1)
NO:3
DATE:
AIM:
To create a database using Data Control Commands and Transaction Control Commands to
manage transactions in the database.
DESCRIPTION:
Transaction Control Language (TCL) commands are used to manage transactions in the database.
These are used to manage the changes made by DML-statements. It also allows statements to be
grouped together into logical transactions.
Examples of TCL:
(i) Commit
(ii) Rollback
(iii) Savepoint
Syntax: commit;
(ii) Rollback: Rollback Command restores database to original since the last Commit.
(iii) Savepoint:
SAVEPOINT command is used to temporarily save a transaction so that you can rollback to that
point whenever required.
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.
Data Control Language (DCL) is used to control privileges in Database. To perform any
operation in the database, such as for creating tables, sequences or views, a user needs privileges.
Privileges are of two types,
• System: This includes permissions for creating session, table, etc. and all types of other
system privileges.
• Object: This includes permissions for any command or query to perform any operation on
the database tables.
• GRANT: Used to provide any user access privileges or other privileges for the database.
Thus, the Data Control Language (DCL) and Transaction Control Language (TCL) commands
were executed successfully.
EX. NO: 4
Date:
SQL FUNCTIONS
AIM:
To study the various SQL functions and their operations on the database.
DESCRIPTION:
Functions are methods used to perform data operations. SQL has many in-built functions used to
perform string concatenations, mathematical calculations etc.
1. Aggregate Functions
2. Scalar Functions
The Aggregate Functions in SQL perform calculations on a group of values and then return a
single value. Following is a few of the most commonly used Aggregate Functions:
Function Description
SUM() Used to return the sum of a group of values.
COUNT() Returns the number of rows either based on a condition, or without a condition.
AVG() Used to calculate the average value of a numeric column.
MIN() This function returns the minimum value of a column.
MAX() Returns a maximum value of a column.
FIRST() Used to return the first value of the column.
LAST() This function returns the last value of the column.
The Scalar Functions in SQL are used to return a single value from the given input
value. Following is a few of the most commonly used Aggregate Functions:
Function Description
LCASE() Used to convert string column values to lowercase
UCASE() This function is used to convert a string column values to Uppercase.
LEN() Returns the length of the text values in the column.
MID() Extracts substrings in SQL from column values having String data type.
ROUND() Rounds off a numeric value to the nearest integer.
NOW() This function is used to return the current system date and time.
FORMAT() Used to format how a field must be displayed.
EXAMPLE:
CHARACTER/STRING FUNCTION:
OUTPUT:
NUMERIC FUNCTION
OUTPUT:
MATH FUNCTION:
RESULT: