| From: | Richard Huxton <dev(at)archonet(dot)com> |
|---|---|
| To: | jeremy ` <norman1nz(at)hotmail(dot)com>, List <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: how do you set foriegn keys in pgaccess? |
| Date: | 2005-06-10 10:03:37 |
| Message-ID: | 42A96579.2070108@archonet.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Huxton | 2005-06-10 10:16:43 | Re: [SQL] Permission denied for language pltclu |
| Previous Message | Dinesh Pandey | 2005-06-10 09:51:46 | Re: [SQL] Permission denied for language pltclu |