-- 检查工单表的 name 字段长度限制

SELECT 
    COLUMN_NAME AS 字段名,
    COLUMN_TYPE AS 字段类型,
    CHARACTER_MAXIMUM_LENGTH AS 最大长度,
    IS_NULLABLE AS 可为空,
    COLUMN_COMMENT AS 注释
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
  AND TABLE_NAME = 'test_work_order'
  AND COLUMN_NAME = 'name';

-- 查看现有工单名称的长度分布
SELECT 
    LENGTH(name) AS 名称长度,
    COUNT(*) AS 数量,
    MAX(name) AS 示例
FROM test_work_order
GROUP BY LENGTH(name)
ORDER BY LENGTH(name) DESC
LIMIT 10;
