【问题标题】:MSACCESS - How to add a primary key using a query make tableMS ACCESS - 如何使用查询生成表添加主键
【发布时间】:2020-09-11 21:24:19
【问题描述】:

我有一个使用此 SQL 的查询生成表:

SELECT DISTINCT tblStore.Position, tblStore.Branch, tblStore.Location, tblStore.Operator INTO tblAllPositions
FROM tblStore
WHERE (((tblStore.Position) Is Not Null))
ORDER BY tblStore.Position, tblStore.Branch, tblStore.Location;

我想在新表tblAllPositions 中添加一个名为ID_Positions 的字段并将其设置为主键自动编号。

我该怎么做?

【问题讨论】:

    标签: sql ms-access select-into


    【解决方案1】:

    考虑:

    ALTER TABLE tblAllPositions 
    ADD COLUMN ID_Positions COUNTER, 
    CONSTRAINT PrimaryKey PRIMARY KEY (ID_Positions)
    

    在查看 https://docs.microsoft.com/en-us/office/client-developer/access/desktop-database-reference/data-definition-language 上的 ALTER TABLE 和 CREATE TABLE 教程后,我构建了该 SQL

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-17
      • 2011-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多