Help Center/
GaussDB/
Developer Guide(Distributed_V2.0-3.x)/
Development and Design Proposal/
Database Programming Specifications/
UPDATE
Updated on 2025-03-13 GMT+08:00
UPDATE
- [Specification] In GTM-free mode, cross-node transactions are not allowed. Therefore, when updating a data table distributed by hash, you must specify the equal condition in the WHERE condition for the distribution keys.
- [Rule] The UPDATE statement must contain the WHERE clause to avoid full table scan.
- [Rule] Do not use the updated columns as the update source when the UPDATE clause updates multiple columns simultaneously.
Even if multiple columns are updated simultaneously from the same source, the behavior varies depending on the database. To avoid compatibility issues, avoid the preceding operations at the service layer. Example:
UPDATE table SET col1 = col2, col3 = col1 WHERE col1 = 1;
In , the value of col3 is the original value of col1. In MySQL, the value of col3 is the value of col2 (because the value of col2 is assigned to col1).
- [Rule] Do not use ORDER BY or GROUP BY in the UPDATE statement to avoid unnecessary sorting.
- [Recommendation] If a table has a primary key or index, the WHERE condition must be used together with the primary key or index during update.
Parent topic: Database Programming Specifications
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot