SlideShare a Scribd company logo
1 of 15
SQL Basics - 2
TRANSACTIONS AND
CONCURRENCY CONTROL
The concept of a user session involves the user first connecting to the database. This is like
dialing a phone number, but with a password, to get to the database.
The Standard SQL syntax for this statement is:
CONNECT TO <connection target>
<connection target> ::=
<SQL-server name>
[AS <connection name>]
[USER <user name>]
| DEFAULT
Transactions and ACID
Four characteristics we want in a transaction: the ACID properties.
• Atomicity
• Consistency
• Isolation
• Durability
Atomicity
Atomicity means that the whole transaction becomes persistent in the database or nothing in
the transaction becomes persistent. The data becomes persistent in Standard SQL when a
COMMIT statement is successfully executed.
A ROLLBACK statement removes the transaction and restores the database to its prior
(consistent) state before the transaction began. The COMMIT or ROLLBACK statement can be
explicitly executed by the user or by the database engine when it finds an error. Most SQL
engines default to a ROLLBACK unless they are configured to do otherwise.
Consistency
When the transaction starts, the database is in a consistent state and when it becomes
persistent in the database, the database is in a consistent state. The phrase “consistent state”
means that all of the data integrity constraints, relational integrity constraints, and any other
constraints are true.
Isolation
Isolation is also called serializability because it means that transactions act as if they were
executed in isolation from each other.
Durability
The database is stored on a durable media, so that if the database program is destroyed, the
database itself persists. Furthermore, the database can be restored to a consistent state when
the database system is restored. Log files and back-up procedure
Concurrency Control
Concurrency control is the part of transaction handling that deals with how multiple users
access the shared database without running into each other—sort of like a traffic light system.
One way to avoid any problems is to allow only one user in the database at a time. The only
problem with that solution is that the other users are going to get slow response time.
The Isolation Levels
In standard SQL, the user gets to set the isolation level of the transactions in his session. The
isolation level avoids some of the phenomena we just talked about and gives other information
to the database. The syntax for the <set transaction statement> is:
SCHEMA LEVEL OBJECTS
A database is not just a bunch of tables, even though that is where most of the work is done.
There are stored procedures, user-defined functions, and cursors that the users create. Then
there are indexes and other access methods that the user cannot access directly.
CREATE SCHEMA Statement
There is a CREATE SCHEMA statement defined in the standards that brings an entire schema into
existence all at once. In practice, each product has very different utility programs to allocate
physical storage and define a schema. Much of the proprietary syntax is concerned with physical
storage allocations.
CREATE PROCEDURE, CREATE FUNCTION, and CREATE TRIGGER
Procedural construct statements put modules of procedural code written in SQL/PSM or other
languages into the database
CREATE DOMAIN Statement
The DOMAIN is a schema element in Standard SQL that allows you to declare an in-line macro
that will allow you to put a commonly used column definition in one place in the schema. The
syntax is:
<domain definition> ::=
CREATE DOMAIN <domain name> [AS] <data type>
[<default clause>]
[<domain constraint>. . .]
[<collate clause>]
<domain constraint> ::=
[<constraint name definition>]
<check constraint definition> [<constraint attributes>]
<alter domain statement> ::=
ALTER DOMAIN <domain name> <alter domain action>
<alter domain action> ::=
<set domain default clause>
CREATE SEQUENCE
Sequences are generators that produce a sequence of values each time they are invoked.
The syntax looks like this:
CREATE SEQUENCE <seq name> AS <data type>
START WITH <value>
INCREMENT BY <value>
[MAXVALUE <value>]
[MINVALUE <value>]
[[NO] CYCLE];
CREATE ASSERTION
In Standard SQL, the CREATE ASSERTION allows you to apply a constraint on the tables within a schema but not have the constraint
attached to any particular table. The syntax is:
<assertion definition> ::=
CREATE ASSERTION <constraint name> <assertion check>
[<constraint attributes>]
<assertion check> ::=
CHECK (<search condition>)
As you would expect, there is a DROP ASSERTION statement, but no ALTER ASSERTION statement. An assertion can do things
that a CHECK() clause attached to a table cannot do, because it is outside of the tables involved. A CHECK() constraint is always
TRUE if the table is empty.

More Related Content

What's hot

2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...Jürgen Ambrosi
 
SQL Server Transaction Management
SQL Server Transaction ManagementSQL Server Transaction Management
SQL Server Transaction ManagementDenise McInerney
 
Mule with jdbc(my sql)
Mule with jdbc(my sql)Mule with jdbc(my sql)
Mule with jdbc(my sql)charan teja R
 
Mysql connection
Mysql connectionMysql connection
Mysql connectionbeben benzy
 
Always encrypted overview
Always encrypted overviewAlways encrypted overview
Always encrypted overviewSolidQ
 
Database security
Database securityDatabase security
Database securityJaved Khan
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functionsAmrit Kaur
 
Backbone to React. What it says about awesome UI Code.
Backbone to React. What it says about awesome UI Code.Backbone to React. What it says about awesome UI Code.
Backbone to React. What it says about awesome UI Code.Richard Powell
 
ISAS On SQL Features like Trigger, Transaction,Batches, Stored Procedure
ISAS On SQL Features like Trigger, Transaction,Batches, Stored ProcedureISAS On SQL Features like Trigger, Transaction,Batches, Stored Procedure
ISAS On SQL Features like Trigger, Transaction,Batches, Stored ProcedureShubham Choudahry
 

What's hot (13)

2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
2° Ciclo Microsoft CRUI 3° Sessione: l'evoluzione delle piattaforme tecnologi...
 
SQL Server Transaction Management
SQL Server Transaction ManagementSQL Server Transaction Management
SQL Server Transaction Management
 
Ebook12
Ebook12Ebook12
Ebook12
 
Mule with jdbc(my sql)
Mule with jdbc(my sql)Mule with jdbc(my sql)
Mule with jdbc(my sql)
 
Mysql connection
Mysql connectionMysql connection
Mysql connection
 
Dbcc.doc
Dbcc.docDbcc.doc
Dbcc.doc
 
PL/SQL TRIGGERS
PL/SQL TRIGGERSPL/SQL TRIGGERS
PL/SQL TRIGGERS
 
Always encrypted overview
Always encrypted overviewAlways encrypted overview
Always encrypted overview
 
Database security
Database securityDatabase security
Database security
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
 
Partially Contained Databases
Partially Contained DatabasesPartially Contained Databases
Partially Contained Databases
 
Backbone to React. What it says about awesome UI Code.
Backbone to React. What it says about awesome UI Code.Backbone to React. What it says about awesome UI Code.
Backbone to React. What it says about awesome UI Code.
 
ISAS On SQL Features like Trigger, Transaction,Batches, Stored Procedure
ISAS On SQL Features like Trigger, Transaction,Batches, Stored ProcedureISAS On SQL Features like Trigger, Transaction,Batches, Stored Procedure
ISAS On SQL Features like Trigger, Transaction,Batches, Stored Procedure
 

Viewers also liked

SQL Prepared Statements Tutorial
SQL Prepared Statements TutorialSQL Prepared Statements Tutorial
SQL Prepared Statements TutorialProdigyView
 
Sql queries questions and answers
Sql queries questions and answersSql queries questions and answers
Sql queries questions and answersMichael Belete
 
DBMS lab manual
DBMS lab manualDBMS lab manual
DBMS lab manualmaha tce
 
MS Sql Server: Creating A Database
MS Sql Server: Creating A DatabaseMS Sql Server: Creating A Database
MS Sql Server: Creating A DatabaseDataminingTools Inc
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands1keydata
 
Database Management Systems (DBMS)
Database Management Systems (DBMS)Database Management Systems (DBMS)
Database Management Systems (DBMS)Dimara Hakim
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Beat Signer
 
Sql queries with answers
Sql queries with answersSql queries with answers
Sql queries with answersvijaybusu
 

Viewers also liked (20)

Tables And SQL basics
Tables And SQL basicsTables And SQL basics
Tables And SQL basics
 
DBMS an Example
DBMS an ExampleDBMS an Example
DBMS an Example
 
SQL Prepared Statements Tutorial
SQL Prepared Statements TutorialSQL Prepared Statements Tutorial
SQL Prepared Statements Tutorial
 
Chapter2 j2ee
Chapter2 j2eeChapter2 j2ee
Chapter2 j2ee
 
