SlideShare a Scribd company logo
Database
Management System
Practical File
Submitted To:
Dr. Jyoti
Submitted By:
Rishab
25634
CSE-B
Table of Contents
Title Page No.
Introduction to SQL 2
TO CREATE AND USE DATABASE 5
CREATION OF TABLE WITH AND WITHOUT
CONSTRANTS:
6
ADD RECORDS INTO TABLES: 8
RETRIEVING DATA FROM TABLE 9
DELETING RECORDS 14
DROPPING TABLE 16
UPDATE TABLE 17
ALTER TABLE 18
ORDERING RECORDS 22
AGGREGATE FUNCTIONS 23
GROUPING FUNCTION 25
SET OPERATIONS 27
JOIN OPERATION 30
STRING OPERATION 34
1
Introduction to SQL
Structure Query Language (SQL) is a database query language used for storing and managingdata
in Relational DBMS. SQL was the first commercial language introduced for E.F
Cod’s Relational model of database. Today almost all RDBMS (MySQL, Oracle, Informix, Sybase,
MS Access) use SQL as the standard database query language. SQL is used to performall types of
data operations in RDBMS.
SQL Command
SQL defines following ways to manipulate data stored in an RDBMS.
DDL: Data Definition Language
This includes changes to the structure of the table like creation of table, altering table, deleting a
tableetc.
All DDL commands are auto-committed. That means it saves all the changes permanently in the
database.
Command Description
Create to create new table or database
Alter for alteration
Truncate delete data from table
Drop to drop a table
Rename To rename a table
2
DML: Data Manipulation Language
DML commands are used for manipulating the data stored in the table and not the table itself.
DML commands are not auto-committed. It means changes are not permanent to database, they
canbe rolled back.
Command Description
Insert to insert a new row
Update to update existing row
Delete to delete a row
Merge merging two rows or two tables
TCL: Transaction Control Language
These commands are to keep a check on other commands and their affect on the database.
These commands can annul changes made by other commands by rolling the data back to its
original state.It can also make any temporary change permanent.
3
Command Description
Commit to permanently save
Rollback to undo change
save point to save temporarily
DCL: Data Control Language
Data control language are the commands to grant and take back authority from any database user.
Command Description
Grant grant permission of right
Revoke take back permission.
DQL: Data Query Language
Data query language is used to fetch data from tables based on conditions that we can easily apply.
Command Description
Select retrieve records from one or more table
4
TO CREATE AND USE DATABASE
(A). CREATE DATABASE :
The CREATE DATABASE statement is used to create a new SQL database.
SYNTAX:
CREATE DATABASE database_name;
EXAMPLE:
(B). SHOW DATABASES:
To list all databases on a MySQL server host.
SYNTAX:
SHOW DATABASES;
EXAMPLE:
(C). USE DATABSE:
Use SQL command USE to select a particular database.
SYNTAX:
USE database_name;
EXAMPLE:
5
CREATION OF TABLE WITH AND WITHOUT CONSTRANTS:
(A).CREATE TABLES WITH CONSTRAINTS:
Constraints can be specified when the table is created with the CREATE TABLE statement, orafter
the table is created with the ALTER TABLE statement. The following constraints are commonly
used in SQL:
• NOT NULL - Ensures that a column cannot have a NULL value
• UNIQUE - Ensures that all values in a column are different
• PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely identifieseach row
in a table
• FOREIGN KEY - Uniquely identifies a row/record in another table
• CHECK - Ensures that all values in a column satisfies a specific condition
• DEFAULT - Sets a default value for a column when no value is specified
• INDEX - Used to create and retrieve data from the database very quickly
SYNTAX:
CREATE TABLE table_name (
column1 datatype constraint,
column2 datatype constraint,
column3 datatype constraint,
....
);
EXAMPLE:
(B). CREATE TABLES WITHOUT CONSTRAINTS:
To create a new table within a database
SYNTAX:
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,...);
6
EXAMPLE:
(C). SHOW TABLES:
To list tables in a MySQL database
SYNTAX:
SHOW TABLES;
EXAMPLE:
7
ADD RECORDS INTO TABLES:
(A). SIMPLE INSERTION:
The INSERT Statement is used to add new rows of data to a table.
SYNTAX:
INSERT INTO table_name
VALUES (value1, value2, value3, ...);
EXAMPLE:
(B). INSERTING VALUES INTO SPECIFIC COLUMS:
It is also possible to only insert data in specific columns.
SYNTAX:
INSERT INTO table_name(column_name1, column_name2,…)
VALUES (value1, value2,...);
EXAMPLE:
8
RETRIEVING DATA FROM TABLE
(A). RETRIEVING ALL RECORDS:
The SELECT statement is used to select data from a database.
SYNTAX:
SELECT *FROM table_name;
EXAMPLE:
(B). RETRIEVING SPECIFIC COLUMNS:
The most common query from a database is to collect or retrieve all the elements in a specific column of thedatabase table.
SYNTAX:
SELECT column_name FROM table_name;
EXAMPLE:
( C ). PRINTING WITH USER DEFINED VARIABLE TO STORE THE VALUE
Use a user-defined variable to store the value in table.
SYNTAX:
SELECT column_name AS userdefined_name, attribute AS userdefined_name FROM
table_name
9
EXAMPLE:
(D). USING LOGICAL OPERATORS (AND, OR, NOT):
AND OPERATOR:
The AND operator displays a record if all the conditions separated by AND are TRUE.
SYNTAX:
SELECT * FROM table_name WHERE condition1 AND condition2 AND condition3 ...;
EXAMPLE:
OR OPERATOR:
The OR operator displays a record if any of the conditions separated by OR is TRUE.
SYNTAX:
SELECT * FROM table_name WHERE condition1 OR condition2 OR condition3 ...;
EXAMPLE:
10
NOT OPERATOR:
The NOT operator displays a record if the condition(s) is NOT TRUE.
SYNTAX:
SELECT * FROM table_name WHERE NOT condition;
EXAMPLE:
( E ). USING BETWEEN:
The BETWEEN operator selects values within a given range. The values can be numbers, text, ordates.
The BETWEEN operator is inclusive: begin and end values are included.
SYNTAX:
SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2;
EXAMPLE:
(F). USING IN :
The IN operator allows you to specify multiple values in a WHERE clause. The IN operator is a
shorthand for multiple OR conditions.
SYNTAX:
SELECT column_name
FROM table_name
WHERE column_name IN (value1, value2, ...);
11
EXAMPLE:
(G). USING LIKE:
The LIKE operator is used in a WHERE clause to search for a specified pattern in a column. There
are two wildcards often used in conjunction with the LIKE operator:
• %
• _
(i). %
The percent sign represents zero, one, or multiple characters.
SYNTAX:
SELECT * FROM table_name WHERE column_name LIKE 'a%';
EXAMPLE:
(ii). _
The underscore represents a single character
SYNTAX:
SELECT * FROM table_name WHERE column_name LIKE '_r%';
EXAMPLE:
12
(H). USING IS NULL:
A field with a NULL value is a field with no value. If a field in a table is optional, it is possible to
insert a new record or update a record without adding a value to this field. Then, the field willbe
saved with a NULL value.
SYNTAX:
SELECT * FROM table_name WHERE column_name IS NULL;
EXAMPLE:
( I ). LIMIT NUMBER OF RECORD:
Limited number of records.
SYNTAX:
Select * from table_name limit limit_no;
EXAMPLE:
13
DELETING RECORDS
(A). DELETE SINGLE RECORD:
The DELETE statement is used to delete existing records in a table.
SYNTAX:
DELETE FROM table_name WHERE condition;
EXAMPLE:
(B). DELETE MULTIPLE RECORDS:
The DELETE statement is used to delete all existing records in a table.
SYNTAX:
DELETE FROM table_name WHERE id IN(1,2,3…,10);
EXAMPLE:
14
( C ). DELETE ALL RECORDS:
The DELETE statement is used to delete all existing records in a table.
SYNTAX:
DELETE FROM table_name
EXAMPLE:
15
DROPPING TABLE
The DROP DATABASE statement is used to drop an existing SQL database
SYNTAX:
DROP TABLE table_name
EXAMPLE:
.
16
UPDATE TABLE
(A). UPDATE WITHO
; UT WHERE CLAUSE:
The WHERE clause is used to filter records. The WHERE clause is used to extract only thoserecords
that fulfill a specified condition
SYNTAX:
UPDATE table_name SET column_name;
EXAMPLE:
(B) UPDATE WITH WHERE CLAUSE:
The WHERE clause is used to filter records. The WHERE clause is used to extract only those
records that fulfill a specified condition.
SYNTAX:
UPDATE table_name SET column_name WHERE condition;
EXAMPLE:
17
18
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.
.
(A). ADDING COLUMN:
To add a column in a table
SYNTAX:
ALTER TABLE table_name ADD COLUMN column_name DATATYPE(SIZE)
EXAMPLE:
(B). ADDING MULTIPLE COLUMNS:
Use the ALTER TABLE command to add columns to a table after it's created. The commandalso
allows you to add multiple columns in the one statement.
SYNTAX:
ALTER TABLE table_name ADD column (Column_name1 DATATYPE, Column_name2
DATATYPE);
EXAMPLE:
19
(C) CHANGING COLUMN WIDTH:
To change the data type of a column in a table
SYNTAX:
ALTER TABLE table_name MODIFY column_name DATATYPE;
EXAMPLE:
(D). DROPPING COLUMN:
To delete a column in a table
SYNTAX:
ALTER TABLE table_name DROP COLUMN column_name;
EXAMPLE:
(E) ADDING COLUMN AT PARTICULAR POSITION:
To add a column at a specific position within a table
SYNTAX:
ALTER TABLE table_name ADD COLUMN column_name DATATYPE AFTER
column_name;
EXAMPLE:
(F). CHANGING COLUMN NAME :
Change the name of column
SYNTAX: ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name;
EXAMPLE:
20
(G). RENAME THE TABLE NAME:
To rename a table name to SQL.
SYNTAX:
RENAME TABLE old_table TO new_table;
EXAMPLE:
21
ORDERING RECORDS
(A) ASCEDING
The order by statement in sql is used to sort the fetched data in ascending order.
SYNTAX:
SELECT * FROM table_name ORDER BY column_name ASC;
EXAMPLE:
(B) DESCENDING:
The order by statement in sql is used to sort the fetched data in descending order.
SYNTAX:
SELECT * FROM table_name ORDER BY column_name DESC;
EXAMPLE:
22
AGGREGATE FUNCTIONS
(A). AVERAGE:
The MySQL avg() function is used to return the average value of an expression.
SYNTAX:
SELECT AVG(column_name) as average_column_name FROM table_name;
EXAMPLE:
(B). MAXIMUM
The MySQL max() function is used to return the maximum value of an expression. It is used
when you need to get the maximum value from your table.
SYNTAX:
SELECT MAX(column_name) as maximum_column_name FROM table_name;
EXAMPLES:
(C). MINIMUM
The MySQL min() function is used to return the minimum value from the table.
SYNTAX:
SELECT MIN(column_name) as minimum_column_name FROM table_name;
23
EXAMPLES:
(D). COUNT
The MySQL count() function is used to return the count of an expression. It is used when youneed
to count some records of your table.
SYNTAX:
SELECT COUNT (column_name) FROM table_name ;
EXAMPLES:
(E). SUM
The MySQL sum() function is used to return the total summed value of an expression.
SYNTAX:
SELECT SUM(column_name) FROM table_name;
EXAMPLES:
24
GROUPING FUNCTION
(A). GROUPING BY CLAUSE
The GROUP BY statement is often used with aggregate functions (COUNT, MAX, MIN, SUM,AVG)
to group the result-set by one or more columns.
SYNTAX:
SELECT column_name FROM table_name WHERE condition GROUP BY column_name;
EXAMPLE:
(B). HAVING CLAUSE
The HAVING clause was added to SQL because the WHERE keyword could not be used with
aggregate functions.
SYNTAX:
SELECT column_name FROM table_name GROUP BY column_name HAVING condition;
EXAMPLE:
25
(C). ALL CLAUSE
ALL operator is used to select all tuples of SELECT STATEMENT. It is also used to compare avalue
to every value in another value set or result from a subquery.
SYNTAX:
SELECT ALL column_name FROM table_name WHERE condition;
EXAMPLES:
26
SET OPERATIONS
(A). UNION
SYNTAX:
SELECT column_name FROM table_1 UNION SELECT column_name FROM table_2;
EXAMPLES:
27
(B). UNION ALL
SYNTAX:
SELECT column_name FROM table_1 UNION ALL SELECT column_name FROM table_2;
EXAMPLES:
28
(C). INTERSECT
the INTERSECT operator is not available in MySQL. Still, we can simulate this using the INNER JOIN and
IN Clause and EXISTS Clause depending on the complexity and requirements of the query.
SYNTAX:
SELECT DISTINCT column_list FROM table_name1
WHERE column_name IN (SELECT column_list FROM table_name2);
EXAMPLES:
(D) EXCEPT
SYNTAX:
SELECT column_name FROM table_1 EXCEPT SELECT column_name FROM table_2;
EXAMPLES:
29
JOIN OPERATION
(A). NATURAL JOIN
The NATURAL JOIN is such a join that performs the same task as an INNER or LEFT JOIN, inwhich
the ON or USING clause refers to all columns that the tables to be joined have in common.
SYNTAX:
SELECT * FROM table_1 NATURAL JOIN table_2;
EXAMPLES:
(B). LEFT OUTER JOIN
A LEFT OUTER JOIN is one of the JOIN operations that allow you to specify a join clause. It
preserves the unmatched rows from the first (left) table, joining them with a NULL row in the
shape of the second (right) table.
30
SYNTAX:
SELECT table_1.column1, table_2.column2… FROM table_1 LEFT OUTER JOIN table_2 ON
table_1.common_field = table_2.common_field;
EXAMPLES:
31
(C). RIGHT OUTER JOIN
A RIGHT OUTER JOIN is one of the JOIN operations that allow you to specify a JOIN clause.It
preserves the unmatched rows from the second (right) table, joining them with a NULL in the
shape of the first (left) table.
SYNTAX:
SELECT table_1.column1, table_2.column2… FROM table_1 RIGHT OUTER JOIN table_2
ON table_1.common_field = table_2.common_field;
EXAMPLES:
(D). INNER JOIN
The INNER JOIN selects all rows from both participating tables as long as there is a match
between the columns. An SQL INNER JOIN is same as JOIN clause, combining rows from twoor
more tables.
SYNTAX:
SELECT table_1.column1, table_2.column2… FROM table_1 INNER JOIN table_2 ON
table_1.common_field = table_2.common_field;
EXAMPLES:
(E). THETA JOIN
A theta join allows for arbitrary comparison relationships (such as ≥). An equijoin is a theta
join using the equality operator. A natural join is an equijoin on attributes that have the same
name in each relationship.
32
EXAMPLES:
(F). CROSS JOIN
The SQL CROSS JOIN produces a result set which is the number of rows in the first table
multiplied by the number of rows in the second table if no WHERE clause is used along with
CROSS JOIN. This kind of result is called as Cartesian Product.
SYNTAX:
SELECT * FROM table_1 CROSS JOIN table_2;
EXAMPLES:
33
STRING OPERATION
(A) SUBSTRING
Return the substring as specified
SYNTAX:
SELECT SUBSTRING(string, start, length)
EXAMPLES:
(B). SUBSTRING_INDEX
The SUBSTRING_INDEX() function returns a substring of a string before a specified number ofdelimiter
occurs.
SYNTAX:
SELECT SUBSTRING_INDEX(string, delimiter, number)
EXAMPLES:
(C). UPPER
The UPPER() function converts a string to upper-case.
SYNTAX:
SELECT UPPER(text)
EXAMPLES:
(D). LOWER
The LOWER() function converts a string to lower-case.
SYNTAX:
SELECT LOWER(text)
34
EXAMPLES:
(F). LTRIM
The LTRIM() function removes leading spaces from a string.
SYNTAX:
SELECT LTRIM(string)
EXAMPLES:
(G). RTRIM
The RTRIM() function removes trailing spaces from a string.
SYNTAX:
SELECT RTRIM(string)
EXAMPLES:
(H). LEFT
The LEFT() function extracts a number of characters from a string (starting from left).
SYNTAX:
SELECT LEFT(string, number_of_chars);
EXAMPLES:
35
(I). RIGHT
The RIGHT() function repeats a string as many times as specified.
SYNTAX:
SELECT RIGHT(string, number);
EXAMPLES:
(J). REVERSE
The REVERSE() function reverses a string and returns the result.
SYNTAX:
SELECT REVERSE(string)
EXAMPLES:
(K). LPAD
The LPAD() function left-pads a string with another string, to a certain length.
SYNTAX:
SELECT LPAD(string, length, lpad_string);
EXAMPLES:
36
(L). RPAD
The RPAD() function right-pads a string with another string, to a certain length.
SYNTAX:
SELECT RPAD(string, length, rpad_string);
EXAMPLES:
37
Ad

