This statement will copy all records from table “EMPLOYEE_DTL” to “EMPLOYEE_DTL_COPY”.

INSERT INTO EMPLOYEE_DTL_COPY SELECT * FROM EMPLOYEE_DTL;

Update Statements:

Update statements are used to update records with/without conditions. The following example uses a condition in where clause. Update statements can be committed to the database by using explicit “commit” command or it can be rolled back by using “rollback” command.

UPDATE EMPLOYEE_DTL SET DPTMT_NUM=20 WHERE EMP_DTL_ID=2;

Delete Statements:

Delete statements are used to delete records with/without conditions. The following example uses some condition in where clause. Delete statements can be committed to the database by using explicit “commit” command or it can be rolled back by using “rollback” command.

DELETE FROM EMPLOYEE_DTL WHERE EMP_DTL_ID=2;

Select all rows:

Select statements are used to retrieve records from the database with/without conditions. Select statements are the most powerful commands, which you have to learn since you can avoid unnecessary “PLSQL” in many cases.

SELECT * FROM EMPLOYEE_DTL;

Select rows by using a WHERE clause:

SELECT * FROM EMPLOYEE_DTL WHERE EMP_DTL_ID=1;

Select few columns:

SELECT EMP_DTL_ID, FRST_NM, SLRY_AMT FROM EMPLOYEE_DTL WHERE

SSN=’123-45-67′;

Select records by Sorting (ASC = ascending and DESC = descending):

SELECT * FROM EMPLOYEE_DTL ORDER BY EMP_DTL_ID ASC;

SELECT * FROM EMPLOYEE_DTL ORDER BY EMP_DTL_ID DESC;

Select records by Grouping and Having clause:

SELECT DPTMT_NUM, COUNT(DPTMT_NUM) FROM EMPLOYEE_DTL GROUP BY DPTMT_NUM;

SELECT DPTMT_NUM, COUNT(DPTMT_NUM) FROM EMPLOYEE_DTL GROUP BY DPTMT_NUM HAVING COUNT(DPTMT_NUM) > 1;

SELECT DPTMT_NUM, COUNT(DPTMT_NUM) FROM EMPLOYEE_DTL GROUP BY DPTMT_NUM HAVING COUNT(DPTMT_NUM) < 2;

Select records by using a Sub Query:

SELECT * from EMPLOYEE_DTL WHERE DPTMT_NUM IN(SELECT DPTMT_NUM FROM DEPARTMENT_LKP WHERE DPTMT_DESC=’IT’);