View on GitHub

Notes

reference notes

Data Manipulation Language

A DML statement is executed when you:

INSERT Statement Syntax

Add new rows to a table by using the INSERT statement:

INSERT INTO table[(column [, column...])]
VALUES (value [, value...]);

With this syntax, only one row is inserted at a time.

Inserting a new row

Inserting Rows with Null Values

Inserting Special Values

The SYSDATE function records the current date and time.

INSERT INTO employees (employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, commission_pct, manager_id, department_id)
VALUES (113, 'Louis', 'Popp', 'LPOPP', '515.124.4567', SYSDATE, 'AC_ACCOUNT', NULL, 205, 110);

Inserting Specific Date and Time Values

Creating a Script

Copying Rows from Another Table

UPDATE Statement Syntax

Modify existing values in a table by using the UPDATE statement:

UPDATE table
SET column = value [, column = value...]
[WHERE condition];

Updating Rows in a Table

Updating Two Columns with a Subquery

Update employee 113’s job and salary to match those of employee 205.

UPDATE employees
SET (job_id, salary) = (SELECT job_id, salary
FROM employees
WHERE employee_id = 205)
WHERE employee_id = 113;

DELETE Statement Syntax

You can remove existing rows from a table by using the DELETE statement:

DELETE [FROM] table
[WHERE condition];

Deleting Rows from a Table

TRUNCATE Statement