Deleting Data from a Table
Outdated data may need to be deleted when tables are used. Data can be deleted from tables only by row.
SQL statements can only access and delete an independent row by declaring conditions that match the row. If a table has a primary key, you can use it to specify a row. You can delete several rows that match the specified condition or delete all the rows from a table.
For example, to delete all the rows whose c_customer_sk column is 3869 from the table customer_t1, run the following command:
1
|
openGauss=# DELETE FROM customer_t1 WHERE c_customer_sk = 3869; |
To delete all rows from the table, run either of the following commands:
1
|
openGauss=# DELETE FROM customer_t1; |
Or
1
|
openGauss=# TRUNCATE TABLE customer_t1; |
If you need to delete an entire table, you are advised to use the TRUNCATE statement rather than DELETE.
To delete a table, run the following command:
1
|
openGauss=# DROP TABLE customer_t1; |
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.
For any further questions, feel free to contact us through the chatbot.
Chatbot