0

I have exported my local database table to a file and wish to load it to my cloud db. when using the command: \copy <table name> from '<path>/<file name>.txt' delimiter ',' csv; the data is copied without enforcing the unique rules that exist on the table as well as insert the ID column "as is", not following the serial numbering.

I know the command update <table name> set <id column name> = DEFAULT;

here is the tricky part: I'm exporting other tables as well that have references to eachother

is there a way to achieve these two goals?

1
  • 1
    The premises are false: copy actually enforces unique constraints, and serial auto-numbering happens by default, just like with INSERT. If that doesn't work for you, please show a reproducible example or expand on the specifics of your case. Commented Nov 18, 2013 at 12:54

1 Answer 1

0

The tricky part is relatively tricky. You need to load the tables in the correct order. Otherwise you will have foreign key problems. I think the best way to do this is manually, but you could look at pg_depend and pg_constraint to see what you need to find to automate the order.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.