Re: Serial

From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Serial
Date: 2007-04-03 10:14:46
Message-ID: 20070403101446.GC30108@a-kretschmer.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

am Tue, dem 03.04.2007, um 11:55:10 +0200 mailte Shavonne Marietta Wijesinghe folgendes:
> thanks. I read the page you gave.

Really?

>
> CREATE SEQUENCE seq_mytable_n_gen;
>
> CREATE TABLE mytable
> (
> n_gen int nextval('seq_mytable_n_gen'),
> mycolumn1 int,
> mycolumn2 int
> );
>
>
> i tried creating it like that. The sequence was created without any error.
> But for the create table i get
>
> ERROR: syntax error at or near "nextval" at character 38
>
> What should i do?

Your question was, how to set the sequence to a new value, and my answer
was: use setval().

Now you tried to create a new table. You have a simple syntax error:

,----[ example ]
| test=# create sequence testseq;
| CREATE SEQUENCE
| test=*# create table testtab (id int default nextval('testseq'));
| CREATE TABLE
`----

You forgot the word 'default'.

>
>
> Shavonne Wijesinghe
>
> ----- Original Message -----
> From: "A. Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>

Please, no silly text above with fullquote below, i read from top to
bottom...

Andreas
--
Andreas Kretschmer
Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net

In response to

  • Re: Serial at 2007-04-03 09:55:10 from Shavonne Marietta Wijesinghe

Responses

  • Re: Serial at 2007-04-03 10:29:37 from Shavonne Marietta Wijesinghe

Browse pgsql-sql by date

  From Date Subject
Next Message Shavonne Marietta Wijesinghe 2007-04-03 10:29:37 Re: Serial
Previous Message Milen A. Radev 2007-04-03 10:10:58 Re: Serial