Thread: how do you set foriegn keys in pgaccess?

how do you set foriegn keys in pgaccess?

From
"jeremy `"
Date:
I am a bit of a newbie to postgres, but I managed to install 8.0.4 on my
windows box and it mostly appears to be working fine;
I can set a primary key constraint, but when i try to set the foreign key it
requires a 'reference' - but there is nothing there to chose from.

I also have another query:
How do you export the database tables and relationships etc? I found a
pg_dump command in help and I am guessing this I what i need but where do I
enter this command in pgaccess?

Also how do you input existing SQL script into postgres?

Thanks for any help.
Jeremy

_________________________________________________________________
Become a fitness fanatic @  http://xtramsn.co.nz/health


Re: how do you set foriegn keys in pgaccess?

From
Richard Huxton
Date:
jeremy ` wrote:
> I am a bit of a newbie to postgres, but I managed to install 8.0.4 on my
> windows box and it mostly appears to be working fine;
> I can set a primary key constraint, but when i try to set the foreign
> key it requires a 'reference' - but there is nothing there to chose from.
>
> I also have another query:
> How do you export the database tables and relationships etc? I found a
> pg_dump command in help and I am guessing this I what i need but where
> do I enter this command in pgaccess?
>
> Also how do you input existing SQL script into postgres?

Well, pg_dump and psql are command-line tools that are very flexible
parts of your toolkit. They are described quite extensively in the
manuals, and these should have been installed as HTML on your system.

Also - are you sure you're using pgaccess and not pgadmin - both are
graphical tools for PG, but I though pgadmin was installed by default on
Windows.

--
   Richard Huxton
   Archonet Ltd

Re: how do you set foriegn keys in pgaccess?

From
Changyu Dong
Date:
Hi, Jeremy,
Have you tried PGadminIII? It's much easier to use.
To input a script, you can use psql
psql -h HOSTNAME -d DANAME -f FILENAME -U USERNAME

Changyu

--- jeremy ` <norman1nz@hotmail.com> wrote:

> I am a bit of a newbie to postgres, but I managed to
> install 8.0.4 on my
> windows box and it mostly appears to be working
> fine;
> I can set a primary key constraint, but when i try
> to set the foreign key it
> requires a 'reference' - but there is nothing there
> to chose from.
>
> I also have another query:
> How do you export the database tables and
> relationships etc? I found a
> pg_dump command in help and I am guessing this I
> what i need but where do I
> enter this command in pgaccess?
>
> Also how do you input existing SQL script into
> postgres?
>
> Thanks for any help.
> Jeremy
>
>
_________________________________________________________________
> Become a fitness fanatic @
> http://xtramsn.co.nz/health
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 8: explain analyze is your friend
>




__________________________________
Discover Yahoo!
Find restaurants, movies, travel and more fun for the weekend. Check it out!
http://discover.yahoo.com/weekend.html


Re: how do you set foriegn keys in pgaccess?

From
Richard Huxton
Date:
Don't forget to cc: the list.

jeremy ` wrote:
> yea sory I an using pgadmin3, and thats the prog that I'm not sure how
> to set foriegn keys with.

OK - to make a foreign key where bar.foo_ref references foo.foo_id you
should do the following:
1. Select table "bar" then "constraints"
2. Right-click and choose a new foreign-key
3. Give the foreign-key a name "my_first_foreign_key"
4. Drop down "references" to choose table "foo"
5. Click the "Columns" tab at the top of the dialogue-box
6. Choose local column = "foo_ref" and referenced = "foo_id"
7. Click the "Add" button
8. Click the "Action" tab and choose whether to restrict/cascade
9. Click OK

You should now see a new constraint on table bar, forcing "foo_ref" to
refer to values from table "foo" column "foo_id".

> What do I use for 'command line' features? do i need a separate program
> to pgadmin?

See the manuals - "client applications", they're all installed already.
I use psql almost exclusively. There I'd type something like:
   ALTER TABLE bar ADD CONSTRAINT my_first_constraint
   FOREIGN KEY (foo_ref) REFERENCES foo (foo_id)
   ON UPDATE RESTRICT ON DELETE RESTRICT;

--
   Richard Huxton
   Archonet Ltd