Sql queries questions and answers
Sql queries questions and answersSql queries questions and answers
Sql queries questions and answers
 
Steering system 7
Steering system 7Steering system 7
Steering system 7
 
Sql queries
Sql queriesSql queries
Sql queries
 
100 sql queries
100 sql queries100 sql queries
100 sql queries
 
DBMS lab manual
DBMS lab manualDBMS lab manual
DBMS lab manual
 
Steering geometry 8
Steering geometry 8Steering geometry 8
Steering geometry 8
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
MySQL
MySQLMySQL
MySQL
 
Word Chapter 04
Word Chapter 04Word Chapter 04
Word Chapter 04
 
Dbms lab questions
Dbms lab questionsDbms lab questions
Dbms lab questions
 
MS Sql Server: Creating A Database
MS Sql Server: Creating A DatabaseMS Sql Server: Creating A Database
MS Sql Server: Creating A Database
 
DBMS Practical File
DBMS Practical FileDBMS Practical File
DBMS Practical File
 
SQL Tutorial - Basic Commands
SQL Tutorial - Basic CommandsSQL Tutorial - Basic Commands
SQL Tutorial - Basic Commands
 
Database Management Systems (DBMS)
Database Management Systems (DBMS)Database Management Systems (DBMS)
Database Management Systems (DBMS)
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 
Sql queries with answers
Sql queries with answersSql queries with answers
Sql queries with answers
 

Similar to Sql basics 2

Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)Vidyasagar Mundroy
 
SQL Server Admin Best Practices with DMV's
SQL Server Admin Best Practices with DMV'sSQL Server Admin Best Practices with DMV's
SQL Server Admin Best Practices with DMV'sSparkhound Inc.
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq lsInSync Conference
 
Novidades do SQL Server 2016
Novidades do SQL Server 2016Novidades do SQL Server 2016
Novidades do SQL Server 2016Marcos Freccia
 
Modern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas JellemaModern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas JellemaLucas Jellema
 
Kaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions PresentationKaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions Presentationkaashiv1
 
Subqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactionsSubqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactionsmaxpane
 
common_schema, DBA's framework for MySQL
common_schema, DBA's framework for MySQLcommon_schema, DBA's framework for MySQL
common_schema, DBA's framework for MySQLShlomi Noach
 
Vpd Virtual Private Database By Saurabh
Vpd   Virtual Private Database By SaurabhVpd   Virtual Private Database By Saurabh
Vpd Virtual Private Database By Saurabhguestd83b546
 
Managing SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAManaging SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAConcentrated Technology
 
Introduction to sql server
Introduction to sql serverIntroduction to sql server
Introduction to sql serverVinay Thota
 
Remote DBA Experts 11g Features
Remote DBA Experts 11g FeaturesRemote DBA Experts 11g Features
Remote DBA Experts 11g FeaturesRemote DBA Experts
 

Similar to Sql basics 2 (20)

Sql server
Sql serverSql server
Sql server
 
Sql Server
Sql ServerSql Server
Sql Server
 
Sql Sever Presentation.pptx
Sql Sever Presentation.pptxSql Sever Presentation.pptx
Sql Sever Presentation.pptx
 
Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)
 
SQL Server Admin Best Practices with DMV's
SQL Server Admin Best Practices with DMV'sSQL Server Admin Best Practices with DMV's
SQL Server Admin Best Practices with DMV's
 
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu   (obscure) tools of the trade for tuning oracle sq lsTony Jambu   (obscure) tools of the trade for tuning oracle sq ls
Tony Jambu (obscure) tools of the trade for tuning oracle sq ls
 
Novidades do SQL Server 2016
Novidades do SQL Server 2016Novidades do SQL Server 2016
Novidades do SQL Server 2016
 
Modern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas JellemaModern Database Development Oow2008 Lucas Jellema
Modern Database Development Oow2008 Lucas Jellema
 
Kaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions PresentationKaashiv SQL Server Interview Questions Presentation
Kaashiv SQL Server Interview Questions Presentation
 
Store procedures
Store proceduresStore procedures
Store procedures
 
Sherlock holmes for dba’s
Sherlock holmes for dba’sSherlock holmes for dba’s
Sherlock holmes for dba’s
 
Subqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactionsSubqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactions
 
common_schema, DBA's framework for MySQL
common_schema, DBA's framework for MySQLcommon_schema, DBA's framework for MySQL
common_schema, DBA's framework for MySQL
 
It Depends
It DependsIt Depends
It Depends
 
Vpd Virtual Private Database By Saurabh
Vpd   Virtual Private Database By SaurabhVpd   Virtual Private Database By Saurabh
Vpd Virtual Private Database By Saurabh
 
Managing SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBAManaging SQLserver for the reluctant DBA
Managing SQLserver for the reluctant DBA
 
Introduction to sql server
Introduction to sql serverIntroduction to sql server
Introduction to sql server
 
Module02
Module02Module02
Module02
 
Remote DBA Experts 11g Features
Remote DBA Experts 11g FeaturesRemote DBA Experts 11g Features
Remote DBA Experts 11g Features
 
Chapter09
Chapter09Chapter09
Chapter09
 

More from Raghu nath

Ftp (file transfer protocol)
Ftp (file transfer protocol)Ftp (file transfer protocol)
Ftp (file transfer protocol)Raghu nath
 
Javascript part1
Javascript part1Javascript part1
Javascript part1Raghu nath
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsRaghu nath
 
Selection sort
Selection sortSelection sort
Selection sortRaghu nath
 
Binary search
Binary search Binary search
Binary search Raghu nath
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)Raghu nath
 
Stemming algorithms
Stemming algorithmsStemming algorithms
Stemming algorithmsRaghu nath
 
Step by step guide to install dhcp role
Step by step guide to install dhcp roleStep by step guide to install dhcp role
Step by step guide to install dhcp roleRaghu nath
 
Network essentials chapter 4
Network essentials  chapter 4Network essentials  chapter 4
Network essentials chapter 4Raghu nath
 
Network essentials chapter 3
Network essentials  chapter 3Network essentials  chapter 3
Network essentials chapter 3Raghu nath
 
Network essentials chapter 2
Network essentials  chapter 2Network essentials  chapter 2
Network essentials chapter 2Raghu nath
 
Network essentials - chapter 1
Network essentials - chapter 1Network essentials - chapter 1
Network essentials - chapter 1Raghu nath
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2Raghu nath
 
python chapter 1
python chapter 1python chapter 1
python chapter 1Raghu nath
 
Linux Shell Scripting
Linux Shell ScriptingLinux Shell Scripting
Linux Shell ScriptingRaghu nath
 

More from Raghu nath (20)

Mongo db
Mongo dbMongo db
Mongo db
 
Ftp (file transfer protocol)
Ftp (file transfer protocol)Ftp (file transfer protocol)
Ftp (file transfer protocol)
 
MS WORD 2013
MS WORD 2013MS WORD 2013
MS WORD 2013
 
Msword
MswordMsword
Msword
 
Ms word
Ms wordMs word
Ms word
 
Javascript part1
Javascript part1Javascript part1
Javascript part1
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Selection sort
Selection sortSelection sort
Selection sort
 
Binary search
Binary search Binary search
Binary search
 
JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)JSON(JavaScript Object Notation)
JSON(JavaScript Object Notation)
 
Stemming algorithms
Stemming algorithmsStemming algorithms
Stemming algorithms
 
Step by step guide to install dhcp role
Step by step guide to install dhcp roleStep by step guide to install dhcp role
Step by step guide to install dhcp role
 
Network essentials chapter 4
Network essentials  chapter 4Network essentials  chapter 4
Network essentials chapter 4
 
Network essentials chapter 3
Network essentials  chapter 3Network essentials  chapter 3
Network essentials chapter 3
 
Network essentials chapter 2
Network essentials  chapter 2Network essentials  chapter 2
Network essentials chapter 2
 
Network essentials - chapter 1
Network essentials - chapter 1Network essentials - chapter 1
Network essentials - chapter 1
 
Python chapter 2
Python chapter 2Python chapter 2
Python chapter 2
 
python chapter 1
python chapter 1python chapter 1
python chapter 1
 
Linux Shell Scripting
Linux Shell ScriptingLinux Shell Scripting
Linux Shell Scripting
 
Perl
PerlPerl
Perl
 

