Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: problem adding a foreign key in v1.5 and a question re v1.5 vs


  • From: Miha Radej <miha(dot)radej(at)siix(dot)com>
  • To: "'pgadmin-support(at)postgresql(dot)org'" <pgadmin-support(at)postgresql(dot)org>
  • Subject: Re: problem adding a foreign key in v1.5 and a question re v1.5 vs
  • Date: Fri, 11 Nov 2005 16:53:57 +0100
  • Message-id: <4374BE95.6090405@siix.com> <text/plain>

hi!

the foreign key problem seems to come from using an incorrect schema name. ie. in a database i am using i have a few schemas. i am working on one of them and when selecting a referencing table all table names are displayed as 'schema.tablename' except the tables from the current schema i'm working on, where just the form 'tablename' is used. and pgadmin3 appears to use the public schema if no schema seems to be specified, which then returns no columns.

ie: i am working on a schema called 'myschema' and i select a table 'tablename' as a referenced table. pgadmin generates the following query to retrieve the column names from a newly selected table:
SELECT attname
          FROM pg_attribute att, pg_class cl, pg_namespace nsp
         WHERE attrelid=cl.oid AND relnamespace=nsp.oid
           AND nspname='public'
           AND relname='tablename'
           AND attnum > 0

         ORDER BY attnum

instead of
SELECT attname
          FROM pg_attribute att, pg_class cl, pg_namespace nsp
         WHERE attrelid=cl.oid AND relnamespace=nsp.oid
           AND nspname='myschema'
           AND relname='tablename'
           AND attnum > 0

         ORDER BY attnum

regards,
Miha



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group