More Related Content

Similar to DBMS.pdf (20)

Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
SANTOSH RATH
 
SQL
SQLSQL
SQL
Shyam Khant
 
Les10 Creating And Managing Tables
Les10 Creating And Managing TablesLes10 Creating And Managing Tables
Les10 Creating And Managing Tables
NETsolutions Asia: NSA – Thailand, Sripatum University: SPU
 
Lab
LabLab
Lab
neelam_rawat
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
HudaRaghibKadhim
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
Belle Wx
 
Sql commands
Sql commandsSql commands
Sql commands
Pooja Dixit
 
Database Overview
Database OverviewDatabase Overview
Database Overview
Livares Technologies Pvt Ltd
 
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12  CBSESQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12  CBSE
SQL DATABASE MANAGAEMENT SYSTEM FOR CLASS 12 CBSE
sdnsdf
 
CS3481_Database Management Laboratory .pdf
CS3481_Database Management Laboratory .pdfCS3481_Database Management Laboratory .pdf
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
Oraclesql
OraclesqlOraclesql
Oraclesql
Priya Goyal
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
EliasPetros
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
Eddyzulham Mahluzydde
 
Database Languages power point presentation
Database Languages power point presentationDatabase Languages power point presentation
Database Languages power point presentation
AshokRachapalli1
 
