Lab-Lecture-week-06(2)
Lab-Lecture-week-06(2)
New row
“…insert a new row
DEPT
into DEPT table…”
DEPTNO DNAME LOC
------ ---------- --------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS DEPT
30 SALES CHICAGO DEPTNO DNAME LOC
40 OPERATIONS BOSTON ------ ---------- --------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
50 DEVELOPMENT
5 DETROIT
The INSERT Statement
• Add new rows to a table by using the INSERT statement.
1 row created.
Copying Rows
from Another Table
• Write your INSERT statement with a subquery.
SQL> INSERT INTO managers(id, name, salary, hiredate)
2 SELECT empno, ename, sal, hiredate
3 FROM emp
4 WHERE job = 'MANAGER';
3 rows created.
EMP
EMPNO ENAME JOB ... DEPTNO
UPDATE table
SET column = value [, column = value, ...]
[WHERE condition];
• All rows in the table are deleted if you omit the WHERE
clause.