pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Andreas Tille <tillea@rki.de>
To: PostgreSQL SQL <pgsql-sql@postgresql.org>
Subject: Re: Explicite typecasting of functions
Date: Thu, 15 Aug 2002 09:43:53 +0100
Message-ID: <200208150943.54761.dev@archonet.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0208150908430.8253-100000@wr-linux02.rki.ivbb.bund.de>
References: <Pine.LNX.4.44.0208150908430.8253-100000@wr-linux02.rki.ivbb.bund.de>

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



view thread (6+ messages)

Message-ID: <200208150943.54761.dev@archonet.com>
Permalink:  ../200208150943.54761.dev@archonet.com/
Also on:    postgresql.org/message-id/200208150943.54761.dev@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, tillea@rki.de
  Subject: Re: Explicite typecasting of functions
  In-Reply-To: <200208150943.54761.dev@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox