Skip to navigation

Change a Sigma table primary key (Beta)

View as Markdown

This documentation describes one or more public beta features that are in development. Beta features are subject to quick, iterative changes; therefore the current user experience in the Sigma service can differ from the information provided in this page.

This page should not be considered official published documentation until Sigma removes this notice and the beta flag on the corresponding feature(s) in the Sigma service. For the full beta feature disclaimer, see Beta features.

When you create a local Sigma table, Sigma automatically generates a new Id text column and uses it as the default primary key. This column contains system-generated key values that uniquely identify each row in the table so Sigma can find rows to update or delete when you edit data.

To identify rows using your own data, you can change the primary key to a single text column or multiple text columns that form a composite key.

This page explains how to change the primary key of a local Sigma table. For information about local Sigma tables and how to create them, see Create local Sigma tables. For general information about Sigma tables, see Sigma tables overview.

Sigma tables are currently supported by Snowflake, Databricks, and PostgreSQL connections.

Requirements

To change the primary key of a Sigma table:

  • The table must be a local Sigma table. You cannot change the primary key of an organization-wide table.
  • You must be the owner of the Sigma table (Can own access).

Change the primary key

Choose a column with values that are unique, not null, and stable over time, such as store ID. Avoid dates, timestamps, row numbers, and calculated values that can repeat or change.

When no single column uniquely identifies each row, select multiple columns to create a composite key. For example, store ID might repeat across regions, but the region and store code together identify exactly one store.

  1. Open the workbook draft that contains the local Sigma table.

  2. Select the local Sigma table element, then open the Properties panel to view the data source. A Local table badge displays next to the source name.

  3. Click the down arrow () next to the data source name, then select Change primary key column(s) in the menu.

    The Properties panel for a local Sigma table, with the Local table badge next to the data source name and the data source menu open to the Change primary key column(s) option
  4. In the modal, click the Select the new primary key column(s) field.

  5. In the dropdown, select the checkbox next to each column you want to use as the primary key. Clear the checkbox next to any column you want to remove from the key.

    The dropdown shows all columns in the Sigma table, but you can select only text columns. Other column types cannot be used as the primary key.

    The Change primary key modal with the column dropdown open, showing the Id, Store ID, Region ID, and Store name text columns, with Store ID and Region ID selected
  6. Sigma checks for duplicate and null values in the primary key:

    • If Sigma detects duplicate or null values, select different columns or resolve the issue before attempting to change the primary key.
    • If Sigma detects no duplicate or null values, the primary key is valid. Click Save.
    The Change primary key modal with Store ID and Region ID selected as the new primary key columns, a message that no duplicate or null values were detected, and the Cancel and Save buttons

    Sigma changes the primary key in your data platform and locks the local Sigma table to prevent edits while the change is in progress. If Sigma completes the primary key change but you still cannot edit the table, refresh the page and continue editing the data.