[postgis-users] new ogc field

Obe, Regina robe.dnd at cityofboston.gov
Tue Oct 2 04:50:33 PDT 2007


Temiz,

Don't quite understand your question.  Don't you have that field already
or you mean you want to add data to that column or you want to know how
to create in the future?  If you want to add data, you can directly
update the field.  The default value gets put in if you don't have an
explicit update or insert on that field.

The ogc_fid_seq is just a serial field AKA auto number put in by I think
OGR2OGR.

To add a serial field - you would simply do something like this

ALTER TABLE sometable ADD ogc_fid serial

where ogc_fid is the name of the new field.  The above will
automatically create the new field, create a sequence object for the new
field and set the defualt value to the nextval of the sequence.

In PostgreSQL you can default a value of any integer field to the next
value of any sequence which is what nextval(some sequence object) does.
Nextval returns the next integer in the sequence.

So you could even do something like
SELECT nextvalue('sel10p4_ogc_fid_seq');

To cache the value and force an increment.

Or do 
SELECT currval('sel10p4_ogc_fid_seq');
To get the last assigned value

 The nice thing about that is that you can use the same sequence object
for multiple tables so that your primary keys can be unique across
multiple tables which is immensely handy in numerous scenarios
especially for inventory comes to mind.

If you want to create sequences alone separate from a table - you would
do something like

CREATE SEQUENCE mynewseq
  INCREMENT 1
  MINVALUE 1
  START 1
;


Hope that helps,
Regina


-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
temiz
Sent: Tuesday, October 02, 2007 2:19 PM
To: postgis-list
Subject: [postgis-users] new ogc field

hello

how can I make this column ?

ogc_fid      | integer           | not null default 
nextval('sel10p4_ogc_fid_seq'::regclass)

regards

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

-----------------------------------------
The substance of this message, including any attachments, may be
confidential, legally privileged and/or exempt from disclosure
pursuant to Massachusetts law. It is intended
solely for the addressee. If you received this in error, please
contact the sender and delete the material from any computer.




More information about the postgis-users mailing list