Maurice Yarrow wrote:
So it turned out to be possible to do it like this:
CREATE SEQUENCE id_seq;
SELECT setval('id_seq',100111);
FYI, you could have done this:
CREATE SEQUENCE id_seq START 100111;
- John D. Burger
MITRE
---(end of broadcast)---
Hello Richard
Thanks for the tip.
So it turned out to be possible to do it like this:
CREATE SEQUENCE id_seq;
SELECT setval('id_seq',100111);
CREATE TABLE customer( id INTEGER DEFAULT nextval('id_seq'), name
VARCHAR(30) );
INSERT INTO customer (name) VALUES ('SomeName');
INSERT INTO customer
> I thought about using a DEFAULT value, but I had presumed
> that this was only for repeated intializations. So then is it the
> case that a
> CREATE TABLE mytable ( id INTEGER PRIMARY KEY DEFAULT 10, ...
> only applies this default to the very first row of such a table, and then
> sensibly,
> Is there a formal way to set an initial value for a PRIMARY KEY
> when CREATE TABLE ? (This would be some large number,
> typically.)
I am not sure exact what you are looking for, but have you already looked at
the default clause of
the create table statement?
http://www.postgresql.org/docs/8
Maurice Yarrow <[EMAIL PROTECTED]> writes:
> Is there a formal way to set an initial value for a PRIMARY KEY
> when CREATE TABLE ?
If it's a SERIAL column, you use setval() on the underlying sequence
before you start inserting data.
regards, tom lane
-
Use a sequence and set the initial value of the sequence.
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:pgsql-general-
> [EMAIL PROTECTED] On Behalf Of Maurice Yarrow
> Sent: Friday, October 27, 2006 11:51 AM
> To: pgsql-general@postgresql.org
> Subject: [GENERAL] CREATE TABLE ini