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:
- Query the table definition. The command output shows that the distribution column of the table is c_last_name.
1select pg_get_tabledef('customer_t1');

- Try updating data in the distribution column. An error message will be displayed.
1update customer_t1 set c_last_name = 'Jimy' where c_customer_sk = 6885;

- Change the distribution column of the table to a column that cannot be updated, for example, c_customer_sk.
1alter table customer_t1 DISTRIBUTE BY hash (c_customer_sk);

- Update the data in the old distribution column.
1update customer_t1 set c_last_name = 'Jimy' where c_customer_sk = 6885;

Last Article: Database Use
Next Article: "Connection reset by peer" Is Displayed When a User Executes an SQL Statement
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.