Re: Serial

From: "Milen A(dot) Radev" <milen(at)radev(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Serial
Date: 2007-04-03 10:10:58
Message-ID: eut97i$n5f$1@sea.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Shavonne Marietta Wijesinghe wrote:
> thanks. I read the page you gave.
>
> 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?

Add the missing "default":

CREATE TABLE mytable
(
n_gen int DEFAULT nextval('seq_mytable_n_gen'),
mycolumn1 int,
mycolumn2 int
);

--
Milen A. Radev

In response to

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

Browse pgsql-sql by date

  From Date Subject
Next Message A. Kretschmer 2007-04-03 10:14:46 Re: Serial
Previous Message Shavonne Marietta Wijesinghe 2007-04-03 09:55:10 Re: Serial