【发布时间】:2009-10-30 10:16:41
【问题描述】:
我想从访问表中删除一个作为主键的列。 我该如何为此编写查询。
【问题讨论】:
标签: ms-access
我想从访问表中删除一个作为主键的列。 我该如何为此编写查询。
【问题讨论】:
标签: ms-access
您需要在一个查询中首先删除表上的主键索引:
DROP INDEX PrimaryKey ON Table1
然后您可以在第二个查询中删除该列:
ALTER TABLE Table1 DROP COLUMN id
【讨论】:
您可以通过多种方式获取索引的名称。
Dim RS As ADODB.Recordset
Set RS = CurrentProject.Connection.OpenSchema _
(12, Array(Empty, Empty, Empty, Empty, "Table1")) ''12=adSchemaIndexes
RS.Filter = "PRIMARY_KEY = True"
If Not RS.EOF Then
Debug.Print RS.Fields("Index_Name")
End If
End Sub
更多What is the name of the violating unique index constraint in dao / ms-access
【讨论】: