设置两个字段主键

发布于 2024-12-14 06:38:43 字数 137 浏览 4 评论 0原文


1 id1 ==>编号

id2 ==>编号


id 希望 id1 包含唯一编号,id2 包含唯一编号。

如何设置id1和id2主键

table1


id1 ==> number

id2 ==> number


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

how can set id1 and id2 primary key?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨落□心尘 2024-12-21 06:38:43

在表设计器中,选择两行,然后单击工具栏中的主键按钮。

或者,打开查询设计器,将视图更改为 SQL 视图,然后键入以下代码:

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

然后,单击运行按钮。这将创建一个包含这两个字段的主键。

如果您询问是否在两列中都有自动递增整数字段,则不能。您必须以编程方式执行此操作。 Access(以及大多数其他数据库)只允许每个表有一个“自动编号”字段。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文