Help Center/ GaussDB(DWS)/ Troubleshooting/ Database Use/ An Error Is Reported When Data Is Inserted or Updated, Indicating that the Distribution Key Cannot Be Updated
Updated on 2024-01-25 GMT+08:00

An Error Is Reported When Data Is Inserted or Updated, Indicating that the Distribution Key Cannot Be Updated

Symptom

An error is reported when data is inserted or updated, indicating that the distribution key cannot be updated. The following is the error message:

1
ERROR: Distributed key column can't be updated in current version

Possible Causes

The GaussDB(DWS) distribution key cannot be updated.

Handling Procedure

Method 1: The distribution key cannot be updated. Ignore the error.

Method 2: Change the distribution column to a column that cannot be updated. (In versions later than 8.1.0, the distribution column can be changed.) For example:

  1. Query the table definition. The command output shows that the distribution column of the table is c_last_name.

    1
    SELECT pg_get_tabledef('customer_t1');
    

  2. Try updating data in the distribution column. An error message will be displayed.

    1
    UPDATE customer_t1 SET c_last_name = 'Jimy' WHERE c_customer_sk = 6885;
    

  3. Change the distribution column of the table to a column that cannot be updated, for example, c_customer_sk.

    1
    ALTER TABLE customer_t1 DISTRIBUTE BY hash (c_customer_sk); 
    

  4. Update the data in the old distribution column.

    1
    UPDATE customer_t1 SET c_last_name = 'Jimy'WHERE c_customer_sk = 6885;