Обсуждение: Create table & serial question
Hello all
If this is too trivial... sorry. :o(((
I have created a table with the following command:
CREATE TABLE ROUTE
(
ID SERIAL ,
START DATE ,
PRIMARY KEY ( ID )
) ;
And it worked just fine. But if I call:
INSERT INTO ROUTE VALUES(10, '10/10/1999') ;
it ads a record but the id is 10. Is this the correct behaviour for the
SERIAL type? I was hoping it will be 1 and ignore the one that I set.
If this is the normal behaviour, how can I make it ignore the 10 and place
the next id?
Tx
dovle
Just do
INSERT INTO ROUTE VALUES('10/10/1999') ;
It will automatically populate the next value.
On Mon, Nov 18, 2002 at 08:30:13PM +0100, Alex Dovlecel wrote:
> Hello all
> If this is too trivial... sorry. :o(((
>
> I have created a table with the following command:
>
> CREATE TABLE ROUTE
> (
> ID SERIAL ,
> START DATE ,
> PRIMARY KEY ( ID )
> ) ;
>
> And it worked just fine. But if I call:
> INSERT INTO ROUTE VALUES(10, '10/10/1999') ;
> it ads a record but the id is 10. Is this the correct behaviour for the
> SERIAL type? I was hoping it will be 1 and ignore the one that I set.
>
> If this is the normal behaviour, how can I make it ignore the 10 and place
> the next id?
>
> Tx
> dovle
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
--
Dror Matalon
Zapatec Inc
1700 MLK Way
Berkeley, CA 94709
http://www.zapatec.com
Should be:
INSERT INTO ROUTE(START) VALUES('10/10/1999');
Dror Matalon wrote:
>
> Just do
>
> INSERT INTO ROUTE VALUES('10/10/1999') ;
>
> It will automatically populate the next value.
>
> On Mon, Nov 18, 2002 at 08:30:13PM +0100, Alex Dovlecel wrote:
> > Hello all
> > If this is too trivial... sorry. :o(((
> >
> > I have created a table with the following command:
> >
> > CREATE TABLE ROUTE
> > (
> > ID SERIAL ,
> > START DATE ,
> > PRIMARY KEY ( ID )
> > ) ;
> >
> > And it worked just fine. But if I call:
> > INSERT INTO ROUTE VALUES(10, '10/10/1999') ;
> > it ads a record but the id is 10. Is this the correct behaviour for the
> > SERIAL type? I was hoping it will be 1 and ignore the one that I set.
> >
> > If this is the normal behaviour, how can I make it ignore the 10 and place
> > the next id?
> >
> > Tx
> > dovle
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 3: if posting/reading through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo@postgresql.org so that your
> > message can get through to the mailing list cleanly
>
> --
> Dror Matalon
> Zapatec Inc
> 1700 MLK Way
> Berkeley, CA 94709
> http://www.zapatec.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org