identify lock
This commit is contained in:
		
							parent
							
								
									59d4502074
								
							
						
					
					
						commit
						2b42ef0287
					
				|  | @ -0,0 +1,29 @@ | |||
| # Identify what locking table | ||||
| 
 | ||||
| ## Method 1 | ||||
| 
 | ||||
| ``` | ||||
| SHOW open tables WHERE In_use > 0; | ||||
| ``` | ||||
| 
 | ||||
| ## Method 2 | ||||
| 
 | ||||
| ``` | ||||
| SELECT | ||||
|     OBJECT_SCHEMA,  | ||||
|     OBJECT_NAME,  | ||||
|     GROUP_CONCAT(DISTINCT EXTERNAL_LOCK) | ||||
| FROM  | ||||
|     performance_schema.table_handles  | ||||
| WHERE  | ||||
|     EXTERNAL_LOCK IS NOT NULL | ||||
| GROUP BY  | ||||
|     OBJECT_SCHEMA,  | ||||
|     OBJECT_NAME; | ||||
| ``` | ||||
| 
 | ||||
| ## Process list | ||||
| 
 | ||||
| ``` | ||||
| SHOW PROCESSLIST; | ||||
| ``` | ||||
|  | @ -1,21 +0,0 @@ | |||
| # Find all tables whose foreign key refers to the table/column | ||||
| 
 | ||||
| # BY TABLE | ||||
| SELECT  | ||||
|   TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME | ||||
| FROM | ||||
|   INFORMATION_SCHEMA.KEY_COLUMN_USAGE | ||||
| WHERE | ||||
|   REFERENCED_TABLE_SCHEMA = (SELECT DATABASE()) AND | ||||
|   REFERENCED_TABLE_NAME = '<insert_table_name>'; | ||||
|    | ||||
|    | ||||
| # BY TABLE COLUMN | ||||
| SELECT  | ||||
|   TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME | ||||
| FROM | ||||
|   INFORMATION_SCHEMA.KEY_COLUMN_USAGE | ||||
| WHERE | ||||
|   REFERENCED_TABLE_SCHEMA = (SELECT DATABASE()) AND | ||||
|   REFERENCED_TABLE_NAME = '<insert_table_name>' AND | ||||
|   REFERENCED_COLUMN_NAME = '<insert_column_name>'; | ||||
|  | @ -6,3 +6,4 @@ This is a repository with useful snippets of various kinds of code | |||
| 
 | ||||
| - [MySQL](./src/branch/master/MySQL) | ||||
| - - [all_foreign_keys_to_table_or_column](./src/branch/master/MySQL/all_foreign_keys_to_table_or_column.md) | ||||
| - - [identify_lock](./src/branch/master/MySQL/identify_lock.md) | ||||
		Loading…
	
		Reference in New Issue