0

I have a database called contests whose copy I want to create
Referring to the top answer for this question : Copy a table (including indexes) in postgres
I executed the following command :
create table contests_clean ( like contests INCLUDING ALL );
It did create a new table with the modifiers and indexes as viewed in \d contests in the database but it did not copy the references (Referenced by as viewed in \d contests )
What do I need to add to the command to include References as well (Referenced by as viewed in \d contests
Please ask for any further details that are required

Tanmay Bhatnagar
  • 2,330
  • 4
  • 30
  • 50

1 Answers1

1

"Referenced by" means that another table references contests, i.e. there is a foreign key constraint in the referencing table pointing to contests.

So you cannot really "copy" that along with contents but had to either change the foreign key constraints in the referencing tables pointing to the new table or copy the referencing tables and then change their foreign key constraints.

sticky bit
  • 36,626
  • 12
  • 31
  • 42