简体   繁体   中英

How to dump selected PostgreSQL data from one database to other databse

I have three tables with foreign key relationship with each other.

The table school will be uploaded manually. A student will login to the website and check their marks

The entire data is to be uploaded to another new database of different instance

The Login Id(stud_id) of the student in DB1 is 10 and Login Id(stud_id) of the student in DB2 is 1 in another instance.

For retaining the data of student_marks table, I intend to do the following steps,

1. Dump student_marks table from DB1
2. Copy it to DB2

NOTE: stud_id would be different for both the databases

Is there any way to do the above.

Refer the table below,

school:

 id  | name| place 
-----+-------------
 1 |  sch1  | test

student:

id  | school_id| stud_name 
-----+-------------
 1   |  1       | stud1

student_marks:

 id  | stud_id| subj1 | subj2
-----+-----------------------
 1   |  1    | 30      | 30

Thanks in advance!

首先禁用外键约束,然后转储数据,然后再次启用外键约束,或者您可以在迁移数据后放置外键约束。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM