0% found this document useful (0 votes)
56 views16 pages

Himalayan Group of Professional Institutions Kala Amb, Sirmaur, H.P

The document contains details of 10 practical sessions on various Database Management System concepts like creating databases and tables, inserting records, selecting data using queries, updating records, using aggregate functions, and joining tables. Each practical session is summarized with the relevant SQL commands and their usage along with examples.

Uploaded by

SanjeevKumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views16 pages

Himalayan Group of Professional Institutions Kala Amb, Sirmaur, H.P

The document contains details of 10 practical sessions on various Database Management System concepts like creating databases and tables, inserting records, selecting data using queries, updating records, using aggregate functions, and joining tables. Each practical session is summarized with the relevant SQL commands and their usage along with examples.

Uploaded by

SanjeevKumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Himalayan Group of Professional Institutions

Kala Amb, Sirmaur, H.P

PRACTICAL
FILE ON
DATABASE MANAGEMENT
SYSTEM
BTECH CSE 4 TH
2023

SUMITTED TO:-SUBMITTED BY
MS. ANJANA SHARMAKULBHUSHAN
BTECH ROLL NO.
21011303018
S PRACTICAL Name DATE SIGN
NO.
01 Demonstration of create DATABASE
and user SQL commands.
02 Demonstration of create table with not
null, unique, primary key and auto
increment constraints and describe
table SQL commands.
03 Demonstration of insert into SQL
commands.
04 Demonstration of select SQL
commands with different methods.
05 Demonstration of where clause with
select SQL commands.
06 Demonstration of the SQL AND, OR,
and NOT operators.
07 Demonstration of the ALTER,TABLE
ADD column, DROP column SQL
commands.
08
Demonstration of update SQL
commands.
09 Demonstration of AGGREGATE
function such as SUM(), AVG(), MIN(),
MAX(), COUNT().
10 Demonstration of joint clause.
PRACTICAL --1

Demonstration of CREATE DATABASE, SHOW DATABASES and USE DATABASE SQL


commands.
(1) CREATE DATABASE

The CREATE DATABASE statement is used to create a new SQL database.

(2) SHOW DATABASE

The SHOW DATABASES statement is used to show existing SQL databases.

(3) USE DATABASE

The USE DATABASE statement is used to select the existing SQL databases.
PRACTICAL—2

Demonstration of CREATE TALE with NOT NULL, UNIQUE, PRIMARY KEY an


AUTO_INCRMENT constraints and DESCRIBE TABLE SQL commands.

(1) CREATE TABLE


The CREATE TABLE statement is used to create a new table in a database.

(2) DESCRIBE TABLE


The DESCRIBE TABLE statement is used to describe existing table in a database.
PRACTICAL – 3

Demonstration of INSERT INTO SQL command


(1)INSERT INTO
The INSERT INTO statement is used to insert new records in a table.

INSERT INTO Syntax


It is possible to write the INSERT INTO statement in two ways:
1. Specify both the column names and the values to be inserted:
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
2. If you are adding values for all the columns of the table, you do not need to specify the column
names in the SQL query. However, make sure the order of the values is in the same order as the
columns in the table. Here, the INSERT INTO syntax would be as follows:
INSERT INTO table_name
PRACTICAL--4

Demonstration of SELECT SQL command with different methods.


(1) SELECT STATEMET
The SELECT statement is used to select data from a database.
The data returned is stored in a result table, called the result-set.

SELECT Syntax
SELECT column1, column2, ...
FROM table_name;
Here, column1, column2, ... are the field names of the table you want to select data from.

If you want to select all the fields available in the table, use the following
syntax:
SELECT * FROM table_name;
PRACTICAL--5

Demonstration of WHERE CLAUSE with SELECT SQL command.


(1)WHERE CLAUSE
The WHERE clause is used to filter records.
It is used to extract only those records that fulfil a specified condition.
WHERE CLAUSE Syntax
SELECT column1, column2, ...
FROM table_name
WHERE condition;

DEMO 1

DEMO 2
PRACTICAL--6

Demonstration of the SQL AND, OR and NOT Operators.


The SQL AND, OR and NOT Operators
The WHERE clause can be combined with AND, OR, and NOT operators.
The AND and OR operators are used to filter records based on more than one condition:

 The AND operator displays a record if all the conditions separated by AND are TRUE.

 The OR operator displays a record if any of the conditions separated by OR is TRUE.


The NOT operator displays a record if the condition(s) is NOT TRUE.

DEMO TABLE

(1)AND Operator
AND Syntax
SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3 ...;
(1) OR Operator
OR Syntax
SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;

(2) NOT Operator


NOT Syntax
SELECT column1, column2, ...
FROM table_name
WHERE NOT condition
PRACTICAL—7

Demonstration of the ALTER TABLE, ADD Column, DROP Column SQL Commands.

(1) ALTER TABLE


The ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
The ALTER TABLE statement is also used to add and drop various constraints on an existing table.
(2) ALTER TABLE -ADD Column
To add a column in a table, use the following syntax:
ALTER TABLE table_name
ADD column_name datatype;

(3) ALTER TABLE -DROP Column


To delete a column in a table, use the following syntax (notice that some database systems don't
allow deleting a column):
ALTER TABLE table_name
DROP COLUMN column_name;
PRACTICAL—8

Demonstration of UPDATE SQL Command.


(1) UPDATE Statement
The UPDATE statement is used to modify the existing records in a table.
UPDATE Syntax
UPDATE table_name SET column1 = value1, column2 = value2, ...
WHERE condition;

2) Table After Updation.

PRACTICAL--9
Demonstration of AGGREGATE FUNCTION such as SUM(), AVG(), MIN(), MAX(), COUNT().
(1) AGGREGATE FUNCTION An aggregate function in SQL performs a calculation on multiple values
and returns asingle value.
DEMO Record

(2) SUM () FUNCTION The SUM () function returns the total sum of a numeric column .
SUM () Syntax
SELECT SUM(column_name)
FROM table_name
WHERE condition;

(3)AVG () FUNCTION
The AVG () function returns the average value of a numeric column.
AVG () Syntax
SELECT AVG(column_name)
FROM table_name
WHERE condition;
(4) COUNT () FUNCTION
The COUNT () function returns the number of rows that matches a specified criterion.
COUNT () Syntax
SELECT COUNT(column_name)
FROM table_name
WHERE condition;

(4) MIN () FUNCTION


The MIN () function returns the smallest value of the selected column.
MIN ()Syntax
SELECT MIN(column_name)
FROM table_name
WHERE condition;
(5) MAX () FUNCTION
The MAX () function returns the largest value of the selected column.
MAX () Syntax
SELECT MAX(column_name)
FROM table_name
WHERE condition;
PRACTICAL—10
Demonstration of JOIN CLAUSE.
(1) JOIN CLAUSE
JOIN clause is used to combine rows from two or more tables, based on a related column
between them. SYNTAX:
SYNTAX: SELECT * FROM JOIN ON Table1.column = Table2.column WHERE ;
Employee Table:

DEPARTMENT TABLE:

NATURAL JION BY USING WHERE CLAUSE:

You might also like