Рет қаралды 177
In this postgresql tutorial video we'll explain the sql locking process in postgresql.
This postgresql tutorial for beginners will tell you that there are multiple postgresql locking modes:
1) SELECT query or Access Share Mode:
This SQL locking mode acquires locks on a specific table. Such a locking mode only allows us to read data from a table. Writing to a table is prohibited.
2) SELECT FOR UPDATE SQL Query or Row Share Mode:
This SQL locking mode will acquire a lock on a specific SQL table.
FOR SHARE and FOR UPDATE SQL queries and statements will be affected.
This locking method allows other threads to read the same resource.
When this locking mode is in use, read access is also possible.
3) UPDATE & DELETE SQL Query or Row Exclusive Mode:
This locking mode will acquire a lock on a specific row.
Concurrent INSERTs or DELETE sql queries to the same row will be prevented.
UPDATE, DELETE, and INSERT sql statements will be also affected.
This locking method allows exclusive access to a row.
4) CREATE INDEX SQL Query or Share Mode:
This locking mode allows for concurrent creation and read access to sql indexes on a sql table.
Locks will be obtained from the CREATE INDEX SQL query.
5) VACUUM SQL Query or Share Update Exclusive Mode:
This locking mode allows read and write access to a table.
Rows cannot be read or written.
This update mode affects the VACUUM, validation, table editing, and index creation commands.
6) ALTER TABLE or Share Row Exclusive Mode:
This locking mode is built for ALTER TABLE SQL queries.
As such, it protects tables from unplanned changes to data.
Data can be read as the schema is being modified.
7) ALTER TABLE & DROP TABLE or Exclusive Mode:
An exclusive lock is a write lock.
Such locks prevent anyone from modifying the content within database tables.
Data can be accessed by only one (exclusive) resource.
8) CREATE DATABASE & DROP DATABASE or Access Exclusive Mode:
An access exclusive mode is easy to understand.
Such a lock warrants that a database is accessed by only one transaction in one specific session.
We hope that this postgres tutorial has taught you something to improve your postgres architecture, stick around for more content, and until next time.
Below you will find a couple of sql interview questions and answers for your next sql interview:
Q: Is postgresql installation windows 10 very difficult?
A: No, simply download a Windows-based installer from PostgreSQL, then follow the instructions given by PostgreSQL: www.postgresql.org/download/w...
Q: Is there a PostgreSQL crash course for postgresql docker installations?
A: There are a few postgresql tutorial and stuff, but not a crash course. We'll probably make one in the near future though - stay tuned!
Q: What is the postgresql pg_hba.conf file?
A: The postgresql pg_hba.conf file is the configuration file controlling the client's authentication.
Q: What are some of the main database slowness reasons?
A: We've already made a video on this, but the main database slowness reasons are as follows:
1. Selecting too much data
2. Selecting unnecessary data
3. Scanning through many unnecessary rows
To reduce slow sql queries, make sure to use sql indexes.
Q: What is a sql index?
A: sql indexes explained goes like this: a sql index is a database structure used to quickly find rows in a table within a database.
Music:
Swing by Peyruis / peyruis
Creative Commons - Attribution 3.0 Unported - CC BY 3.0
Free Download / Stream: bit.ly/2Ca0gai
Music promoted by Audio Library: • Swing - Peyruis (No Co...
#postgresql #database #web #webdevelopment #developer #sql #webdeveloper