You can execute the DELETE statement to delete records from a table.

Syntax

DELETE FROM table_name
[ WHERE condition ]        

Precautions

  • The table on which you execute the DELETE statement must have a primary key.
  • You cannot use the alias of a table to execute the DELETE statement.
  • If you need to delete all records or all partitions from a table, we recommend that you use the TRUNCATE TABLE or TRUNCATE PARTITION statement, instead of the DELETE statement.

Example

  • Delete the record where name is Alex from the customer table.
    DELETE FROM customer WHERE customer_name='Alex';                  
  • Delete the records where age is less than 18 from the customer table.
    DELETE FROM customer WHERE age<18;