0% found this document useful (0 votes)
75 views20 pages

Branch: C.S.E Subject: Mysql/Dbms Year/Sem: 2 /4: Shri Vaishnav Polytechnic College M.O.G Lines Indore (M.P)

This document contains the details of 10 experiments conducted on MySQL/DBMS as part of a 2nd year 4th semester course. Each experiment covers a different SQL concept like creating databases and tables, inserting data, selecting data, using clauses like order by and group by, performing calculations, pattern matching and various SQL functions. The document also contains exercises on creating different tables for employee, works, company and manager with various operations like insert, select, where etc. It provides the structure of the experiments and code examples for learning SQL commands.

Uploaded by

Ravi Verma
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)
75 views20 pages

Branch: C.S.E Subject: Mysql/Dbms Year/Sem: 2 /4: Shri Vaishnav Polytechnic College M.O.G Lines Indore (M.P)

This document contains the details of 10 experiments conducted on MySQL/DBMS as part of a 2nd year 4th semester course. Each experiment covers a different SQL concept like creating databases and tables, inserting data, selecting data, using clauses like order by and group by, performing calculations, pattern matching and various SQL functions. The document also contains exercises on creating different tables for employee, works, company and manager with various operations like insert, select, where etc. It provides the structure of the experiments and code examples for learning SQL commands.

Uploaded by

Ravi Verma
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/ 20

SHRI VAISHNAV POLYTECHNIC COLLEGE

M.O.G LINES INDORE (M.P)

BRANCH: C.S.E

SUBJECT: MySQL/DBMS

YEAR/SEM: 2nd/4th

Submitted By: Submitted To:


Ravi Verma Mrs.Shraddha Wadnerkar
INDEX
Sr Topic Date Of Date Of Remarks
No. Assignmen Submissio
t n
1 Experiment-1: STUDY OF
SQL, DDL, DML, DCL.

2 Experiment-2: STUDY OF
BASIC SQL STATEMENTS.

3 Experiment-3 STUDY OF SQL


STATEMENTS FOR
CREATING AND SELECTING
A DATABASE.

4 Experiment-4 STUDY OF
SQL STATEMENTS TO
CREATE TABLE.

5 Experiment-5 : Study of SQL


statements for loading data
into a table.

6 Experiment-6 : Study of SQL


statements for retrieving
data from a table.

7 Experiment-7 : Study of
order by and group by
clause.
8 Experiment-8 : Study of
Data Calculation

9 Experiment-9 : Study of
Pattern Matching

10 Experiment-10 : Study of
SQL functions

11 EXCERSICE : 1

12 Part 1 : Create table for


employee with different
operations .

13 (a). Description of
employee.

14 Part 2:Create table works


where use different
operations.

15 Part 3 : Create the table for


company where use
different operations.

16 Part 4:Create the table for


Manager and perform
different operations.
Experiment-5 : Study of SQL
statements for loading data into a
table.
1. INSERT INTO : The INSERT INTO statement is used to insert new records in
a table.
Syntax: INSERT INTO table name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
Example:

2. ALTER : To alter the structure of the existing database.


Syntax : ALTER TABLE <TABLE_NAME> ADD/DROP/MODIFY(
COLUMN_NAME1 DATATYPE1,
COLUMN_NAME2 DATATYPE2 );
Example: FOR ADD:
FOR DROP :

FOR MODIFY:
Experiment-6 : Study of SQL
statements for retrieving data from
a table.
The SQL commands to retrieve data from table are
1. SELECT ALL DATA : This Command is used to retrieve all the data present in
table.
Syntax : SELECT * FROM TABLE_NAME;
Example :

2. SELECT A ROW : This Command is used to retrieve all the data present in table
of
a given row.
Syntax : SELECT * FROM TABLE_NAME WHERE COLUMN_NAME=VALUE;
Example :

3. SELECT A COLUMN : This Command is used to retrieve a column data present


in
table .
Syntax : SELECT COLUMN_NAME FROM TABLE_NAME ;
Example :

Experiment-7 : Study of order by


and group by clause.
The ORDER BY and GROUP BY commands are
1. ORDER BY : The ORDER BY statement in SQL is used to sort the fetched data in
either ascending or descending according to one or more columns. By
default ORDER BY sorts the data in ascending order. We can use the keyword
DESC
to sort the data in descending order and the keyword ASC to sort in
ascending order.
Syntax : SELECT COLUMN_NAME FROM TABLE_NAME ORDER BY
COLUMN_NAME
ASC/DESC;
Example :
2. GROUP BY : The GROUP BY clause is a SQL command that is used to group
rows
that have the same values. The GROUP BY clause is used in the SELECT statement
.Optionally it is used in conjunction with aggregate functions to produce summary
reports from the database.
Syntax : SELECT COLUMN_NAME FROM TABLE_NAME GROUP BY
COLUMN_NAME HAVING condition ;
Example :

