Google Groupes n'accepte plus les nouveaux posts ni abonnements Usenet. Les contenus de l'historique resteront visibles.

multiple field primary key in Access 2003?

1 vue
Accéder directement au premier message non lu

Joe

non lue,
21 janv. 2005, 22:08:4021/01/2005
à
I have a table with a student id and course id. I would like to make
both fields the primary key since a student can have multiple course
ids but I do not want duplicate records.

How would I go about creating the multiple field PK in Access 2003?
Thanks!

MGFoster

non lue,
21 janv. 2005, 22:18:5721/01/2005
à
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Easiest:

1) Open the table in design view.
2) Drag over the record selectors (square blocks to the left of the
column name) of the 2 columns you want as PKs; or, hold down Ctrl &
click the record selectors of the columns you want as PKs.
3) On the main menu click Edit > Primary Key.
4) Close & Save the table.
a) If there is duplicate data in the PK columns you will not be able
to save the new table design.

SQL DDL:

ALTER TABLE table_name
ADD CONSTRAINT PK_table_name (StudentID, CourseID)

Put the above in a Query's SQL view & run it. Number 4), above,
applies: the DDL statement will fail.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQfHGNYechKqOuFEgEQJ8VgCbB/eeBdagCUjEQG/jR+J1snlAwQIAoPt7
cd/TKbAKgkv7dM4eREPoNy75
=ygN8
-----END PGP SIGNATURE-----

0 nouveau message