自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

MySQLump 參數(shù)--Lock-Tables淺析

數(shù)據(jù)庫 MySQL
mysqldump有一個(gè)參數(shù)--lock-tables,以前對(duì)這個(gè)參數(shù)也沒有深入、詳細(xì)了解過,直到上次有個(gè)網(wǎng)友問“參數(shù)lock-tables 是一次性鎖定當(dāng)前庫的所有表,還是鎖定當(dāng)前導(dǎo)出表?“ 所以我給大家說說,希望能幫助到大家。

[[379135]]

本文轉(zhuǎn)載自微信公眾號(hào)「DBA閑思雜想錄」,作者瀟湘隱者 。轉(zhuǎn)載本文請(qǐng)聯(lián)系DBA閑思雜想錄公眾號(hào)。     

mysqldump有一個(gè)參數(shù)--lock-tables,以前對(duì)這個(gè)參數(shù)也沒有深入、詳細(xì)了解過,直到上次有個(gè)網(wǎng)友問“參數(shù)lock-tables 是一次性鎖定當(dāng)前庫的所有表,還是鎖定當(dāng)前導(dǎo)出表?“ ,之前一直以為只是鎖定當(dāng)前導(dǎo)出表,后面看了參數(shù)說明后,

  1. -l, --lock-tables   Lock all tables for read. 
  2.  
  3.                       (Defaults to on; use --skip-lock-tables to disable.) 

自己也不怎么確認(rèn)了,當(dāng)時(shí)就測(cè)試了一下。準(zhǔn)備一個(gè)稍微大一點(diǎn)的庫,如果數(shù)據(jù)庫太小,那么可能mysqldum命令一下子就導(dǎo)出了所有庫,很難清晰的看到實(shí)驗(yàn)結(jié)果。

執(zhí)行下面命令做邏輯備份

  1. [root@DB-Server ~]# mysqldump -u root -p --default-character-set=utf8  --opt --extended-insert=false --lock-tables MyDB > db_backup_MyDB.sql 
  2.  
  3. Enter password

同時(shí)立即執(zhí)行下面命令

  1. mysql> show open tables where in_use >0; 
  2. +----------+--------------------------------+--------+-------------+ 
  3. Database | Table                          | In_use | Name_locked | 
  4. +----------+--------------------------------+--------+-------------+ 
  5. | MyDB     | AO_60DB71_VERSION              |      1 |           0 | 
  6. | MyDB     | AO_AEFED0_TEAM_TO_MEMBER       |      1 |           0 | 
  7. | MyDB     | AO_4B00E6_STASH_SETTINGS       |      1 |           0 | 
  8. | MyDB     | AO_2D3BEA_FOLIOCF              |      1 |           0 | 
  9. | MyDB     | AO_AEFED0_TEAM_ROLE            |      1 |           0 | 
  10. | MyDB     | AO_60DB71_DETAILVIEWFIELD      |      1 |           0 | 
  11. | MyDB     | AO_60DB71_LEXORANK             |      1 |           0 | 
  12. | MyDB     | AO_6714C7_REPORT_SCHEDULE      |      1 |           0 | 
  13. | MyDB     | AO_E8B6CC_SYNC_AUDIT_LOG       |      1 |           0 | 
  14. | MyDB     | cwd_application                |      1 |           0 | 
  15. | MyDB     | clusternode                    |      1 |           0 | 
  16. | MyDB     | AO_86ED1B_GRACE_PERIOD         |      1 |           0 | 
  17. | MyDB     | AO_60DB71_WORKINGDAYS          |      1 |           0 | 
  18. | MyDB     | cwd_directory                  |      1 |           0 | 
  19. | MyDB     | AO_2D3BEA_BASELINE             |      1 |           0 | 
  20. | MyDB     | fieldlayoutitem                |      1 |           0 | 
  21. | MyDB     | JQUARTZ_BLOB_TRIGGERS          |      1 |           0 | 
  22. | MyDB     | AO_013613_HD_SCHEME_MEMBER     |      1 |           0 | 
  23. | MyDB     | AO_2D3BEA_ALLOCATION           |      1 |           0 | 
  24. | MyDB     | AO_013613_WL_SCHEME            |      1 |           0 | 
  25. | MyDB     | AO_7DEABF_EXEC_CLUSTER_MESSAGE |      1 |           0 | 
  26. .................................................................... 

如上截圖,執(zhí)行mysqldump命令的時(shí)候,使用show open tables where in_use >0命令,你會(huì)看到MyDB里面的所有表的In_use的值都為1,意味著是當(dāng)執(zhí)行mysqldump命令時(shí),是一次性鎖定當(dāng)前庫的所有表。而不是鎖定當(dāng)前導(dǎo)出表。

In_use說明

  • The number of table locks or lock requests there are for the table. For example, if one client acquires a lock for a table using LOCK TABLE t1 WRITE, In_use will be 1. If another client issues LOCK TABLE t1 WRITE while the table remains locked, the client will block waiting for the lock, but the lock request causes In_use to be 2. If the count is zero, the table is open but not currently being used. In_use is also increased by the HANDLER ... OPEN statement and decreased by HANDLER ... CLOSE.

參考資料:

https://dev.mysql.com/doc/refman/5.7/en/show-open-tables.html

https://oracle-base.com/articles/mysql/mysql-identify-locked-tables

 

責(zé)任編輯:武曉燕 來源: DBA閑思雜想錄
相關(guān)推薦

2021-03-02 12:34:47

MySQL解鎖表鎖定表

2009-06-16 10:36:00

Google Fusi應(yīng)用實(shí)例

2010-05-24 10:45:52

子命令Svn lock

2021-03-29 15:32:31

Python函數(shù)參數(shù)

2009-07-22 16:02:14

iBATIS參數(shù)

2025-03-19 10:26:12

Python參數(shù)開發(fā)

2021-03-03 10:00:52

Python函數(shù)Python基礎(chǔ)

2009-07-06 14:52:10

ServletConfServletCont

2009-09-04 18:16:19

C# Main參數(shù)C# Main

2009-08-24 14:51:25

C# 泛型泛型類型

2009-08-28 15:57:56

C#線程傳遞參數(shù)

2009-08-24 15:02:05

C# 類型

2010-05-10 11:26:40

Oracle 參數(shù)文件

2010-01-25 09:57:39

C++函數(shù)參數(shù)

2009-08-17 13:26:20

C#調(diào)用Windows

2025-04-24 10:56:01

MySQLInnoDB數(shù)據(jù)庫鎖

2009-12-14 16:43:55

2024-06-12 14:03:31

MySQLInnoDB

2021-01-28 05:17:01

并發(fā)包JDK

2022-05-26 21:05:23

MySQL腳本數(shù)據(jù)庫
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)