Обсуждение: OID question

Поиск
Список
Период
Сортировка

OID question

От
Jacques Huard
Дата:
   I have used MySQL to do several database related things in the past
using PHP.  In the past I have used a field "row_id" as a unique number
(within that specific table) as a reference to a specific row.  This
"row_id" field  was automatically placed in a table when it was created
in MySQL and the next unique number was placed in the field when
automatically during every new insert.  This made things easy for
writing applications in PHP.  When I switch to Postgres I noticed that
there was a OID.  I believe that this "object identifier" is similar to
the "row_id" in MySQL but I am unable to access it for an given row.
PHP has a function which can get the last OID for the last "Insert"
issued, however, this won't help me accomplish the same things I was
able to accomplish using "row_id" in MySQL.  I have read the
documetation and have not found a real good description of OID but have
found commands that can add a unique sequence column which could
accomplish what I need.  However,  I need (or want) the unique sequence
column to maintain itself, without calling a function to fill in that
field during an insert.  I am sure there is an easy way to accomplish
this and I am overlooking the solution.  Could someone suggest what they
have done?  Thanks for any response.

   Jacques Huard  jacques@_no_spam_intuineer.com




Re: OID question

От
Ed Loehr
Дата:
Jacques Huard wrote:
> 
> ...I need (or want) the unique sequence
> column to maintain itself, without calling a function to fill in that
> field during an insert...

Try using the SERIAL type.
http://www.postgresql.org/docs/faq-english.html#4.16.1

Regards,
Ed Loehr