MySQL使用笔记
# 查看MySQL的版本
select version();
1
# 删除所有表
SELECT concat('DROP TABLE IF EXISTS ', table_name, ';')
FROM information_schema.tables
WHERE table_schema = '库名';
1
2
3
2
3
# 查找表
# 根据字段名查找表
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = 'your_column_name'
AND TABLE_SCHEMA='your_database_name';
1
2
3
4
2
3
4
# 根据索引名查找表
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.STATISTICS
WHERE INDEX_NAME = 'your_index_name'
AND TABLE_SCHEMA='your_database_name';
1
2
3
4
2
3
4
编辑 (opens new window)
上次更新: 2024/03/04, 13:28:13