On Thursday 15 Aug 2002 8:13 am, Andreas Tille wrote:
> On Wed, 14 Aug 2002, Tom Lane wrote:
> >     CREATE TABLE without mentioning the default
> >     CREATE FUNCTION
> >     ALTER TABLE ... SET DEFAULT
> >
> > Note however that pg_dump is not bright enough to deduce that you did
> > this.  It will dump the table definition first, with the DEFAULT clause,
> > and so you'll have to do manual surgery on the dump file if you ever
> > need to reload.
>
> Hmmm, the original problem I wanted to solve using this function is that
> pg_dump is not bright enough to store sequences.

Eh? If you run a pg_dump on your database you should get something like:

CREATE SEQUENCE "bar_a_seq" start 1 increment 1 maxvalue 9223372036854775807 
minvalue 1 cache 1;

CREATE TABLE "bar" (
        "a" integer DEFAULT nextval('"bar_a_seq"'::text) NOT NULL,
        "b" integer
);

... data then follows...

-- Name: bar_a_seq Type: SEQUENCE SET Owner: richardh
SELECT setval ('"bar_a_seq"', 3, true);

It's that last bit that sets the value of the sequence. Now AFAIK pg_dump's 
been like that pretty much forever.

Note - if you only pg_dump the table, you won't get the sequence, you need to 
dump the whole DB and grep away the bits you don't want.

- Richard Huxton

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to