Re: PostgreSQL Syntax questions

From: Ben <bench(at)silentmedia(dot)com>
To: krishtpt <raman(dot)krishnan(at)tenth-planet(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PostgreSQL Syntax questions
Date: 2008-06-12 23:27:09
Message-ID: Pine.LNX.4.64.0806121622120.3347@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 12 Jun 2008, krishtpt wrote:

> 1. I am trying to disable constraints from a particular table in postgresql.
> But I couldn't get the alter command for the same.

The documentation is generally pretty good, if you know what you're
looking for. At what point in reading

http://www.postgresql.org/docs/8.3/interactive/sql-altertable.html

do you get confused?

> 2. I am trying to fetch all the constraints from a specific table using a
> select query. I am using 'select * from pg_constraint'. If I execute this
> query I am able to get all the constraints from all the tables. But I
> couldn't find which constraint is for what table. How can I get this data.
> 3. I am also trying to fetch all the triggers for a specific table using a
> select query. How can I get this data?

In psql, you can issue a command like:

\d <tablename>

...which will give you all the columns, their types, any indices, foreign
keys, triggers, etc. for <tablename>. This sounds like what you're looking
for?

> 4. I also would like to know how can I execute an sql file from windows
> command prompt in postgresql.

Again, psql is probably your friend. I'm not familiar with windows, but I
believe it allows redirection in the command prompt. In unix, you would:

psql <connection args> < file.sql

... and everything in file.sql would be executed as if you had typed it in
yourself.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ben 2008-06-12 23:29:33 Re: understanding a nested query
Previous Message Stephen Denne 2008-06-12 22:24:14 Re: Win32 8.3.3 install fail (sufficient privileges to install system services).