0

How do I create a COPY of a table without including any of the rows?

I want to copy a table, delete all of the rows, update a csv file to the copied table using csv copy_expert, and then use the copied table to update the original table.

I'm using copy_table = """SELECT (Top 0) into temp FROM original.;""" But it's giving an error for postgres.

Bo Peng
  • 561
  • 2
  • 8
  • 17

1 Answers1

2

Same question as Copy table structure into new table? Add a LIKE clause to your CREATE TABLE statement.

CREATE TABLE new_table_name ( LIKE old_table_name INCLUDING ALL )
Terry G Lorber
  • 2,932
  • 2
  • 23
  • 33