1、导入的时候按照外键的先后顺序导入,而不是把约束删除。 或者把外键约束禁用掉。 == 这个也想过,不过有点烦啊 一百多个表 每次从数据库里导出它都是按字母顺序的;这样每次都要排一遍。 而且数据很变态,A是B外键的同时可能B也是A的外键:(2、用代码判断。 == 这是个办法。花些时间写个程序了。 程序里要: select * from tableA where a.foreignKey is null; select * from tableB where b.foreignKey is null; select * from tableC where c.foreignKey is null; .... 也是很繁琐的啊
或者把外键约束禁用掉。
==
这个也想过,不过有点烦啊
一百多个表
每次从数据库里导出它都是按字母顺序的;这样每次都要排一遍。
而且数据很变态,A是B外键的同时可能B也是A的外键:(2、用代码判断。
==
这是个办法。花些时间写个程序了。
程序里要:
select * from tableA where a.foreignKey is null;
select * from tableB where b.foreignKey is null;
select * from tableC where c.foreignKey is null;
....
也是很繁琐的啊
`information_schema`.`TABLE_CONSTRAINTS`