ashkufaraz
ashkufaraz

Reputation: 5297

set two field primary key

table1


id1 ==> number

id2 ==> number


id want id1 contain uniqe number and id2 contain unique number.

how can set id1 and id2 primary key?

Upvotes: 12

Views: 55588

Answers (1)

XIVSolutions
XIVSolutions

Reputation: 4502

In the Table Designer, Select both rows, and then click the Primary Key button in the Toolbar.

OR, open the Query Designer, change the view to SQL View, and type the following code:

ALTER TABLE your_table_name ADD CONSTRAINT your_pk_name PRIMARY KEY(id1, id2);

Then, hit the run button. This will create a Primary key which includes both of those fields.

If you are asking about having an Auto-incrementing integer field in both columns, you can't. You would have to do that programmatically. Access (and most other db's) only allow one "autonumber" field per table.

Upvotes: 24

Related Questions