java 通過map根據list某個欄位進行合併
阿新 • • 發佈:2021-01-19
1、查詢MySQL庫下所有表名,資料為空的表
SELECT table_name, table_rows FROM information_schema. TABLES WHERE table_schema = 'ahbo' AND table_rows < 1;
2、查詢指定庫擁有某欄位的表
SELECT DISTINCT TABLE_NAME FROM information_schema. COLUMNS WHERE COLUMN_NAME = 'columnName' AND TABLE_SCHEMA = 'dbName' AND TABLE_NAME NOT LIKE 'vw%';
3、修改指定資料庫中所有varchar型別的表字段的字符集為UTF8,並將排序規則修改為utf8_general_ci
SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY `', column_name, '` ', DATA_TYPE, '(', CHARACTER_MAXIMUM_LENGTH, ') CHARACTER SET UTF8 COLLATE utf8_general_ci', (CASE WHEN IS_NULLABLE = 'NO' THEN ' NOT NULL' ELSE '' END), ';') 別名 FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'SchoolUserOnline_20170416' AND DATA_TYPE = 'varchar' AND ( CHARACTER_SET_NAME != 'utf8' OR COLLATION_NAME != 'utf8_general_ci' );
4、修改指定資料庫中所有資料表的字符集為UTF8,並將排序規則修改為utf8_general_ci
SELECT CONCAT('ALTER TABLE ', table_name, 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;') FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'databaseName'