# Database.AlterKey(KeyRef, Boolean) Method
> Version: _Available or changed with runtime version 13.0._
Alter a table's key in SQL, either disabling or enabling it. Any alteration only pertains to the current transaction and will be reverted at the end of the current transaction. Any alteration will fail if it's called on System or non-SQL based tables. Disabling clustered or unique keys is also not supported and will fail at runtime.
> NOTE
> This method is supported only in Business Central on-premises.
## Syntax
```al
 Database.AlterKey(KeyRef: KeyRef, Enable: Boolean)
```
> NOTE
> This method can be invoked without specifying the data type name.
## Parameters
KeyRef
Type: ../keyref/keyref-data-type
A keyref of the key to alter.
Enable
Type: ../boolean/boolean-data-type
Whether to enable or disable a key. Keys that are created as disabled cannot be enabled.
## Related information
database-data-type
Getting Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/database/database-alterkey-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/database/database-alterkey-method/
