db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject Re: Serial type in Postgresql
Date Wed, 23 Nov 2005 09:19:45 GMT





Hi,

you can always altar the table to have a default value of the serial.
>From the postgresql documentation:

CREATE TABLE tablename (
    colname SERIAL
);


is equivalent to specifying:





CREATE SEQUENCE tablename_colname_seq;
CREATE TABLE tablename (
    colname integer DEFAULT nextval('tablename_colname_seq') NOT NULL
);





So you can alter your tables to have the default values as above, and you
have your serial back.

The decision not to support both sequences and serial any more was made
before my time, so I can only guess what the reasons were: Implicitly, both
is the same, so one supported way should be enough. And then, creating
sequences in a hidden manner is not good style in my opinion. For example,
as far as I know, they are not dropped automatically if the table is
dropped, so garbage remains. And finally, it is less confusing: If it is a
sequence, it should look like a sequence.

    Thomas


Jakub Piechnik <piechutm@wp.pl> schrieb am 22.11.2005 23:16:50:

> Hi
>
> When I'm using pg_Admin3 Query and try to do INSERT when there is a
> sequence on table I have to put the field value explicitly. When there
> is a serial field - the values is automaticly incremented and put into
> column - it's far more useful as autoIncrement and required set as true
> in schema file. It was working good with 3.1.1 version and PostreSQL
> database
>
> Greetings
> Jakub
>
> Thomas Fischer napisaƂ(a):
>
> > As I understand it, a serial field is just a normal field with a
> > default value fed by a sequence. So I do not see a difference between
> > sequenes and serial fields. What can you do with serials which you
> > cannot do with sequences ?
> >
> > Thomas
> >
> >
> > On Fri, 18 Nov 2005, Jakub Piechnik wrote:
> >
> >> Hello
> >>
> >> I was using Torque 3.1.1 with Postgresql 8.0. In a schema file when I
> >> put idMethoad as native and set field as type = "INTEGER",
> >> required="true", autoInceremt ="true" in created sql file that fields
> >> was mentioned as serial fields - why is that not working in Torque
> >> 3.2.-rc2? (Normal INTEGER fields are created with sequence - but
> >> serial fields are more usefull)
> >>
> >> Greetings
> >> Jakub Piechnik
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> >> For additional commands, e-mail: torque-user-help@db.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: torque-user-help@db.apache.org
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message