Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Interfaces Pgadmin Support > Re: For the PG ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 2051 of 2085
Post > Topic >>

Re: For the PG experts

by Erwin Brandstetter <brsaweda@[EMAIL PROTECTED] > Jun 28, 2008 at 08:50 AM

On Jun 16, 3:34=A0pm, jul...@[EMAIL PROTECTED]
 (Julius Tuskenis) wrote:
> Hi Laurent.
>
> As I understand where is no direct link between sequence and the table
> column. You should see pg_attrdef table.
> Query SELECT =A0pg_get_expr(adbin,adrelid) =A0FROM pg_attrdef; will
retur=
n
> you all default values of the columns. Among them you will find
> nextval('your_sequence'::regclass).
>
> Hope that helps...


Right, or more precisely, to get the default for your primary key
column
   myschema.mytab.mycol
use:

SELECT pg_catalog.pg_get_expr(d.adbin, d.adrelid)
  FROM pg_catalog.pg_attrdef d
  JOIN pg_catalog.pg_attribute a ON d.adrelid =3D a.attrelid AND d.adnum
=3D a.attnum
  JOIN pg_catalog.pg_class c ON c.oid =3D a.attrelid
  JOIN pg_catalog.pg_namespace n ON n.oid =3D c.relnamespace
WHERE n.nspname =3D 'myschema' AND c.relname =3D 'mytab' AND a.attname =3D
'mycol'
ORDER BY a.attnum

Gives you something like:
   nextval('mytab_mycol_seq'::regclass)
The quotet part being the sequence in use.

Where do I get this? Try psql -E  and work from there. (Shows the
queries psql uses to retrieve its data.)


But all of this is hardly on topic here. Please turn to
   pgsql.admin (pgsql-admin(at)postgresql(dot)org)
or
   pgsql.general (pgsql-general(at)postgresql(dot)org)


Regards
Erwin
 




 3 Posts in Topic:
For the PG experts
laurent_roche@[EMAIL PROT  2008-06-16 05:36:27 
Re: For the PG experts
julius@[EMAIL PROTECTED]   2008-06-16 16:34:20 
Re: For the PG experts
Erwin Brandstetter <br  2008-06-28 08:50:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Aug 21 23:27:02 CDT 2008.