[GRASSLIST:255] Re: [GRASS5] Built-in vector documentation extended
Thomas Adams
Thomas.Adams at noaa.gov
Mon Mar 20 09:19:57 EST 2006
Markus,
Thanks for your help and suggestions. I discussed the matter with
someone in my office (Mark Fenbers) who is fairly adept with database
systems, in general, and PostgreSQL, in particular. He suggested that we
create a "View" which allows one to create *essentially* a virtual
table, combining elements from one or many tables. Thus:
CREATE OR REPLACE VIEW /my_table_new /AS SELECT oid AS uid,* FROM
/my_table/;
Parts in red are optional. Parts in italics are to be replaced with the
name of your table. This uses the /oid/ as the required integer field,
which, in this example, was named /uid/ as a new column in the VIEW.
Consequently, v.in.db would use table=/my_table_new / and key=/uid/.
The advantage to using a VIEW, is that any changes to /my_table /will be
reflected automatically in /my_table_new/. So, only one table needs to
be maintained. I have tested this in GRASS 6.1cvs and it works
perfectly. The problem I was having is that I could NOT alter the
original table and I needed a solution to the problem that accounted for
dynamic changes to the table I was reading.
Regards,
Tom
Markus Neteler wrote:
> On Mon, Mar 20, 2006 at 08:55:52AM +0100, Markus Neteler wrote:
>
>> I had some troubles recently to use OID (that's why I removed this hint
>> from the manual
>> page). Maybe this is better?
>>
>> ALTER TABLE mytable ADD id integer;
>> CREATE SEQUENCE mytabe_seq;
>> UPDATE mytabe SET id= nextval('mytable_seq');
>> SELECT * from mytable;
>>
>>
>
> added to
>
> http://grass.itc.it/grass61/manuals/html61_user/pg.html
>
> Markus
>
>
>
--
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177
EMAIL: thomas.adams at noaa.gov
VOICE: 937-383-0528
FAX: 937-383-0033
More information about the grass-user
mailing list