Search Postgresql Archives

Re: OID Usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alvaro Herrera wrote:

You can create a function to get the sequence name attached to a table.
Of course, you should take into account the fact that there could be
more than one (two serial fields in a table are rare but not
impossible), but if your tables have only one sequence you should be OK.


Are there a way to find and test if it is a primary key ?

Something with

select relname, relkind
from pg_depend join pg_class on (oid = objid)
where pg_depend.refobjid = 'foo'::regclass
and relkind = 'S';


Hmm, need to play more around using the "pg_" system tables.

Are they all well documentet, or need I some guessing ?

(only lightly tested). Then you can use that to construct your argument
to the nextval() function.


:-)

This doesn't happen with sequences on Postgres. The value you get is
guaranteed to be the one the sequence generated for you.


I know, and this is one of the reasons for not using MySQL :-)

/BL

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux