db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Hughes <mhu...@uvic.ca>
Subject Re: autoincrement in PostgreSQL
Date Thu, 11 Nov 2004 19:23:50 GMT
Alik Kurdjukov wrote:
> Hello!
> 
> I found that autoincrement flag on the column is ignored in PostgreSQL 
> backend. 

Hi, I've been using PostgreSQL 7 for a long time with Torque, and this 
schema snippet generates auto incrementing primary keys:

<database name="laser">

   <table name="Form" idMethod="native">
     <column name="Form_ID" type="INTEGER" required="true" 
primaryKey="true"/>
     <column name="title" type="VARCHAR" size="255"/>
     <column name="idcolumn" type="VARCHAR" size="255"/>
     ...
    </table>
</database>

Output SQL:
DROP TABLE Form;
DROP SEQUENCE Form_SEQ;

CREATE SEQUENCE Form_SEQ;

CREATE TABLE Form
(
                                     Form_ID integer DEFAULT 
nextval('Form_SEQ') NOT NULL,
                                     title varchar (255),
                                     idcolumn varchar (255),
					....
     PRIMARY KEY (Form_ID)
);


While it doesn't use SERIAL, it has the same effect. The idMethod has to 
be set to native for this to work (I believe).

-- 
  Matt Hughes
   + mhughe@uvic.ca

---------------------------------------------------------------------
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