Re: MySQL to Postgres question - Mailing list pgsql-general

From Adam Rich
Subject Re: MySQL to Postgres question
Date
Msg-id 00e101c88b84$df1bbca0$9d5335e0$@r@sbcglobal.net
Whole thread Raw
In response to Re: MySQL to Postgres question  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
> > I am not sure about 8.3 but certainly earlier releases of PostgreSQL
> > would have specific dependency issues when a sequence was applied to
> a
> > a column after the fact, versus using the serial or bigserial
> > psuedo-types.

I'd like to point out that using pg_dump does in fact apply sequences
to columns after the fact. (at least in 8.3)  Columns lose their "serial"
designation after each backup/restore (and therefore during version
upgrades)

mydb=# create table foo(id serial, bar varchar);

NOTICE:  CREATE TABLE will create implicit sequence "foo_id_seq" for serial
column "foo.id"
CREATE TABLE

Then, pg_dump produces:

-bash-3.00$ pg_dump -s --table=foo mydb

CREATE TABLE foo (
    id integer NOT NULL,
    bar character varying
);

CREATE SEQUENCE foo_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;

ALTER SEQUENCE foo_id_seq OWNED BY foo.id;
ALTER TABLE foo ALTER COLUMN id SET DEFAULT nextval('foo_id_seq'::regclass);




pgsql-general by date:

Previous
From: "Edmund.Bacon"
Date:
Subject: Re: Cast character to boolean
Next
From: "Gauthier, Dave"
Date:
Subject: begin-end blocks in psql