Deleting a table v17

You can remove rows from a table using the DELETE command. For example, the following sequence of commands shows the before and after results of deleting all employees in department 20.

SELECT ename, deptno FROM emp;
Output
 ename  | deptno
--------+--------
 SMITH  |     20
 ALLEN  |     30
 WARD   |     30
 JONES  |     20
 MARTIN |     30
 BLAKE  |     30
 CLARK  |     10
 SCOTT  |     20
 KING   |     10
 TURNER |     30
 ADAMS  |     20
 JAMES  |     30
 FORD   |     20
 MILLER |     10
(14 rows)
DELETE FROM emp WHERE deptno = 20;

SELECT ename, deptno FROM emp;
Output
 ename  | deptno
--------+--------
 ALLEN  |     30
 WARD   |     30
 MARTIN |     30
 BLAKE  |     30
 CLARK  |     10
 KING   |     10
 TURNER |     30
 JAMES  |     30
 MILLER |     10
(9 rows)
Warning

Be careful when giving a DELETE command without a WHERE clause such as the following:

DELETE FROM tablename;

This statement removes all rows from the given table, leaving it completely empty. The system doesn't request confirmation before doing this.