Skip to content

Instantly share code, notes, and snippets.

@michaeljforster-zz
Created March 11, 2013 21:48
Show Gist options
  • Select an option

  • Save michaeljforster-zz/5138094 to your computer and use it in GitHub Desktop.

Select an option

Save michaeljforster-zz/5138094 to your computer and use it in GitHub Desktop.
foobar=# begin; create table foo (id serial primary key); alter table foo rename to bar; commit;
BEGIN
NOTICE: CREATE TABLE will create implicit sequence "foo_id_seq" for serial column "foo.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo"
CREATE TABLE
ALTER TABLE
COMMIT
foobar=# \d
List of relations
Schema | Name | Type | Owner
--------+------------+----------+----------
public | bar | table | postgres
public | foo_id_seq | sequence | postgres
(2 rows)
foobar=# begin; create table foo (id serial primary key); alter table foo rename to bar; commit;
BEGIN
NOTICE: CREATE TABLE will create implicit sequence "foo_id_seq1" for serial column "foo.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey1" for table "foo"
CREATE TABLE
ERROR: relation "bar" already exists
ROLLBACK
foobar=# \d
List of relations
Schema | Name | Type | Owner
--------+------------+----------+----------
public | bar | table | postgres
public | foo_id_seq | sequence | postgres
(2 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment