Thread: Two very basic questions..

Two very basic questions..

From
Colm McCartan
Date:
Hello all,

I don't see either of these in the faq or docs... Very basic:

- how do I see details of the various constraints (e.g foreign keys)  in
psql client? Am I looking at a system-table query?
- Er, what can I use as a comment character in a sql file? Multiple
hashmarks seem to cause parse errors

Cheers and apologies if I've missed these in the docs,
colm


Re: Two very basic questions..

From
Einar Karttunen
Date:
On 05.12.01 13:00 +0000(+0000), Colm McCartan wrote:
> Hello all,
>
> I don't see either of these in the faq or docs... Very basic:
>
> - how do I see details of the various constraints (e.g foreign keys)  in
> psql client? Am I looking at a system-table query?
Yes, all the data is in system tables.
The developers manual has info on the contents of the system tables:
http://www.postgresql.org/idocs/index.php?catalogs.html
You can also try using psql -E to see what queries the
\*-commands (eg. \dv) generate.

> - Er, what can I use as a comment character in a sql file? Multiple
> hashmarks seem to cause parse errors

You can have two kinds of comments:
-- single line comments
/* and
multiline comments */

- Einar Karttunen

Re: Two very basic questions..

From
Martijn van Oosterhout
Date:
On Wed, Dec 05, 2001 at 01:00:38PM +0000, Colm McCartan wrote:
> - Er, what can I use as a comment character in a sql file? Multiple
> hashmarks seem to cause parse errors

Standard SQL comments, two hyphens. Like "--".

I'm sure this is mentioned somewhere...

HTH,
--
Martijn van Oosterhout <kleptog@svana.org>
http://svana.org/kleptog/
> Terrorists can only take my life. Only my government can take my freedom.

Re: Two very basic questions..

From
Colm McCartan
Date:
Thanks for the responses. Heres a summary:

>>- how do I see details of the various constraints (e.g foreign keys)  in
>>psql client? Am I looking at a system-table query?
>>
> Yes, all the data is in system tables.
> The developers manual has info on the contents of the system tables:
> http://www.postgresql.org/idocs/index.php?catalogs.html
> You can also try using psql -E to see what queries the
> \*-commands (eg. \dv) generate.

Probably the most useful source on this is the link I found on the
Non-FAQ technical docs for postgres:

http://techdocs.postgresql.org/redir.php?link=/techdocs/hackingreferentialintegrity.php

This points out that foreign keys are just specialised constraints and
gives a few useful queries and views for inspecting and altering them.


>>- Er, what can I use as a comment character in a sql file? Multiple
>>hashmarks seem to cause parse errors
>>
>
> You can have two kinds of comments:
> -- single line comments
> /* and
> multiline comments */
>
> - Einar Karttunen


Thanks again.

colm


Re: Two very basic questions..

From
missive@frontiernet.net (Lee Harr)
Date:
> - how do I see details of the various constraints (e.g foreign keys)  in
> psql client? Am I looking at a system-table query?

Most of this can be seen with
\d tableName

(also see \? for more psql backslash commands)

though I don't think foreign keys are shown.
I am not exactly sure how to get that information,
but you might try searching the mailing list
archives.

> - Er, what can I use as a comment character in a sql file? Multiple
> hashmarks seem to cause parse errors

-- this is a comment

(I believe this is an SQL standard)