Received: from webcon.net (guru.webcon.net [216.187.106.140]) by postgresql.org (Postfix) with ESMTP id 53CE247590F for ; Thu, 25 Apr 2002 13:04:30 -0400 (EDT) Received: from light.int.webcon.net (light.int.webcon.net [192.168.1.1]) by webcon.net (8.11.6/8.11.6) with ESMTP id g3PH4QS29807; Thu, 25 Apr 2002 13:04:27 -0400 Date: Thu, 25 Apr 2002 13:04:22 -0400 (EDT) From: Ian Morgan To: bob lapique Cc: pgsql-sql@postgresql.org Subject: Re: How to discover foreign keys (without pulling hair out) In-Reply-To: Message-ID: Organization: "Webcon, Inc." MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200204/312 X-Sequence-Number: 7576 On Thu, 25 Apr 2002, bob lapique wrote: > I use pgAdminII on Windows. It connects to a PostgreSQL on a Linux PC. > When you click on an existing table's icon, it shows you a script that > could have created it (it detects the structure of the table by itself), > including the foreign keys. That's an easy way. But maybe not very > elegant... I have in fact tried that very thing. pgAdminII has a Log View that is supposed to show all the back-end SQL that it executes in order to show you what it does. However, all it really does is retrieve the pg_triggers.tgargs field, which is 6 fields separated by \0's, then it must parse it internally. I'm looking for a way to parse 'one\000two\000three\000'::bytea into foo1 | foo2 | foo3 ------+------+------- one | two | three using only (Postgre)SQL, no external C functions or the like. Ideas? I'm looking into PL/pgSQL as a solution, but haven't gotten very far yet. Regards, Ian Morgan -- ------------------------------------------------------------------- Ian E. Morgan Vice President & C.O.O. Webcon, Inc. imorgan@webcon.net PGP: #2DA40D07 www.webcon.net * Customized Linux network solutions for your business * -------------------------------------------------------------------