Files
ccdi/sql/fix_charset.sql
2026-01-30 14:15:21 +08:00

29 lines
959 B
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 检查并修复数据库字符集
-- 执行前请备份数据库!
-- 1. 检查数据库字符集
SELECT
DEFAULT_CHARACTER_SET_NAME,
DEFAULT_COLLATION_NAME
FROM information_schema.SCHEMATA
WHERE SCHEMA_NAME = 'discipline-prelim-check';
-- 2. 检查 ccdi_employee 表字符集
SHOW CREATE TABLE ccdi_employee;
-- 3. 检查 ccdi_employee_relative 表字符集
SHOW CREATE TABLE ccdi_employee_relative;
-- 4. 如果字符集不是 utf8mb4执行以下语句修复请根据实际情况修改
-- 修改数据库字符集
ALTER DATABASE `discipline-prelim-check` CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
-- 修改表字符集
ALTER TABLE `ccdi_employee` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `ccdi_employee_relative` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- 5. 清空测试数据(可选)
-- TRUNCATE TABLE ccdi_employee_relative;
-- TRUNCATE TABLE ccdi_employee;