SQL.ppt
SQL.pptSQL.ppt
SQL.ppt
Ranjit273515
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
EliasPetros
 
Sql Queries
Sql QueriesSql Queries
Sql Queries
webicon
 
Lab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer labLab_04.ppt opreating system of computer lab
Lab_04.ppt opreating system of computer lab
MUHAMMADANSAR76
 
SQL DDL
SQL DDLSQL DDL
SQL DDL
Vikas Gupta
 
Les10
Les10Les10
Les10
arnold 7490
 

More from Rishab Saini (9)

PythonPF.pdf
PythonPF.pdfPythonPF.pdf
PythonPF.pdf
Rishab Saini
 
DSA.pdf
DSA.pdfDSA.pdf
DSA.pdf
Rishab Saini
 
Resonance.pptx
Resonance.pptxResonance.pptx
Resonance.pptx
Rishab Saini
 
SQL 3.pptx
SQL 3.pptxSQL 3.pptx
SQL 3.pptx
Rishab Saini
 
PowerFactorImprovement.pptx
PowerFactorImprovement.pptxPowerFactorImprovement.pptx
PowerFactorImprovement.pptx
Rishab Saini
 
Indian Premier League
Indian Premier LeagueIndian Premier League
Indian Premier League
Rishab Saini
 
Poverty
PovertyPoverty
Poverty
Rishab Saini
 
