Search Postgresql Archives

Re: how do you set foriegn keys in pgaccess?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

              http://archives.postgresql.org

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux