DELETE

You can delete records in the table by using the DELETE statement. You can specify delete conditions by combining the statement with the WHERE Clause. You can delete one table with one DELETE statement.

DELETE [FROM] table_name [ WHERE <search_condition> ] [LIMIT row_count]
  • table_name: Specifies the name of a table where the data to be deleted is contained. If the number of table is one, the FROM keyword can be omitted.
  • search_condition: Deletes only data that meets search_condition by using WHERE Clause. If it is specified, all data in the specified tables will be deleted.
  • row_count: Specifies the number of records to be deleted in the LIMIT Clause. An integer greater than 0 can be given.

If you want to delete one table, LIMIT Clause can be specified. You can limit the number of records by specifying the LIMIT Clause.  If the number of records satisfying the WHERE Clause exceeds row_count, only the number of records specified in row_count will be deleted.

Note

From CUBRID 9.0, it allows delete query with join.

CREATE TABLE a_tbl(
    id INT NOT NULL,
    phone VARCHAR(10));
INSERT INTO a_tbl VALUES(1,'111-1111'), (2,'222-2222'), (3, '333-3333'), (4, NULL), (5, NULL);

--delete one record only from a_tbl
DELETE FROM a_tbl WHERE phone IS NULL LIMIT 1;
SELECT * FROM a_tbl;
           id  phone
===================================
            1  '111-1111'
            2  '222-2222'
            3  '333-3333'
            5  NULL
--delete all records from a_tbl
DELETE FROM a_tbl;