Poetry
PoetryPoetry
Poetry
Rishab Saini
 
Impact of Social media
Impact of Social mediaImpact of Social media
Impact of Social media
Rishab Saini
 
Ad

Recently uploaded (20)

TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
TestMigrationsInPy: A Dataset of Test Migrations from Unittest to Pytest (MSR...
Andre Hora
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
Interactive odoo dashboards for sales, CRM , Inventory, Invoice, Purchase, Pr...
AxisTechnolabs
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
F-Secure Freedome VPN 2025 Crack Plus Activation  New VersionF-Secure Freedome VPN 2025 Crack Plus Activation  New Version
F-Secure Freedome VPN 2025 Crack Plus Activation New Version
saimabibi60507
 
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...Exploring Code Comprehension  in Scientific Programming:  Preliminary Insight...
Exploring Code Comprehension in Scientific Programming: Preliminary Insight...
University of Hawai‘i at Mānoa
 
Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]Get & Download Wondershare Filmora Crack Latest [2025]
Get & Download Wondershare Filmora Crack Latest [2025]
saniaaftab72555
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
Douwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License codeDouwan Crack 2025 new verson+ License code
Douwan Crack 2025 new verson+ License code
aneelaramzan63
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
How can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptxHow can one start with crypto wallet development.pptx
How can one start with crypto wallet development.pptx
laravinson24
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Automation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath CertificateAutomation Techniques in RPA - UiPath Certificate
Automation Techniques in RPA - UiPath Certificate
VICTOR MAESTRE RAMIREZ
 
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage DashboardsAdobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
Adobe Marketo Engage Champion Deep Dive - SFDC CRM Synch V2 & Usage Dashboards
BradBedford3
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Ad

