oracle- introduction to sql commands- mazenet solution

10
INTRODUCTION TO SQL Prepared by Ravichandiran Senior Oracle Trainer

Upload: mazenetsolution

Post on 13-Apr-2017

116 views

Category:

Education


4 download

TRANSCRIPT

Page 1: Oracle- Introduction to Sql commands- Mazenet solution

INTRODUCTION TO SQL

Prepared by Ravichandiran

Senior Oracle Trainer

Page 2: Oracle- Introduction to Sql commands- Mazenet solution

WHY MAZENET?

• Oracle Certified Partner & more than 10+ years experienced Trainers.

• Oracle unique id for students• E-kits from Oracle University• Course Completion Certificate from Oracle University.• Flexible timing for working professionals.• Preparing candidates to face interview and free resume

preparation.

Page 3: Oracle- Introduction to Sql commands- Mazenet solution

COMMANDS

DDL - DATA DEFINITION LANUGAGE

DML - DATA MANIPULATION LANGUAGE

TCL - TRANSACTION CONTROL LANGUAGE

DCL - DATA CONTROL LANGUAGE

DRL - DATA RETRIEVAL LANGUAGE

Page 4: Oracle- Introduction to Sql commands- Mazenet solution

DDL

• Used to create or modify the structure of the table.

• Auto commit occurs. Changes cannot be rolled back.

• Session independent commands.

• Commands are :

CREATE, ALTER DROP, TRUNCATE, RENAME

Page 5: Oracle- Introduction to Sql commands- Mazenet solution

DDL - CREATE

SYNTAXcreate table <tab_name>(col1 datatype(size),col2 datatype(size),........................coln datatype(size));

EXAMPLE

Create table emp

(

empno number(5),

ename varchar2(20),

job varchar2(20)

);

Page 6: Oracle- Introduction to Sql commands- Mazenet solution

DDL - ALTERADD• ALTER TABLE EMP ADD

DOJ DATE;

• ALTER TABLE EMP ADD ( SALARY NUMBER(5), COMM NUMBER(4), DEPTNO NUMBER(3));

MODIFY• ALTER TABLE EMP ADD

DOJ DATE;

• ALTER TABLE EMP ADD ( SALARY NUMBER(5), COMM NUMBER(4), DEPTNO NUMBER(3));

Page 7: Oracle- Introduction to Sql commands- Mazenet solution

DDL - ALTER

DROP COLUMN

• ALTER TABLE EMP DROP COLUMN DEPTNO;

• ALTER TABLE EMP DROP(DOJ,COMM);

RENAME COLUMN

• ALTER TABLE EMP RENAME COLUMN EMPNO TO ENO;

Page 8: Oracle- Introduction to Sql commands- Mazenet solution

DDL - DROP

TABLE DROPPED

• DROP TABLE EMP;• DROP TABLE EMP

PURGE;• PURGE RECYCLEBIN;• PURGE TABLE EMP;

FLASHBACK COMMAND

• Flashback table emp to before drop;

• Flashback table emp to before drop rename to employees;

Page 9: Oracle- Introduction to Sql commands- Mazenet solution

DDL - TRUNCATE

• Used to remove records from table.• Cannot delete single row alone• Changes are permanent. So deleted record cannot

be rolled back.

TRUNCATE TABLE EMP;

Page 10: Oracle- Introduction to Sql commands- Mazenet solution

DDL - RENAME

• Used to rename the table.

RENAME <OLD_TABLE_NAME> TO <NEW_TAB_NAME>;RENAME EMP TO EMPLOYEES;