.alter table policy roworder command
Applies to: ✅ Microsoft Fabric ✅ Azure Data Explorer
Use this command to change a table's row order policy. The row order policy is an optional table policy that defines the row order in an extent (data shard). This policy can improve performance for queries that relate to a small set of values that can be ordered.
Permissions
You must have at least Table Admin permissions to run this command.
Syntax
.alter
table
TableName policy
roworder
(
SortKey (asc
| desc
) [,
...])
Learn more about syntax conventions.
Parameters
Name | Type | Required | Description |
---|---|---|---|
TableName | string |
✔️ | The name of the table. |
SortKey | string |
✔️ | The column by which to sort the data in the extent. |
Tip
We recommend using a maximum of two sort keys. For more information, see Performance considerations.
Examples
Set the row order policy for one table
.alter table events policy roworder (TenantId asc, Timestamp desc)
Set the row order policy for several tables
.alter tables (events1, events2, events3) policy roworder (TenantId asc, Timestamp desc)
The following example sets the row order policy on the TenantId
column (ascending) as a primary key, and on the Timestamp
column (ascending) as the secondary key. The policy is then queried.
.alter table events policy roworder (TenantId asc, Timestamp desc)
.alter tables (events1, events2, events3) policy roworder (TenantId asc, Timestamp desc)
.show table events policy roworder
TableName | RowOrderPolicy |
---|---|
events | (TenantId asc, Timestamp desc) |