我要导出多张关联的数据库表的数据成xml 然后导入到生产环境的相同表内 主键都为uuid 映射关系在导入的时候怎么处理
迷茫2017-04-18 09:32:10
If you are just manipulating data, you should use the data import and export function of the database. If you must use Java, since the primary key is UUID, you should not need to import UUID data, but directly generate UUID data when inserting.
迷茫2017-04-18 09:32:10
If the two sets represent the same structure, then the mapping relationship should be written in the table creation statement! Similar to this:
create table student_teacher(student_id int, teacher_id int,
constraint student_teacher_PK primary key(student_id,teacher_id),
constraint student_id_FK foreign key(student_id) references student(id),
constraint teacher_id_FK foreign key(teacher_id) references teacher (id));
You generate an xml file to import, and the mapping relationship is the same in both databases.
Even if you use java and just read the xml file, you don’t need to consider the mapping relationship.
怪我咯2017-04-18 09:32:10
Turn off all foreign key constraints before importing, and enable foreign key constraints after importing