DBMS.pdf

  • 1. Database Management System Practical File Submitted To: Dr. Jyoti Submitted By: Rishab 25634 CSE-B
  • 2. Table of Contents Title Page No. Introduction to SQL 2 TO CREATE AND USE DATABASE 5 CREATION OF TABLE WITH AND WITHOUT CONSTRANTS: 6 ADD RECORDS INTO TABLES: 8 RETRIEVING DATA FROM TABLE 9 DELETING RECORDS 14 DROPPING TABLE 16 UPDATE TABLE 17 ALTER TABLE 18 ORDERING RECORDS 22 AGGREGATE FUNCTIONS 23 GROUPING FUNCTION 25 SET OPERATIONS 27 JOIN OPERATION 30 STRING OPERATION 34 1
  • 3. Introduction to SQL Structure Query Language (SQL) is a database query language used for storing and managingdata in Relational DBMS. SQL was the first commercial language introduced for E.F Cod’s Relational model of database. Today almost all RDBMS (MySQL, Oracle, Informix, Sybase, MS Access) use SQL as the standard database query language. SQL is used to performall types of data operations in RDBMS. SQL Command SQL defines following ways to manipulate data stored in an RDBMS. DDL: Data Definition Language This includes changes to the structure of the table like creation of table, altering table, deleting a tableetc. All DDL commands are auto-committed. That means it saves all the changes permanently in the database. Command Description Create to create new table or database Alter for alteration Truncate delete data from table Drop to drop a table Rename To rename a table 2
  • 4. DML: Data Manipulation Language DML commands are used for manipulating the data stored in the table and not the table itself. DML commands are not auto-committed. It means changes are not permanent to database, they canbe rolled back. Command Description Insert to insert a new row Update to update existing row Delete to delete a row Merge merging two rows or two tables TCL: Transaction Control Language These commands are to keep a check on other commands and their affect on the database. These commands can annul changes made by other commands by rolling the data back to its original state.It can also make any temporary change permanent. 3
  • 5. Command Description Commit to permanently save Rollback to undo change save point to save temporarily DCL: Data Control Language Data control language are the commands to grant and take back authority from any database user. Command Description Grant grant permission of right Revoke take back permission. DQL: Data Query Language Data query language is used to fetch data from tables based on conditions that we can easily apply. Command Description Select retrieve records from one or more table 4
  • 6. TO CREATE AND USE DATABASE (A). CREATE DATABASE : The CREATE DATABASE statement is used to create a new SQL database. SYNTAX: CREATE DATABASE database_name; EXAMPLE: (B). SHOW DATABASES: To list all databases on a MySQL server host. SYNTAX: SHOW DATABASES; EXAMPLE: (C). USE DATABSE: Use SQL command USE to select a particular database. SYNTAX: USE database_name; EXAMPLE: 5
  • 7. CREATION OF TABLE WITH AND WITHOUT CONSTRANTS: (A).CREATE TABLES WITH CONSTRAINTS: Constraints can be specified when the table is created with the CREATE TABLE statement, orafter the table is created with the ALTER TABLE statement. The following constraints are commonly used in SQL: • NOT NULL - Ensures that a column cannot have a NULL value • UNIQUE - Ensures that all values in a column are different • PRIMARY KEY - A combination of a NOT NULL and UNIQUE. Uniquely identifieseach row in a table • FOREIGN KEY - Uniquely identifies a row/record in another table • CHECK - Ensures that all values in a column satisfies a specific condition • DEFAULT - Sets a default value for a column when no value is specified • INDEX - Used to create and retrieve data from the database very quickly SYNTAX: CREATE TABLE table_name ( column1 datatype constraint, column2 datatype constraint, column3 datatype constraint, .... ); EXAMPLE: (B). CREATE TABLES WITHOUT CONSTRAINTS: To create a new table within a database SYNTAX: CREATE TABLE table_name ( column1 datatype, column2 datatype, column3 datatype,...); 6
  • 8. EXAMPLE: (C). SHOW TABLES: To list tables in a MySQL database SYNTAX: SHOW TABLES; EXAMPLE: 7
  • 9. ADD RECORDS INTO TABLES: (A). SIMPLE INSERTION: The INSERT Statement is used to add new rows of data to a table. SYNTAX: INSERT INTO table_name VALUES (value1, value2, value3, ...); EXAMPLE: (B). INSERTING VALUES INTO SPECIFIC COLUMS: It is also possible to only insert data in specific columns. SYNTAX: INSERT INTO table_name(column_name1, column_name2,…) VALUES (value1, value2,...); EXAMPLE: 8
  • 10. RETRIEVING DATA FROM TABLE (A). RETRIEVING ALL RECORDS: The SELECT statement is used to select data from a database. SYNTAX: SELECT *FROM table_name; EXAMPLE: (B). RETRIEVING SPECIFIC COLUMNS: The most common query from a database is to collect or retrieve all the elements in a specific column of thedatabase table. SYNTAX: SELECT column_name FROM table_name; EXAMPLE: ( C ). PRINTING WITH USER DEFINED VARIABLE TO STORE THE VALUE Use a user-defined variable to store the value in table. SYNTAX: SELECT column_name AS userdefined_name, attribute AS userdefined_name FROM table_name 9
  • 11. EXAMPLE: (D). USING LOGICAL OPERATORS (AND, OR, NOT): AND OPERATOR: The AND operator displays a record if all the conditions separated by AND are TRUE. SYNTAX: SELECT * FROM table_name WHERE condition1 AND condition2 AND condition3 ...; EXAMPLE: OR OPERATOR: The OR operator displays a record if any of the conditions separated by OR is TRUE. SYNTAX: SELECT * FROM table_name WHERE condition1 OR condition2 OR condition3 ...; EXAMPLE: 10
  • 12. NOT OPERATOR: The NOT operator displays a record if the condition(s) is NOT TRUE. SYNTAX: SELECT * FROM table_name WHERE NOT condition; EXAMPLE: ( E ). USING BETWEEN: The BETWEEN operator selects values within a given range. The values can be numbers, text, ordates. The BETWEEN operator is inclusive: begin and end values are included. SYNTAX: SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2; EXAMPLE: (F). USING IN : The IN operator allows you to specify multiple values in a WHERE clause. The IN operator is a shorthand for multiple OR conditions. SYNTAX: SELECT column_name FROM table_name WHERE column_name IN (value1, value2, ...); 11
  • 13. EXAMPLE: (G). USING LIKE: The LIKE operator is used in a WHERE clause to search for a specified pattern in a column. There are two wildcards often used in conjunction with the LIKE operator: • % • _ (i). % The percent sign represents zero, one, or multiple characters. SYNTAX: SELECT * FROM table_name WHERE column_name LIKE 'a%'; EXAMPLE: (ii). _ The underscore represents a single character SYNTAX: SELECT * FROM table_name WHERE column_name LIKE '_r%'; EXAMPLE: 12
  • 14. (H). USING IS NULL: A field with a NULL value is a field with no value. If a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this field. Then, the field willbe saved with a NULL value. SYNTAX: SELECT * FROM table_name WHERE column_name IS NULL; EXAMPLE: ( I ). LIMIT NUMBER OF RECORD: Limited number of records. SYNTAX: Select * from table_name limit limit_no; EXAMPLE: 13
  • 15. DELETING RECORDS (A). DELETE SINGLE RECORD: The DELETE statement is used to delete existing records in a table. SYNTAX: DELETE FROM table_name WHERE condition; EXAMPLE: (B). DELETE MULTIPLE RECORDS: The DELETE statement is used to delete all existing records in a table. SYNTAX: DELETE FROM table_name WHERE id IN(1,2,3…,10); EXAMPLE: 14
  • 16. ( C ). DELETE ALL RECORDS: The DELETE statement is used to delete all existing records in a table. SYNTAX: DELETE FROM table_name EXAMPLE: 15
  • 17. DROPPING TABLE The DROP DATABASE statement is used to drop an existing SQL database SYNTAX: DROP TABLE table_name EXAMPLE: . 16
  • 18. UPDATE TABLE (A). UPDATE WITHO ; UT WHERE CLAUSE: The WHERE clause is used to filter records. The WHERE clause is used to extract only thoserecords that fulfill a specified condition SYNTAX: UPDATE table_name SET column_name; EXAMPLE: (B) UPDATE WITH WHERE CLAUSE: The WHERE clause is used to filter records. The WHERE clause is used to extract only those records that fulfill a specified condition. SYNTAX: UPDATE table_name SET column_name WHERE condition; EXAMPLE: 17
  • 19. 18 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. . (A). ADDING COLUMN: To add a column in a table SYNTAX: ALTER TABLE table_name ADD COLUMN column_name DATATYPE(SIZE) EXAMPLE: (B). ADDING MULTIPLE COLUMNS: Use the ALTER TABLE command to add columns to a table after it's created. The commandalso allows you to add multiple columns in the one statement. SYNTAX: ALTER TABLE table_name ADD column (Column_name1 DATATYPE, Column_name2 DATATYPE); EXAMPLE:
  • 20. 19 (C) CHANGING COLUMN WIDTH: To change the data type of a column in a table SYNTAX: ALTER TABLE table_name MODIFY column_name DATATYPE; EXAMPLE: (D). DROPPING COLUMN: To delete a column in a table SYNTAX: ALTER TABLE table_name DROP COLUMN column_name; EXAMPLE:
  • 21. (E) ADDING COLUMN AT PARTICULAR POSITION: To add a column at a specific position within a table SYNTAX: ALTER TABLE table_name ADD COLUMN column_name DATATYPE AFTER column_name; EXAMPLE: (F). CHANGING COLUMN NAME : Change the name of column SYNTAX: ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name; EXAMPLE: 20
  • 22. (G). RENAME THE TABLE NAME: To rename a table name to SQL. SYNTAX: RENAME TABLE old_table TO new_table; EXAMPLE: 21
  • 23. ORDERING RECORDS (A) ASCEDING The order by statement in sql is used to sort the fetched data in ascending order. SYNTAX: SELECT * FROM table_name ORDER BY column_name ASC; EXAMPLE: (B) DESCENDING: The order by statement in sql is used to sort the fetched data in descending order. SYNTAX: SELECT * FROM table_name ORDER BY column_name DESC; EXAMPLE: 22
  • 24. AGGREGATE FUNCTIONS (A). AVERAGE: The MySQL avg() function is used to return the average value of an expression. SYNTAX: SELECT AVG(column_name) as average_column_name FROM table_name; EXAMPLE: (B). MAXIMUM The MySQL max() function is used to return the maximum value of an expression. It is used when you need to get the maximum value from your table. SYNTAX: SELECT MAX(column_name) as maximum_column_name FROM table_name; EXAMPLES: (C). MINIMUM The MySQL min() function is used to return the minimum value from the table. SYNTAX: SELECT MIN(column_name) as minimum_column_name FROM table_name; 23
  • 25. EXAMPLES: (D). COUNT The MySQL count() function is used to return the count of an expression. It is used when youneed to count some records of your table. SYNTAX: SELECT COUNT (column_name) FROM table_name ; EXAMPLES: (E). SUM The MySQL sum() function is used to return the total summed value of an expression. SYNTAX: SELECT SUM(column_name) FROM table_name; EXAMPLES: 24
  • 26. GROUPING FUNCTION (A). GROUPING BY CLAUSE The GROUP BY statement is often used with aggregate functions (COUNT, MAX, MIN, SUM,AVG) to group the result-set by one or more columns. SYNTAX: SELECT column_name FROM table_name WHERE condition GROUP BY column_name; EXAMPLE: (B). HAVING CLAUSE The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions. SYNTAX: SELECT column_name FROM table_name GROUP BY column_name HAVING condition; EXAMPLE: 25
  • 27. (C). ALL CLAUSE ALL operator is used to select all tuples of SELECT STATEMENT. It is also used to compare avalue to every value in another value set or result from a subquery. SYNTAX: SELECT ALL column_name FROM table_name WHERE condition; EXAMPLES: 26
  • 28. SET OPERATIONS (A). UNION SYNTAX: SELECT column_name FROM table_1 UNION SELECT column_name FROM table_2; EXAMPLES: 27
  • 29. (B). UNION ALL SYNTAX: SELECT column_name FROM table_1 UNION ALL SELECT column_name FROM table_2; EXAMPLES: 28
  • 30. (C). INTERSECT the INTERSECT operator is not available in MySQL. Still, we can simulate this using the INNER JOIN and IN Clause and EXISTS Clause depending on the complexity and requirements of the query. SYNTAX: SELECT DISTINCT column_list FROM table_name1 WHERE column_name IN (SELECT column_list FROM table_name2); EXAMPLES: (D) EXCEPT SYNTAX: SELECT column_name FROM table_1 EXCEPT SELECT column_name FROM table_2; EXAMPLES: 29
  • 31. JOIN OPERATION (A). NATURAL JOIN The NATURAL JOIN is such a join that performs the same task as an INNER or LEFT JOIN, inwhich the ON or USING clause refers to all columns that the tables to be joined have in common. SYNTAX: SELECT * FROM table_1 NATURAL JOIN table_2; EXAMPLES: (B). LEFT OUTER JOIN A LEFT OUTER JOIN is one of the JOIN operations that allow you to specify a join clause. It preserves the unmatched rows from the first (left) table, joining them with a NULL row in the shape of the second (right) table. 30
  • 32. SYNTAX: SELECT table_1.column1, table_2.column2… FROM table_1 LEFT OUTER JOIN table_2 ON table_1.common_field = table_2.common_field; EXAMPLES: 31
  • 33. (C). RIGHT OUTER JOIN A RIGHT OUTER JOIN is one of the JOIN operations that allow you to specify a JOIN clause.It preserves the unmatched rows from the second (right) table, joining them with a NULL in the shape of the first (left) table. SYNTAX: SELECT table_1.column1, table_2.column2… FROM table_1 RIGHT OUTER JOIN table_2 ON table_1.common_field = table_2.common_field; EXAMPLES: (D). INNER JOIN The INNER JOIN selects all rows from both participating tables as long as there is a match between the columns. An SQL INNER JOIN is same as JOIN clause, combining rows from twoor more tables. SYNTAX: SELECT table_1.column1, table_2.column2… FROM table_1 INNER JOIN table_2 ON table_1.common_field = table_2.common_field; EXAMPLES: (E). THETA JOIN A theta join allows for arbitrary comparison relationships (such as ≥). An equijoin is a theta join using the equality operator. A natural join is an equijoin on attributes that have the same name in each relationship. 32
  • 34. EXAMPLES: (F). CROSS JOIN The SQL CROSS JOIN produces a result set which is the number of rows in the first table multiplied by the number of rows in the second table if no WHERE clause is used along with CROSS JOIN. This kind of result is called as Cartesian Product. SYNTAX: SELECT * FROM table_1 CROSS JOIN table_2; EXAMPLES: 33
  • 35. STRING OPERATION (A) SUBSTRING Return the substring as specified SYNTAX: SELECT SUBSTRING(string, start, length) EXAMPLES: (B). SUBSTRING_INDEX The SUBSTRING_INDEX() function returns a substring of a string before a specified number ofdelimiter occurs. SYNTAX: SELECT SUBSTRING_INDEX(string, delimiter, number) EXAMPLES: (C). UPPER The UPPER() function converts a string to upper-case. SYNTAX: SELECT UPPER(text) EXAMPLES: (D). LOWER The LOWER() function converts a string to lower-case. SYNTAX: SELECT LOWER(text) 34
  • 36. EXAMPLES: (F). LTRIM The LTRIM() function removes leading spaces from a string. SYNTAX: SELECT LTRIM(string) EXAMPLES: (G). RTRIM The RTRIM() function removes trailing spaces from a string. SYNTAX: SELECT RTRIM(string) EXAMPLES: (H). LEFT The LEFT() function extracts a number of characters from a string (starting from left). SYNTAX: SELECT LEFT(string, number_of_chars); EXAMPLES: 35
  • 37. (I). RIGHT The RIGHT() function repeats a string as many times as specified. SYNTAX: SELECT RIGHT(string, number); EXAMPLES: (J). REVERSE The REVERSE() function reverses a string and returns the result. SYNTAX: SELECT REVERSE(string) EXAMPLES: (K). LPAD The LPAD() function left-pads a string with another string, to a certain length. SYNTAX: SELECT LPAD(string, length, lpad_string); EXAMPLES: 36
  • 38. (L). RPAD The RPAD() function right-pads a string with another string, to a certain length. SYNTAX: SELECT RPAD(string, length, rpad_string); EXAMPLES: 37