[SQL] Primary key reference count

2006-04-19 Thread Wiebe Cazemier
Hi,

I'm trying to find which of the tables in pg_catalog contains the amount of
references to a primary key, but I can't seem to find it. Google queries are
also less than successful. Is it even stored in the catalog? 


---(end of broadcast)---
TIP 4: Have you searched our list archives?

   http://archives.postgresql.org


Re: [SQL] Primary key reference count

2006-04-19 Thread A. Kretschmer
am  19.04.2006, um 14:01:03 +0200 mailte Wiebe Cazemier folgendes:
> Hi,
> 
> I'm trying to find which of the tables in pg_catalog contains the amount of
> references to a primary key, but I can't seem to find it. Google queries are
> also less than successful. Is it even stored in the catalog? 

Yes,
http://www.postgresql.org/docs/8.1/interactive/catalog-pg-constraint.html


HTH, Andreas
-- 
Andreas Kretschmer(Kontakt: siehe Header)
Heynitz:  035242/47215,  D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===Schollglas Unternehmensgruppe=== 

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


Re: [SQL] Primary key reference count

2006-04-19 Thread Wiebe Cazemier
On Wednesday 19 April 2006 15:09, A. Kretschmer wrote:

> Yes,
> http://www.postgresql.org/docs/8.1/interactive/catalog-pg-constraint.html

Either I'm blind, or this is not what I'm looking for. I need to know the
amount of references _to_ a primary key. If you have a customer with two
orders and one invoice, the reference count for the primary key of the
custormer would be 3.

I need to know if I can delete rows which are not referenced anywhere, without
catching the relational constraint exception. The reason I can't catch the
exception, is that I want the exception to arrive at my application and/or
tests.


---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


Re: [SQL] Primary key reference count

2006-04-19 Thread Wiebe Cazemier
On Wednesday 19 April 2006 15:33, Wiebe Cazemier wrote:

> Either I'm blind, or this is not what I'm looking for. I need to know the
> amount of references _to_ a primary key. If you have a customer with two
> orders and one invoice, the reference count for the primary key of the
> custormer would be 3.
> 
> I need to know if I can delete rows which are not referenced anywhere,
> without catching the relational constraint exception. The reason I can't
> catch the exception, is that I want the exception to arrive at my application
> and/or tests.

Never mind. I found another solution.


---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


Re: [SQL] Primary key reference count

2006-04-19 Thread Wiebe Cazemier
On Wednesday 19 April 2006 17:00, Wiebe Cazemier wrote:

> Never mind. I found another solution.

Whoops. Posted to quickly there. I do still need to know the amount of
references to the primary key.


---(end of broadcast)---
TIP 1: if posting/reading through Usenet, please send an appropriate
   subscribe-nomail command to [EMAIL PROTECTED] so that your
   message can get through to the mailing list cleanly


Re: [SQL] Primary key reference count

2006-04-19 Thread Volkan YAZICI
On Apr 19 02:01, Wiebe Cazemier wrote:
> I'm trying to find which of the tables in pg_catalog contains the amount of
> references to a primary key, but I can't seem to find it.

Here's simple query, to list which table's which columns references to a
specific table. (Hope this is what you asked for.)

SELECT TBL.table_name, COL.column_name
FROM information_schema.referential_constraints AS REF
INNER JOIN information_schema.table_constraints AS TBL
   USING (constraint_name)
INNER JOIN information_schema.constraint_column_usage AS COL
   USING (constraint_name)
INNER JOIN information_schema.table_constraints AS PRI
   ON (PRI.constraint_name = REF.unique_constraint_name)
WHERE PRI.table_name = 'pri_id'; -- Your target table goes here.

This is a quick & dirty hack. Just wanted to show the possibility of the
idea using information schema. (You don't want to deal with internal
tables, ain't?)


Regards.

---(end of broadcast)---
TIP 5: don't forget to increase your free space map settings


[SQL] Field length ??

2006-04-19 Thread Louise Catherine
I've this table :create table test(]satu char(10),dua char(5));How could I get the Field length not the Data length ?Thanks,Rina
		Love cheap thrills? Enjoy PC-to-Phone  calls to 30+ countries for just 2¢/min with Yahoo! Messenger with Voice.

[SQL] Programatically Backup Database Using Visual Basic

2006-04-19 Thread Christian Paul B. Cosinas
Hi is there a way wherein I can interface the pg_dump of PostgreSQL Server
in Visual basic.

I mean for example I want to backup Databases "DB1", "BD12", "DB3" using
pg_dump

Thank You,
Ian


I choose Polesoft Lockspam to fight spam, and you?
http://www.polesoft.com/refer.html


---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


Re: [SQL] Programatically Backup Database Using Visual Basic

2006-04-19 Thread Josh Berkus
Paul,

> Hi is there a way wherein I can interface the pg_dump of PostgreSQL Server
> in Visual basic.
>
> I mean for example I want to backup Databases "DB1", "BD12", "DB3" using
> pg_dump

You'd have to run them as shell commands in VB.  Not sure if VB has a 
mechanism for that.

-- 
Josh Berkus
Aglio Database Solutions
San Francisco

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


Re: [SQL] Field length ??

2006-04-19 Thread Louise Catherine
Hi ,With this table :create table test(satu char(10),dua char(5));To get the field length, I use this query:select atttypmod from pg_attribute where attname='satu' and attrelid=(select oid from pg_class where relname='test');---> result 1 : 14select atttypmod from pg_attribute where attname='dua' and attrelid=(select oid from pg_class where relname='test');---> result 2 : 9 Could anyone explain, why the field length must be add by 4 :result 1 : 10 + 4 =14result 2 : 5 + 4 = 9Could I use this query ? Is it valid?select atttypmod-4 from pg_attribute where  attname='satu' and  attrelid=(select oid from pg_class where relname='test');Thank's,Rina 
		How low will we go? Check out Yahoo! MessengerÂ’s low  PC-to-Phone call rates.