Mysql Notesdsfsdf
Mysql Notesdsfsdf
A Database Management System (DBMS) is software that interacts with end-users, applications, and the
database itself to capture and analyze data. It manages data, the database engine, and the database
schema to facilitate the organization and manipulation of data.
A database is an organized collection of data. It is considered as a container of information.
In the manual system, you would maintain several files with different bits of information while in the
computerized system you would use database programs such as Microsoft Access, OpenOffice.org Base,
and MySQL, to organize the data as per your business need.
Database Management System :
A database management system is a software package with computer programs that controls the
creation, maintenance, and use of a database. for example Oracle, IBM DB2, Microsoft SQL Server,
Microsoft Access, PostgreSQL, MySQL, FoxPro, and SQLite.
Data can be organized into two types:
1. Flat File : Data is stored in a single table. Usually suitable for less amount of data.
2. Relational : Data is stored in multiple tables and the tables are linked using a common field.
Relational is suitable for medium to large amount of data.
Functions of a DBMS
Data Storage, Retrieval, and Update: Manages how data is stored, retrieved, and updated.
User Administration: Controls user access to the database.
Data Integrity and Security: Ensures data integrity and security.
Backup and Recovery: Provides tools for backing up and restoring data.
Note
DBMS ensures that data is consistently organized and remains easily accessible.
Types of DBMS
1. Hierarchical DBMS: Data is organized in a tree-like structure.
2. Network DBMS: Data is organized in a graph, allowing many-to-many relationships.
3. Relational DBMS (RDBMS): Data is organized in tables (relations). Examples include MySQL, PostgreSQL.
4. Object-Oriented DBMS: Data is stored in objects, similar to object-oriented programming.
Example
Example of RDBMS: Consider a school database system where data about students, teachers, and
classes are stored in tables. Each table has rows and columns representing different attributes.
Database Servers :
Database servers are dedicated computers that hold the actual databases and run only the DBMS and
related software.
Advantages of Database :
1) Reduces Data Redundancy : Database reduces data redundancy (duplication of data)
2) Sharing of Data : In a database, the users of the database can share the data among themselves.
3) Data Integrity : Data integrity means that the data is accurate and consistent in the database.
4) Data Security : Database provides data security as only authorized users are allowed to access the
database and their identity are authenticated by using a username and password.
5) Privacy : The privacy rule in a database states that only the authorized users can access a database
according to its privacy constraints.
6) Backup and Recovery : Database Management System automatically takes care of backup and
recovery.
Some key features of a database:
1) A database can have one or many tables.
2) Each table in a database contains information about one type of item.
3) Every table has a key field which ensures that there are 100% unique values throughout the database.
Relational DataBase Management System(RDBMS): A Database Management System that conforms at-
least half of the 12 rules defined by Dr. E.F. Codd (1970) in his research document. In a relational data
model, the data is organized into tables (i.e. Rows and Columns). These tables are called Relations. A
row in a table represents a relationship among a set of values. Since table is a collection of relationships
it is generally referred to using the mathematical term Relation.
Database Systems: Systems comprising of Databases and Database Management Systems are simply
referred as database systems.
Advantages of Data Base System:
1) Reduce data redundancy (duplication of data).
2) Control data inconsistency to a large extent.
3) Database facilitate sharing of data.
4) Enforce standards.
5) Centralized databases can ensure data security.
Examples of Common Database Management Systems: MySQL ,INGRES, POSTGRES, ORACLE, DB2.
Data Model: A way by which data structures and their relationships are analyzed.
Different Data Models:
1. Relational data model
2. Network data model
3. Hierarchical data model
Relational data model: In this model data is organized into tabular structures called relations. A
database may contain many relations providing a better classification of data based on its nature and
use. Multiple relations are then linked/ associated together on some common key data values (foreign
key).
Network Data Model: In this model data is represented by collections of records and relationships
among data are represented by links. A record is collection of fields i.e. attributes, each of which
contents only one data value.
Hierarchical data model: In this model records are organized as trees, data is represented by collection
of records connected to one another through links.
Basics of Relational Model Relation: A tabular structure containing data. To be a relation it must satisfy
following four conditions:
■ Atomicity: At every row-column intersection (Cell) there must be an atomic value i.e. a value that can
not be further subdivided.
■ No duplicity: No two rows of relation will be identical i.e. in any two rows value in at least one column
must be different.
■ Ordering of rows is immaterial.
■ Ordering of columns is immaterial.
Important Terms :
Table/Relation
Everything in a relational database is stored in the form of relations. The RDBMS database uses tables to
store data. A table is a collection of related data entries and contains rows and columns to store data.
Each table represents some real-world objects such as person, place, or event about which information
is collected. The organized collection of data into a relational table is known as the logical view of the
database.
Properties of a Relation:
Each relation has a unique name by which it is identified in the database.
Relation does not contain duplicate tuples.
The tuples of a relation have no specific order.
All attributes in a relation are atomic, i.e., each cell of a relation contains exactly one value.
Properties of a row:
No two tuples are identical to each other in all their entries.
All tuples of the relation have the same format and the same number of entries.
The order of the tuple is irrelevant. They are identified by their content, not by their position.
column/attribute
A column is a vertical entity in the table which contains all information associated with a specific field in
a table.
Properties of an Attribute:
Every attribute of a relation must have a name.
Null values are permitted for the attributes.
Default values can be specified for an attribute automatically inserted if no other value is
specified for an attribute.
Attributes that uniquely identify each tuple of a relation are the primary key.
data item/Cells
The smallest unit of data in the table is the individual data item. It is stored at the intersection of tuples
and attributes.
Properties of data items:
Data items are atomic.
The data items for an attribute should be drawn from the same domain.
Degree:
The total number of attributes that comprise a relation is known as the degree of the table.
Cardinality:
The total number of tuples at any one time in a relation is known as the table's cardinality. The relation
whose cardinality is 0 is called an empty table.
Domain:
The domain refers to the possible values each attribute can contain. It can be specified using standard
data types such as integers, floating numbers, etc. For example, An attribute entitled Marital_Status
may be limited to married or unmarried values.
NULL Values
The NULL value of the table specifies that the field has been left blank during record creation. It is
different from the value filled with zero or a field that contains space.
Data Integrity
There are the following categories of data integrity exist with each RDBMS:
Entity integrity: It specifies that there should be no duplicate rows in a table.
Domain integrity: It enforces valid entries for a given column by restricting the type, the format, or the
range of values.
Referential integrity specifies that rows cannot be deleted, which are used by other records.
User-defined integrity: It enforces some specific business rules defined by users. These rules are
different from the entity, domain, or referential integrity.
1) Primary Key : A primary key is a unique value that identifies a row in a table. It helps the database to
search for a record.
2) Composite Primary Key : When primary key constraint is applied on one or more columns then it is
known as Composite Primary Key.
3) Foreign key : The foreign key identifies a column or set of columns in one (referencing) table that
refers to a column or set of columns in another (referenced) table.
Data Manipulation Language (DML): The data manipulation language (DML) handles operations such as
entering rows into a table, changing data, deleting rows, and extracting data from rows and tables. With
DML, one does not change the table’s structure, but rather its contents. It contains commands like
INSERT, UPDATE and DELETE.
Transaction Control Language (TCL): A transaction is a one complete unit of work. A transaction is
successfully completed if and only if all its constituent steps are successfully completed. To manage and
control the transactions, the transaction control commands are used. e.g. COMMIT, ROLLBACK,
SAVEPOINT.
INTRODUCTION TO MYSQL
MySQL: It is an Open Source RDBMS Software that uses Structured Query Language. It is available free
of cost. Key Features of MySQL:
1. High Speed.
2. Ease of Use.
3. Available Free of Cost.
4. Supports standards based SQL.
5. Provides portability.
6. High Security.
7. Provides many data types.
8. Handles large database.
MySQL Data Types: Every column (or data item) should belong to a unique domain (known as data
type). These data types help to describe the kind of information a particular column holds. MySQL
supports the ANSI SQL data types. Some of the commonly used data types along with their
characteristics are as follows:
Data Types :
Datatypes are used to identify which type of data (value) we are going to store in the database. Data
types in OpenOffice base are broadly classified into five categories listed below.
1. Numeric Types
2. Alphanumeric Types
3. Binary Types
4. Date time
5. Other Variable types
Numeric Types :
Numeric data types in a database can be used for storing information such as mobile number, roll
number, door number etc. The different types of numeric data types available are listed here.
Alphanumeric Types :
This data type is used to store information which has alphabets as well as numbers for example address,
book summary field etc. The different types of Alphanumeric Types available are listed here.
Binary Types :
Binary data types are used for storing data in binary formats. Binary data types in a database can be
using for storing photos, music files, etc.
DATE TIME :
Date time data types in a database can be used for storing information such as date of birth, date of
admission, date of product sale, etc.
Creating Tables
Tables are defined with the CREATE TABLE command. When tables are created its columns are named,
data types and sizes supplied for each column. At least one column must be specified.
Syntax:
CREATE TABLE <TableName>(<ColumnName1> <Data Type1>,
<ColumnName2> <Data Type2>,…….,<ColumnNameN> <Data Type N>);
Example:
mysql> CREATE TABLE Students
(
RollNo DECIMAL(3),
Name VARCHAR(25)
);
Once the table is created we can insert the record in it, edit or delete existing records, and also we can
search for desired record in a very comprehensive way using the SQL Select statement.
Creating tables with SQL Constraints:
^ A Constraint is a condition or check applicable on a field or set of fields.
^ Data constraints are the rules that are defined when a table is created.
^ They can also be defined or modified after creating the tables.
^ When constraints are defined any data entering in the table is first checked to satisfy the condition
specified in particular constraint if it is, only then table data can be updated. If data updation/ insertion
is violating the defined constraints, database rejects the data (entire record is rejected).
^ When a constraint is applied to a single column, it is called a column level constraint but if a constraint
is applied on a combination of columns it is called a table constraint.
Following Constraints can be defined on a table in SQL:
Constraints name Description
Constraints are used in a database to specify the rules for data in a table. The following are the different
types of constraints:
NOT NULL
UNIQUE
CHECK
DEFAULT
INDEX
NOT NULL
Example
4 (
9 Address varchar(255),
10 City varchar(255),
11 Country varchar(255)
12 );
13
15
UNIQUE
This constraint ensures that all the values in a column are unique.
Example
4 (
9 Address varchar(255),
10 City varchar(255),
11 Country varchar(255)
12 );
13
14 --UNIQUE on Multiple Columns
15
17 (
22 Address varchar(255),
23 City varchar(255),
24 Country varchar(255),
26 );
27
29
32
34
CHECK
This constraint ensures that all the values in a column satisfy a specific condition.
Example
4 (
6 EmployeeName varchar(255),
8 PhoneNumber int,
9 Address varchar(255),
10 City varchar(255),
12 );
13
15
17 (
19 EmployeeName varchar(255),
21 PhoneNumber int,
22 Address varchar(255),
23 City varchar(255),
26
28
31
33
36
38
DEFAULT
This constraint consists of a set of default values for a column when no value is specified.
Example
4 (
8 PhoneNumber int,
9 Address varchar(255),
10 City varchar(255),
12 );
13
15
19
21
INDEX
This constraint is used to create indexes in the table, through which you can create and retrieve data
from the database very quickly.
Syntax
2 ON Persons (EmployeeName);
Now, let us look into the next part of this article i.e. DML Commands.
Upcoming Batches For Microsoft SQL Server Training Certification Course Online
This section of the article will give you an insight into the commands through which you can manipulate
the database. The commands are as follows:
USE
INSERT INTO
UPDATE
DELETE
SELECT
Apart from these commands, there are also other manipulative operators/functions such as:
Operators
Aggregate Functions
NULL Functions
Aliases & Case Statement
USE
The USE statement is used to select the database on which you want to perform operations.
Syntax
USE DatabaseName;
Example
1 USE Employee;
INSERT INTO
Syntax
--If you don't want to mention the column names then use the below syntax
2 VALUES ('06', 'Sanjana','Jagannath', '9921321141', 'Camel Street House No 12', 'Chennai', 'India
UPDATE
This statement is used to modify the records already present in the table.
Syntax
UPDATE TableName
SET Column1 = Value1, Column2 = Value2, ...
WHERE Condition;
Example
1 UPDATE Employee_Info
3 WHERE EmployeeID = 1;
DELETE
Syntax
2 WHERE EmployeeName='Preeti';
SELECT
This statement is used to select data from a database and the data returned is stored in a result table,
called the result-set.
Syntax
2 FROM Employee_Info;
Apart from just using the SELECT keyword individually, you can use the following keywords with the
SELECT statement:
DISTINCT
ORDER BY
GROUP BY
HAVING Clause
INTO
Syntax
SELECT DISTINCT Column1, Column2, ...ColumnN
FROM TableName;
Example
1 SELECT DISTINCT PhoneNumber FROM Employee_Info;
The ‘ORDER BY’ statement is used to sort the required results in ascending or descending order. The
results are sorted in ascending order by default. Yet, if you wish to get the required results in descending
order, you have to use the DESC keyword.
Syntax
SELECT Column1, Column2, ...ColumnN
FROM TableName
ORDER BY Column1, Column2, ... ASC|DESC;
Example
1 -- Select all employees from the 'Employee_Info' table sorted by EmergencyCon
3 ORDER BY EmergencyContactName;
8
-- Select all employees from the 'Employee_Info' table sorted by EmergencyContactName
9
SELECT * FROM Employee_Info
10
ORDER BY EmergencyContactName, EmployeeName;
11
12
/* Select all employees from the 'Employee_Info' table sorted by EmergencyContactName in Descending or
13
order: */
14
SELECT * FROM Employee_Info
15
ORDER BY EmergencyContactName ASC, EmployeeName DESC;
India India
SQL Training in
SQL Course in Kolkata
hyderabad
This ‘GROUP BY’ statement is used with the aggregate functions to group the result-set by one or more
columns.
Syntax
SELECT Column1, Column2,..., ColumnN
FROM TableName
WHERE Condition
GROUP BY ColumnName(s)
ORDER BY ColumnName(s);
Example
1 -- To list the number of employees from each city.
2
3 SELECT COUNT(EmployeeID), City
4 FROM Employee_Info
5 GROUP BY City;
The ‘HAVING’ clause is used in SQL because the WHERE keyword cannot be used everywhere.
Syntax
SELECT ColumnName(s)
FROM TableName
WHERE Condition
GROUP BY ColumnName(s)
HAVING Condition
ORDER BY ColumnName(s);
Example
/* To list the number of employees in each city. The employees should be sorted high to low and only thos
1
more than 5 employees:*/
2
3
SELECT COUNT(EmployeeID), City
4
FROM Employee_Info
5
GROUP BY City
6
HAVING COUNT(EmployeeID) > 2
7
ORDER BY COUNT(EmployeeID) DESC;
The ‘SELECT INTO’ statement is used to copy data from one table to another.
Syntax
SELECT *
INTO NewTable [IN ExternalDB]
FROM OldTable
WHERE Condition;
Example
1 -- To create a backup of database 'Employee'
3 FROM Employee;
4
7 FROM Employee;
10 FROM Employee
Now, as I mentioned before, let us move onto our next section in this article on SQL Commands, i.e. the
Operators.
Operators in SQL
Arithmetic Operators
Operator Description
% Modulous [A % B]
/ Division [A / B]
* Multiplication [A * B]
– Subtraction [A – B]
+ Addition [A + B]
Bitwise Operators
Operator Description
| Bitwise OR [A | B]
Comparison Operators
Operator Description
= Equal to [A = B]
Compound Operators
Operator Description
%= Modulo equals [A %= B]
/= Divide equals [A /= B]
*= Multiply equals [A*= B]
Logical Operators
AND
OR
NOT
BETWEEN
LIKE
IN
EXISTS
ALL
ANY
AND Operator
This operator is used to filter records that rely on more than one condition. This operator displays the
records, which satisfy all the conditions separated by AND, and give the output TRUE.
Syntax
OR Operator
This operator displays all those records which satisfy any of the conditions separated by OR and give the
output TRUE.
Syntax
NOT Operator
The NOT operator is used, when you want to display the records which do not satisfy a condition.
Syntax
NOTE: You can also combine the above three operators and write a query as follows:
NOTE: You can also combine the above three operators and write a query as follows:
BETWEEN Operator
The BETWEEN operator is used, when you want to select values within a given range. Since this is an
inclusive operator, both the starting and ending values are considered.
Syntax
SELECT ColumnName(s)
FROM TableName
WHERE ColumnName BETWEEN Value1 AND Value2;
Example
LIKE Operator
The LIKE operator is used in a WHERE clause to search for a specified pattern in a column of a table.
There are mainly two wildcards that are used in conjunction with the LIKE operator:
% – It matches 0 or more character.
_ – It matches exactly one character.
Syntax
SELECT ColumnName(s)
FROM TableName
WHERE ColumnName LIKE pattern;
Refer to the following table for the various patterns that you can mention with the LIKE operator.
WHERE CustomerName LIKE ‘v% Finds any values that start with “v”
WHERE CustomerName LIKE ‘%v’ Finds any values that end with “v”
WHERE CustomerName LIKE ‘%and%’ Finds any values that have “and” in any position
Example
IN Operator
This operator is used for multiple OR conditions. This allows you to specify multiple values in a WHERE
clause.
Syntax
SELECT ColumnName(s)
FROM TableName
WHERE ColumnName IN (Value1,Value2...);
Example
EXISTS Operator
The EXISTS operator is used to test if a record exists or not.
Syntax
SELECT ColumnName(s)
FROM TableName
WHERE EXISTS
(SELECT ColumnName FROM TableName WHERE condition);
Example
1 SELECT EmergencyContactName
2 FROM Employee_Info
3 WHERE EXISTS (SELECT EmergencyContactName FROM Employee_Info WHERE EmployeeId = 05 AND City = 'K
ALL Operator
The ALL operator is used with a WHERE or HAVING clause and returns TRUE if all of the subquery values
meet the condition.
Syntax
SELECT ColumnName(s)
FROM TableName
WHERE ColumnName operator ALL
(SELECT ColumnName FROM TableName WHERE condition);
Example
1 SELECT EmployeeName
2 FROM Employee_Info
3 WHERE EmployeeID = ALL (SELECT EmployeeID FROM Employee_Info WHERE City = 'Hyderabad');
ANY Operator
Similar to the ALL operator, the ANY operator is also used with a WHERE or HAVING clause and returns
true if any of the subquery values meet the condition.
Syntax
SELECT ColumnName(s)
FROM TableName
WHERE ColumnName operator ANY
(SELECT ColumnName FROM TableName WHERE condition);
Example
1 SELECT EmployeeName
2 FROM Employee_Info
3 WHERE EmployeeID = ANY (SELECT EmployeeID FROM Employee_Info WHERE City = 'Hyderabad' OR City =
Next, in this article on SQL Commands, let us look into the various Aggregate Functions provided in SQL.
Aggregate Functions
MIN()
MAX()
COUNT()
SUM()
AVG()
MIN() Function
The MIN function returns the smallest value of the selected column in a table.
Syntax
SELECT MIN(ColumnName)
FROM TableName
WHERE Condition;
Example
1 SELECT MIN(EmployeeID) AS SmallestID
2 FROM Employee_Info;
MAX() Function
The MAX function returns the largest value of the selected column in a table.
Databases Training
5(1600)
SQL ESSENTIALS TRAINING
SQL Essentials Training
Reviews
5(4650)
4(6850)
5(2900)
5(1200)
5(9)
Next
Syntax
SELECT MAX(ColumnName)
FROM TableName
WHERE Condition;
Example
1 SELECT MAX(Salary) AS LargestFees
2 FROM Employee_Salary;
COUNT() Function
The COUNT function returns the number of rows which match the specified criteria.
Syntax
SELECT COUNT(ColumnName)
FROM TableName
WHERE Condition;
Example
1 SELECT COUNT(EmployeeID)
2 FROM Employee_Info;
SUM() Function
The SUM function returns the total sum of a numeric column that you choose.
Syntax
SELECT SUM(ColumnName)
FROM TableName
WHERE Condition;
Example
1 SELECT SUM(Salary)
2 FROM Employee_Salary;
AVG() Function
The AVG function returns the average value of a numeric column that you choose.
Syntax
SELECT AVG(ColumnName)
FROM TableName
WHERE Condition;
Example
1 SELECT AVG(Salary)
2
FROM Employee_Salary;
NULL Functions
The NULL functions are those functions which let you return an alternative value if an expression is
NULL. In the SQL Server, the function is ISNULL().
Example
2 FROM Employee_Salary;
In this section of this article on SQL Commands, you will go through the Aliases and Case statement one
after the other.
Aliases
Aliases are used to give a column/table a temporary name and only exists for a duration of the query.
Syntax
--Alias Column Syntax
SELECT ColumnName(s)
FROM TableName AS AliasName;
Example
1 SELECT EmployeeID AS ID, EmployeeName AS EmpName
2 FROM Employee_Info;
5 FROM Employee_Info;
Case Statement
This statement goes through all the conditions and returns a value when the first condition is met. So, if
no conditions are TRUE, it returns the value in the ELSE clause. Also, if no conditions are true and there
is no ELSE part, then it returns NULL.
Syntax
CASE
WHEN Condition1 THEN Result1
WHEN Condition2 THEN Result2
WHEN ConditionN THEN ResultN
ELSE Result
END;
Example
1 SELECT EmployeeName, City
2 FROM Employee_Info
3 ORDER BY
4 (CASE
6 ELSE City
7 END);
Now, that I have told you a lot about DML commands in this article on SQL Commands, let me just tell
you in short about Nested Queries, Joins, Set Operations, and Dates & Auto Increment.
Nested Queries
Nested queries are those queries which have an outer query and inner subquery. So, basically, the
subquery is a query which is nested within another query such as SELECT, INSERT, UPDATE or DELETE.
Refer to the image below:
Joins
JOINS are used to combine rows from two or more tables, based on a related column between those
tables. The following are the types of joins:
INNER JOIN: This join returns those records which have matching values in both the tables.
FULL JOIN: This join returns all those records which either have a match in the left or the right
table.
LEFT JOIN: This join returns records from the left table, and also those records which satisfy the
condition from the right table.
RIGHT JOIN: This join returns records from the right table, and also those records which satisfy
the condition from the left table.
INNER JOIN
Syntax
SELECT ColumnName(s)
FROM Table1
INNER JOIN Table2 ON Table1.ColumnName = Table2.ColumnName;
Example SELECT Technologies.TechID, Employee_Info.EmployeeName
FROM Technologies
FULL JOIN
Syntax
SELECT ColumnName(s)
FROM Table1
FULL OUTER JOIN Table2 ON Table1.ColumnName = Table2.ColumnName;
Example
FROM Employee_Info
ORDER BY Employee_Info.EmployeeName;
LEFT JOIN
Syntax
SELECT ColumnName(s)
FROM Table1
LEFT JOIN Table2 ON Table1.ColumnName = Table2.ColumnName;
Example
FROM Employee_Info
ORDER BY Employee_Info.EmployeeName;
RIGHT JOIN
Syntax
SELECT ColumnName(s)
FROM Table1
RIGHT JOIN Table2 ON Table1.ColumnName = Table2.ColumnName;
Example
ORDER BY Technologies.TechID;
Set Operations
There are mainly three set operations:UNION, INTERSECT, EXCEPT. You can refer to the image below to
understand the set operations in SQL.
UNION
This operator is used to combine the result-set of two or more SELECT statements.
Syntax
INTERSECT
This clause used to combine two SELECT statements and return the intersection of the data-sets of both
the SELECT statements.
Syntax
INTERSECT
EXCEPT
This operator returns those tuples that are returned by the first SELECT operation, and are not returned
by the second SELECT operation.
Syntax
SELECT ColumnName
FROM TableName
EXCEPT
SELECT ColumnName
FROM TableName;
Next, in this article, let us look into the date functions and auto-increment fields.
This section of the article will give you an insight into the commands which aDMLre used to enforce
database security in multiple user database environments. The commands are as follows:
GRANT
REVOKE
GRANT
This command is used to provide access or privileges on the database and its objects to the users.
Syntax
GRANT PrivilegeName
ON ObjectName
TO {UserName |PUBLIC |RoleName}
[WITH GRANT OPTION];
where,
REVOKE
This command is used to withdraw the user’s access privileges given by using the GRANT command.
Syntax
REVOKE PrivilegeName
ON ObjectName
FROM {UserName |PUBLIC |RoleName}
Example
Views
A view in SQL is a single table, which is derived from other tables. So, a view contains rows and columns
similar to a real table and has fields from one or more table.
Syntax
Syntax
Syntax
This section of the article will give you an insight into the commands which are used to manage
transactions in the database. The commands are as follows:
COMMIT
Syntax
COMMIT;
ROLLBACK
This command is used to restore the database to the last committed state.
Syntax
ROLLBACK;
NOTE: When you use ROLLBACK with SAVEPOINT, then you can directly jump to a savepoint in an
ongoing transaction. Syntax: ROLLBACK TO SavepointName;
SAVEPOINT
This command is used to temporarily save a transaction. So if you wish to rollback to any point, then
you can save that point as a ‘SAVEPOINT’.
Syntax
SAVEPOINT SAVEPOINTNAME;