-- 检查 mes_moentry 和 mes_morder 表的主键定义

-- 查看 mes_moentry 表的主键
SELECT 
    'mes_moentry' AS table_name,
    COLUMN_NAME,
    CONSTRAINT_NAME,
    ORDINAL_POSITION
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = 'aidopdev' 
  AND TABLE_NAME = 'mes_moentry'
  AND CONSTRAINT_NAME = 'PRIMARY'
ORDER BY ORDINAL_POSITION;

-- 查看 mes_morder 表的主键
SELECT 
    'mes_morder' AS table_name,
    COLUMN_NAME,
    CONSTRAINT_NAME,
    ORDINAL_POSITION
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = 'aidopdev' 
  AND TABLE_NAME = 'mes_morder'
  AND CONSTRAINT_NAME = 'PRIMARY'
ORDER BY ORDINAL_POSITION;

-- 查看所有约束
SELECT 
    'mes_moentry' AS table_name,
    CONSTRAINT_NAME,
    CONSTRAINT_TYPE
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE TABLE_SCHEMA = 'aidopdev' 
  AND TABLE_NAME = 'mes_moentry';

SELECT 
    'mes_morder' AS table_name,
    CONSTRAINT_NAME,
    CONSTRAINT_TYPE
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE TABLE_SCHEMA = 'aidopdev' 
  AND TABLE_NAME = 'mes_morder';
