25 March 2020

This snippet shows you how you can copy a whole table to another one. Useful if you are about to change data in a table and later need to compare it with EXCEPT.

Source code viewer
  1. create table clone_of_my_table as (select * from my_table);
  2.  
  3. -- Table/structure without any data
  4. create table clone_of_my_table as (select * from my_table) with no data;
Programming Language: PostgreSQL