Bo Peng
Bo Peng

Reputation: 603

postgresql COPY TABLE not including table rows

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.

Upvotes: 0

Views: 243

Answers (1)

Terry G Lorber
Terry G Lorber

Reputation: 2962

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 )

Upvotes: 2

Related Questions