Database Lock and its types

0 votes
Hi!!

What does a lock mean in Database?
Aug 9, 2018 in Database by DataKing99
• 8,250 points
18,453 views

2 answers to this question.

0 votes

Database lock basically signifies the transaction about the current status of the data item i.e. whether that data is being used by other transactions or not at that point of time.

Two types of Database lock are present:

  • Shared Lock 
  • Exclusive Lock
answered Aug 9, 2018 by CodingByHeart77
• 3,750 points
Ok... But table level lock is different from exclusive lock, I presume.

Hey, @ Sudhir,

This is regarding your statement:

The LOCK TABLE statement allows you to explicitly acquire a shared or exclusive table lock on the specified table. The table lock lasts until the end of the current transaction.

When a statement modifies data, its transaction holds an exclusive lock on data that prevents other transactions from accessing the data.

This lock remains in place until the transaction holding the lock issues a commit or rollback. Table-level locking lowers concurrency in a multi-user system.

0 votes

Hello Dataking99,

  • A database lock is used to “lock” some data in a database so that only one database user/session may update that particular data
  • So, database locks exist to prevent two or more database users from updating the same exact piece of data at the same exact time.
  •  When data is locked, then that means that another database session can NOT update that data until the lock is released .

Database locks can actually be placed at different levels – also known as lock granularity – within the database. Here is the list of lock

  1. Database level locking- Entire database is locked – which means that only one database session can apply any updates to the database.
  2. File level locking- An entire database file is locked(file can have a wide variety of data – inside a file there could be an entire table, a part of a table, or even parts of different tables.)
  3. Table level locking- It means that an entire table is locked as a whole. This lock level comes in handy when making a change that affects an entire table, like updating all the rows in a table, or modifiying the table to add or remove columns.
  4. Page or block level locking-Block, or page, level locking occurs when a block or page that is part of a database file is locked
  5. Column level locking-Some columns within a given row in a given table are locked.
  6. Row level locking- Lock applies to a row in a table.

Hope this is helpful!!

Thank You!!

answered Apr 20, 2020 by Niroj
• 82,840 points

Related Questions In Database

0 votes
2 answers

Types of relationships in Database

There are 3 types of relationships in ...READ MORE

answered Aug 17, 2018 in Database by zombie
• 3,790 points
2,936 views
0 votes
1 answer

Atomicity and Aggregation in Database

Atomicity is the condition where either all the ...READ MORE

answered Aug 22, 2018 in Database by DataKing99
• 8,250 points
3,057 views
0 votes
1 answer

What do ‘Record’, ‘Field’ and ‘Table’ mean in terms of a database?

You can refer to the following definitions ...READ MORE

answered Nov 12, 2018 in Database by Sahiti
• 6,370 points
22,101 views
0 votes
1 answer

What are the different types of keys used in the database?

There are mainly 5 types of Keys, ...READ MORE

answered Nov 19, 2018 in Database by Sahiti
• 6,370 points
5,945 views
0 votes
1 answer

Is it possible to access Couchbase by terminal?

What you want to accomplish isn't possible ...READ MORE

answered Apr 29, 2018 in DevOps & Agile by DareDev
• 6,890 points
791 views
0 votes
1 answer

How to connect Java program to the MySQL database?

You can connect your Java code with ...READ MORE

answered May 11, 2018 in Java by Parth
• 4,640 points
1,929 views
0 votes
1 answer
+1 vote
3 answers

How do I check and export sonarqube analysis reports in embedded db?

Browse to sonarqube web instance to access ...READ MORE

answered Jul 2, 2018 in DevOps Tools by DareDev
• 6,890 points
28,383 views
+1 vote
1 answer

Cursor and Its Types

The cursor is a temporary work area ...READ MORE

answered Aug 9, 2018 in Database by CodingByHeart77
• 3,750 points
974 views
0 votes
1 answer

Data Independence & it's types

Data Independence refers to the ability to ...READ MORE

answered Aug 30, 2018 in Database by CodingByHeart77
• 3,750 points
5,740 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP