다음을 통해 공유


Keys Collection

Microsoft SQL Server의 이후 버전에서는 이 기능이 제거됩니다. 새 개발 작업에서는 이 기능을 사용하지 않도록 하고, 현재 이 기능을 사용하는 응용 프로그램은 수정하십시오.

The Keys collection contains Key objects that reference referential integrity declarations that are implemented by Microsoft SQL Server PRIMARY KEY and FOREIGN KEY constraints.

현재 개체를 보여 주는 SQL-DMO 개체 모델

Properties

주의

With the Keys collection, you can:

  • Implement key-based referential integrity by creating SQL Server PRIMARY KEY and FOREIGN KEY constraints.

  • Remove key-based referential integrity.

For more information about using the Keys collection to create SQL Server PRIMARY KEY and FOREIGN KEY constraints, see "Key Object" in this volume.

To remove a SQL Server constraint implementing key-based referential integrity

  • Use the Remove method of the Keys collection, as in:

    oTable.Keys.Remove("FK_Order_Details_Products")
    

When using the Item or Remove method, the Keys collection supports member identification using either name or ordinal reference syntax. For example:

Set oKey = oTable.Keys("PK_Order_Details")

Or:

Set oKey = oTable.Keys(2)

[!참고]

Creating or removing SQL Server constraints implementing key-based referential integrity by using the Keys collection requires appropriate privilege. The SQL Server login used for SQLServer object connection must be a member of the fixed role db_ddladmin or a role with greater privilege.