Experiment-8 : Study of Data


Calculation
MySQL provides several functions that you can use to perform calculations on
dates, for example, to calculate working years or extract parts of dates .
To determine how many years old each of your pets is, use the TIMESTAMPDIFF()
function. Its arguments are the unit in which you want the result expressed, and
the two date for which to take the difference.
Syntax : SELECT COLUMN_NAME , CURDATE( ) ,
TIMESTAMPDIFF( YEARS ,COLUMN_NAME , CURDATE( ) ) AS
NAME_OF_NEW_COLUMN
FROM TABLE_NAME;
EXAMPLE :
Experiment-9 : Study of Pattern
Matching
MySQL provides standard SQL pattern matching as well as a form of pattern
matching based on extended regular expression similar to those use by linux
utility such as VI,GID,SED. SQL pattern matching enable you to use “_” to match
any single character and “ %” to match any arbitrary.
In that case we don’t use =,=1 when we use SQL patterns , use like or not like.
Syntax : SELECT * FROM TABLE_NAME WHERE COLUMN_NAME LIKE/NOT LIKE
’EXPRESSION’;
Example:
Experiment-10 : Study of SQL
functions
SQL provide many built in functions to perform operations on data these
functions are useful while performing mathematical calculations , string ,
concatenation ,sub -string etc.
SQL functions are divided into 2 categories which are as follow:
 Aggregate Functions
 Scalar Functions

AGGREGATE FUNCTIONS : This function return single value after


performing calculation on a group of values some frequently used aggregate
functions are.
1. AVG( ) - Average returns average value after calculating it from values in a
numeric column .
Syntax : SELECT AVG(COLUMN_NAME) FROM TABLE_NAME;
Example :
2. COUNT( ) – Count returns the number of rows present in the table either
based on
some condition or without condition.
Syntax : SELECT COUNT(COLUMN_NAME) FROM TABLE_NAME;
Example :

3. MAX( ) – Max function return maximum value from selected column of the
table.
Syntax : SELECT MAX(COLUMN_NAME) FROM TABLE_NAME;
Example :

4. MIN( ) – MIN function return minimum value from selected column of the
table.
Syntax : SELECT MIN(COLUMN_NAME) FROM TABLE_NAME;
Example :

5. SUM( ) – Sum function return total sum of a selected column numeric values .
Syntax : SELECT SUM(COLUMN_NAME) FROM TABLE_NAME;
Example :
SCALAR FUNCTIONS : Scalar function returns a single value from an input value
some
frequently used scalar functions are
UCASE( ) : UCASE function is used to convert value of string column to upper case
character.
Syntax : SELECT UCASE(COLUMN_NAME) FROM TABLE_NAME;
Example :

2. LCASE( ) : LCASE function is used to convert value of string column to lower


case
character.
Syntax : SELECT LCASE(COLUMN_NAME) FROM TABLE_NAME;
Example :

3. MID( ) : MID function is used to extract sub string from column values of string
type in a table.
Syntax : SELECT MID(COLUMN_NAME) FROM TABLE_NAME;
Example :
EXCERSICE : 1
Part 1 : Create table for employee with different operations .
(a). Description of employee.

(b). Insert data into employee

(c). Select all data from employee


(d).Select a row where eid=101.

(e).Show the list of Eid and Employee Name.

(f).Write a query to show the name of employee who lives in city Indore.
Part 2:Create table works where use different operations.
(a).Show the Description of table and use insert into.
Description:

Insert Into:

(b).Show all data from works table.

(c). Show the list of employee with there designation.


(d). Show the list of employee with there designation in descending order.

(e). Write SQL query to find average salary of employee.

(f). Write SQL query to find working year of employee in company .

Part 3 : Create the table for company where use different operations.
(a). Show the Description of table and use insert into.
Description :
Insert Into:

(b).Show all data from company table.

(c).Write query to display record of employee who’s city is Indore .


Part 4:Create the table for Manager and perform different operations.
(a). Show the Description of table and use insert into.
Description :

Insert Into:

(b).Show all data from Manager table.

(c).Write the query to show the record of Manager who’s name start with “A”.

(d). Write the query to show the record of Manager who’s name have letter “R”.
(e). Write the query to show the record of Manager with 7 character.

You might also like