Recently uploaded

Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 

Recently uploaded (20)

Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 

Sql basics 2

  • 2. TRANSACTIONS AND CONCURRENCY CONTROL The concept of a user session involves the user first connecting to the database. This is like dialing a phone number, but with a password, to get to the database. The Standard SQL syntax for this statement is: CONNECT TO <connection target> <connection target> ::= <SQL-server name> [AS <connection name>] [USER <user name>] | DEFAULT
  • 3. Transactions and ACID Four characteristics we want in a transaction: the ACID properties. • Atomicity • Consistency • Isolation • Durability
  • 4. Atomicity Atomicity means that the whole transaction becomes persistent in the database or nothing in the transaction becomes persistent. The data becomes persistent in Standard SQL when a COMMIT statement is successfully executed. A ROLLBACK statement removes the transaction and restores the database to its prior (consistent) state before the transaction began. The COMMIT or ROLLBACK statement can be explicitly executed by the user or by the database engine when it finds an error. Most SQL engines default to a ROLLBACK unless they are configured to do otherwise.
  • 5. Consistency When the transaction starts, the database is in a consistent state and when it becomes persistent in the database, the database is in a consistent state. The phrase “consistent state” means that all of the data integrity constraints, relational integrity constraints, and any other constraints are true.
  • 6. Isolation Isolation is also called serializability because it means that transactions act as if they were executed in isolation from each other.
  • 7. Durability The database is stored on a durable media, so that if the database program is destroyed, the database itself persists. Furthermore, the database can be restored to a consistent state when the database system is restored. Log files and back-up procedure
  • 8. Concurrency Control Concurrency control is the part of transaction handling that deals with how multiple users access the shared database without running into each other—sort of like a traffic light system. One way to avoid any problems is to allow only one user in the database at a time. The only problem with that solution is that the other users are going to get slow response time.
  • 9. The Isolation Levels In standard SQL, the user gets to set the isolation level of the transactions in his session. The isolation level avoids some of the phenomena we just talked about and gives other information to the database. The syntax for the <set transaction statement> is:
  • 10. SCHEMA LEVEL OBJECTS A database is not just a bunch of tables, even though that is where most of the work is done. There are stored procedures, user-defined functions, and cursors that the users create. Then there are indexes and other access methods that the user cannot access directly.
  • 11. CREATE SCHEMA Statement There is a CREATE SCHEMA statement defined in the standards that brings an entire schema into existence all at once. In practice, each product has very different utility programs to allocate physical storage and define a schema. Much of the proprietary syntax is concerned with physical storage allocations. CREATE PROCEDURE, CREATE FUNCTION, and CREATE TRIGGER Procedural construct statements put modules of procedural code written in SQL/PSM or other languages into the database
  • 12. CREATE DOMAIN Statement The DOMAIN is a schema element in Standard SQL that allows you to declare an in-line macro that will allow you to put a commonly used column definition in one place in the schema. The syntax is:
  • 13. <domain definition> ::= CREATE DOMAIN <domain name> [AS] <data type> [<default clause>] [<domain constraint>. . .] [<collate clause>] <domain constraint> ::= [<constraint name definition>] <check constraint definition> [<constraint attributes>] <alter domain statement> ::= ALTER DOMAIN <domain name> <alter domain action> <alter domain action> ::= <set domain default clause>
  • 14. CREATE SEQUENCE Sequences are generators that produce a sequence of values each time they are invoked. The syntax looks like this: CREATE SEQUENCE <seq name> AS <data type> START WITH <value> INCREMENT BY <value> [MAXVALUE <value>] [MINVALUE <value>] [[NO] CYCLE];
  • 15. CREATE ASSERTION In Standard SQL, the CREATE ASSERTION allows you to apply a constraint on the tables within a schema but not have the constraint attached to any particular table. The syntax is: <assertion definition> ::= CREATE ASSERTION <constraint name> <assertion check> [<constraint attributes>] <assertion check> ::= CHECK (<search condition>) As you would expect, there is a DROP ASSERTION statement, but no ALTER ASSERTION statement. An assertion can do things that a CHECK() clause attached to a table cannot do, because it is outside of the tables involved. A CHECK() constraint is always TRUE if the table is empty.