Understanding DML statements
Data Manipulation Language (DML) statements are used to manipulate data in existing tables. INSERT, UPDATE
, and DELETE
are examples of DML statements. We use INSERT
to add a new record to the table, UPDATE
to modify one or more columns of a table, and DELETE
to remove a record from the table.
The following is an example of an INSERT
statement. We insert a new record in the regions
table of the HR schema:
SQL> INSERT INTO regions VALUES (5, 'Australia'); 1 row created. SQL> COMMIT; Commit complete. SQL>
An example of the UPDATE
statement is shown next, where we modify the value of region_name
from Australia
to Aus and NZ
. This is done as follows:
SQL> UPDATE regions SET region_name = 'Aus and NZ' Where region_id = 5; 1 row updated. SQL> COMMIT; Commit complete. SQL>
The following is an example of the DELETE
statement. We remove the newly added record from the regions
table as follows:
SQL> DELETE FROM regions Where region_id = 5; 1 row deleted...