set two field primary key

跟風遠走 提交于 2019-12-10 02:23:11

问题


table1


id1 ==> number

id2 ==> number


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

how can set id1 and id2 primary key?


回答1:


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.



来源:https://stackoverflow.com/questions/8022332/set-two-field-primary-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!