Skip to content

Instantly share code, notes, and snippets.

@andrewp-as-is
Last active July 19, 2021 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewp-as-is/d1154ec6601933aebcdcf6d259b85831 to your computer and use it in GitHub Desktop.
Save andrewp-as-is/d1154ec6601933aebcdcf6d259b85831 to your computer and use it in GitHub Desktop.
postgres copy table
CREATE TABLE IF NOT EXISTS t(
id serial PRIMARY KEY,
value text
);
INSERT INTO t(id,value) VALUES (1,'value1'), (2,'value2');
CREATE TABLE t_with_data AS TABLE t;
CREATE TABLE t_without_data AS TABLE t WITH NO DATA;
select COUNT(*) from t_without_data;
select COUNT(*) from t_with_data;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment