SlideShare a Scribd company logo
Oracle 11g - SQL
Date Document Version V 1.0
Original Date:
Last Revision Date:
Document Revision History
Date Version Section/Page Update Description Contact Name
20.06.2012 V 1.0 Initial document Prathap Narayanappa
References
Document Title Description Owner Location
Copied
Table of Contents
1. Overview………………………………………………………………………………………………………………………………….. 3
2. Oracle – SQL.…………………………………………………………………………………………………………………………….. 3
2.1 Classification of SQLStatements………………………………………………………………………………. 3
2.1.0 Data Types………………………………………………………………………………………………………………..4
VARCHAR2
NUMBER (P,S)
DATE
2.1.1 DDL Statements……………………………………………………………………………………………….. ……..5
CREATE
ALTER
DROP
TRUNCATE
See also (FLASHBACK, RENAME, PURGE, COMMENT, UNDROP, ANALYZE, AUDIT, NOAUDIT, ASSOCIATE
STATISTICS, DISASSOCIATE STATISTICS)
2.1.2 DML Statements……………………………………………………………………….. …………………………….
INSERT
UPDATE
DELETE
MERGE
See also (CALL, EXPLAIN PLAN, LOCK TABLE)
2.1.3 DRL Statements…………………………………………………………………………………………………………
SELECT
2.1.4 TCL Statements…………………………………………………………………………………………………………..
COMMIT
ROLLBACK
SAVEPOINT
SET TRANSACTION
2.1.5 DCL Statements………………………………………………………………………………………………………….
GRANT
REVOKE
2.1.6 Session ControlStatements ……………………………………………………………………………………….
ALTER SESSION
SET ROLE
2.1.7 SystemControl Statements……………………………………………………………………………………….
ALTER SYSTEM
3. Constraints………………………………………………………………………………………………………………………………….
NOT NULL
UNIQUE
PRIMARY KEY
FOREIGN KEY -ON DELETE CASCADE-ON DELETE SET NULL
CHECK
4. Joins…………………………………………………………………………………………………………………………………………….
ANSI (SQL-1999 Standards) JOINS - Types
ORACLE JOINS - Types
5. Set Operators……………………………………………………………………………………………………………………………..
UNION
UNION ALL
MINUS
INTERSECT
6. Clauses…………………………………………………………………………………………………………………………………………
GROUP BY
HAVING
WHERE
DISTINCT
ORDER BY - ASC , DESC
7. SQLExpressions and Operators……………………………………………………………………………………………………
Arithmeticoperators
Comparisonoperators
BETWEEN Operator
Logical Operators
OtherOperators
8. SQLFunctions……………………………………………………………………………………………………………………………….
Character Functions - case conversionfunctions
Character Functions - charactermanipulationfunctions
NumericFunctions
Date Functions
Aggregate Functions
General Functions
Conditional Functions
ConversionFunctions
9. Sub query, Co-Related Sub query, Exist Clause…………………………………………………………………………………
Single rowsubquery
Multiple row subquery
Correlatedsubquery
Multiple Columnsubquery
EXISTS
10. Views, Inline Views and Materialized Views………………………………………………………………………………….
Views – types -Simple Views -Complex Views
Inline View
Materialized View
11. Indexes, Synonym, Dblink, Backup Copies………………………………………………………………………………………
Indexes - types
Sequence - (nextval, currval)
Synonym - Types - Private,-Public
Dblink
Backup Copies
12. Miscellaneous Functions………………………………………………………………………………………………………………
RANK
DENSE RANK
PIVOT
IDENTITY, @@IDENTITY,SCOPE_IDENTITY, IDENT_CURRENT
CAST -(SQL 92), CONVERT
ACID PROPERTIES
ROLLUP
CUBE
COUNT_BIG
BINARY_CHECKSUM
CHECKSUM_AGG
LOCAL TEMPORARY TABLE/ GLOBAL TEMPORARY TABLE
1. Overview
This document provides simplified and detailed level of information with examples about Oracle - SQL
(including 11g new features) based on the syllabus of 11g Oracle SQL - Exam 1Z0-051.
2. Oracle and SQL
Oracle is a Database, which is developed by Oracle Corporation.
Organizations can store data on various media and in different formats, such as hard copy document in a
filing cabinet or data stored in electronic spreadsheets or in databases.
A Database is an organized collection of information.
To manage databases, you need Database Management Systems (DBMS). A DBMS is a program that stores,
retrieves and modifies data in the database on request. There arefour main types of databases: Hierarchical,
Network, Relational and Object relational (ORDBMS).
SQL
SQL (Structured Query Language) is a simple computer language used to create, access, and manipulate the
data and structure in relational Databases.
2.1 Classification of SQLStatements
DDL (Data Definition Language)
 CREATE
 ALTER
 DROP
 TRUNCATE
Refer also (FLASHBACK, RENAME, PURGE, COMMENT, UNDROP, ANALYZE, AUDIT, NOAUDIT, ASSOCIATE
STATISTICS, DISASSOCIATE STATISTICS)
DML (Data Manipulation Language)
 INSERT
 UPDATE
 DELETE
 MERGE
Refer also (CALL, EXPLAIN PLAN, LOCK TABLE)
DQL or DRL (Data Querying Language or Data Retrieval Language)
 SELECT
DCL (Data Control Language)
 GRANT
 REVOKE
TCL (Transaction Control Language)
 COMMIT
 ROLLBACK
 SAVEPOINT
 SET TRANSACTION
Session Control Statements
 ALTER SESSION
 SET ROLE
System Control Statement
 ALTER SYSTEM
2.1.0 Data types
 VARCHAR2 (length) – Alpha numeric type of data can be stored, length range 1 to 60 can be specified
 NUMBER (P,S) – Number values can be stored, Number having precision P can range1 to 38, scale S
can range -84 to 127
 DATE – Valid date range can be stored
refer also
 (NUMBER - NUMBER (p),NUMBER (S), FLOAT [(P)] )
 (DATE - TIMESTAMP[fractional_seconds_precision], INTERVAL YEAR TO MONTH, INTERVAL DAY TO
SECOND)
 (CHARACTER - CHAR, VARCHAR, VARCHAR2, LONG, NCHAR(n), NVARCHAR2(n),)
 (BINARY - RAW, LONGRAW)
 (BLOB, CLOB, NCLOB, BFILE, ROWID, UROWID(n) )
2.1.1 DDL (Data Definition Language)Statements
DDL statements areused to build and modify the structure of tables and other objects in the Database.
 CREATE – to create tables and other objects
Syntax > CREATE TABLE table_name (column_name1 data_type,column_name2 data_type,column_name3
data_type,....);
Example> CREATE TABLE EMP (EMPNO NUMBER, ENAME VARCHAR2(20), DEPTNO NUMBER, JOB
VARCHAR2(15), MGR NUMBER, HIREDATE DATE, SAL NUMBER, COMM NUMBER)
 ALTER – to alter tables and other objects
Syntax>
>ALTER TABLE EMP RENAME TO EMP_NEW; to rename table name
>ALTER TABLE EMPADD (MAILID VARCHAR2(25)); to add new column into table
>ALTER TABLE EMP DROP COLUMN MAILID; to remove existing column from table
>ALTER TABLE EMP MODIFY MAILID NUMBER; to change datatype of a column
>ALTER TABLE EMP RENAME COLUMN MAILID TO EMAILID; torename a column name
>ALTER TABLE EMP ADD PRIMARY KEY (EMPNO); to add primary key
>ALTER TABLE EMP ADD CONSTRAINT UK1_EMP UNIQUE (EMAILID); to add unique constraint
>ALTER TABLE EMP MODIFY COMM DEFAULT 10; to modify values of a column
>ALTER TABLE EMP MODIFY EMAILID VARCHAR2 (30); to increase & decrease length of a column
>ALTER TABLE EMP MODIFY SAL NOT NULL; to make a column not null constraint
>ALTER TABLE EMP DROP PRIMARY KEY; to remove primary key
>ALTER TABLE EMP READ ONLY; to make table read only access
 DROP – to delete tables and other objects
Syntax> DROP TABLE <TABLE_NAME>;
>DROP TABLE EMP;
 TRUNCATE – to delete data in a table permanently
Syntax> TRUNCATE TABLE <TABLE_NAME>;
>TRUNCATE TABLE EMP;
refer also
(FLASHBACK, RENAME, PURGE, COMMENT, UNDROP, ANALYZE, AUDIT, NOAUDIT, ASSOCIATE STATISTICS,
DISASSOCIATE STATISTICS)
2.1.2 DML (Data Manipulation Language)Statements
DML statements are used to maintain and managedata within tables.
 INSERT – to insert data into tables
Syntax> INSERT INTO table_name VALUES (value1, value2, value3,...);
> INSERT INTOtable_name (column1, column2, column3,...)VALUES (value1, value2, value3,...);
 UPDATE – to update (modify) existing data in tables
Syntax> UPDATE table_name SET column1=value, column2=value2,...WHERE some_column=some_value ;
 DELETE – to delete data from tables
Syntax> DELETE FROM table_name ;
> DELETE FROM table_name WHERE some_column=some_value ;
 MERGE – to perform insert and update in a single statement.
Syntax>
Example>
Refer also (CALL, EXPLAIN PLAN, LOCK TABLE)
The CALL and EXPLAIN PLAN statements are supported in PL/SQL only when executed dynamically. All other
DML statements are fully supported in PL/SQL.
2.1.3 DRL (Data Retrieval Language)Statement
DRL statement is used to read data from tables.
 SELECT - to retrieve data from tables
Syntax> SELECT column_name(s)FROM table_name ;
> SELECT * FROM table_name;
> SELECT * FROM EMP ;
> select * from all_objects where object_type='TABLE' ;
2.1.4 TCL (Transaction ControlLanguage)Statements
 COMMIT – saves the work done
Commit is of two types -
-Implicit Commit : This will be issued by Oracle internally, When DDL is performed.
-Explicit Commit : This will be issued by user.
 ROLLBACK - restore the database to original since the last COMMIT
Rollback will be applied in two methods -
-Upto Previous Commit
-Upto Previous Rollback
 SAVEPOINT – saves the work done up to some point. Used with Rollback.
 SET TRANSACTION -
 Locking Mechanism -
2.1.5 DCL (Data Control Language)Statements
DCL statements areused for access control in the Database.
 GRANT – gives access privileges to users for database
 REVOKE – withdraws access privileges to users for database
Use the GRANT or REVOKE statement to give privileges to a specific user or role, or to all
users, to perform actions on database objects. These privileges can be any combination of select,
insert, update, delete, references, alter, and index. Below is an explanation of what each privilege
means.
Privilege Description
Select Ability to query the table with a select statement.
Insert Ability to add new rows to the table with the insert statement.
Update Ability to update rows in the table with the update statement.
Delete Ability to delete rows from the table with the delete statement.
References Ability to create a constraint that refers to the table.
Alter Ability to change the table definition with the alter table statement.
Index Ability to create an index on the table with the create index statement.
2.1.6 Session ControlStatements
Session control statements dynamically managethe properties of a user session. These statements do not
implicitly commit the current transaction. PL/SQL does not support session control statements.
• ALTER SESSION
> alter session set current_schema = <schemaname> ;
> alter session set optimizer_mode = <mode> ;
• SET ROLE
> SET TIME ZONE
> SET SESSION AUTHORIZATION
> SET SESSION CHARACTERISTICS
2.1.7 SystemControl Statements
 ALTER SYSTEM - dynamically manages the properties of an Oracle Databaseinstance. This statement
does not implicitly commit the current transaction and is not supported in PL/SQL.
Syntax> alter system kill session 'session-id, session-serial' ;
> alter system checkpoint ;
> alter system kill session 'session-id, session-serial' ;
> Alter system archive log [start, stop, all, ...] ;
3. CONSTRAINTS
Constraintsare the rulesdefinedinoracle tablestoimplementdataintegrity.These rulescanbe
placed for each column i.e, at column level, or at the end of the column prototypingi.e, table level.
Wheneveranyactionisdone onthe table,these rules are invokedandraise exceptionupon
violation.
 NOT NULL
 UNIQUE
 PRIMARY KEY
 FOREIGN KEY
 CHECK
 NOT NULL - isusedto restrictNULL valuesina columnof a table.
 UNIQUE - Unique constraintensuresthatthe columnvaluesare distinct,withoutany duplicates.
The columnsof the table withunique constraintare calledunique key.The null able columnswith
unique constraintscancontainNULLS. Unique Constraintcanbe imposedonmultiplecolumns
also(composite uniquekey).
 PRIMARY KEY - ishybrid constraintevolvedfromfunctionalcombinationof NOTNULLandUNIQUE
constraints.The columnsof the table enforcedunderprimarykeyare restrictedfromNULLSand
Duplicate values.
FewkeypointsonPrimaryKey
-A Table can have onlyone primarykey
-Multiple columnscanbe clubbedundercomposite primarykey
-Oracle internallycreatesuniqueindex topreventduplicationinthe columnvalues
 FOREIGN KEY - If primarykeyof one table takespart in anothertable thenitiscalled foreign key,
the table withprimarykeyiscalledparenttable andtable withforeignkeyiscalledchildtable.
-ON DELETE CASCADE
-ON DELETE SET NULL
 CHECK - usedtolimitthe value range thatcan be placedina column.
4. Joins
 ANSISQL-1999 Standards
JOINS–types
1) Natural Join
-joinwithUSINGclause
-joinwithON clause
2) OuterJoin
-Leftouterjoin
-RightOuterJoin
-Full OuterJoin
3) Cross Join
 ORACLE JOINS
JOINS– types
1) InnerJoin(simple join),
-Equi Join
-NonEqui Join
-Self Join
2) OuterJoin
-LeftOuterJoin
-RightOuterJoin
-Full OuterJoin
3) CartesianProduct
5. SetOperators
 UNION
 UNION ALL
 MINUS
 INTERSECT
6. Clauses
 GROUP BY
 HAVING
 WHERE
 DISTINCT
 ORDER BY - ASC , DESC
7. SQL Expressionsand Operators
 Arithmeticoperators[ +, -, *, /, (),]
 Comparisonoperators(single rowandmultiple row operators)
-Equality( = )
-Inequalityoperator( >,< )
-Composite inequalityoperator( <=, >= )
 BETWEEN Operator( BETWEEN expression1ANDexpression2)
 Logical Operators (AND,OR,NOT)
 IN,NOT IN
 EXIST,NOT EXIST
 LIKE
 ESCAPEIdentifier
 IS NULL
 IS NOTNULL
 StringConcatenationoperators
 Literals
 Quote Operator(from10g onwards)
 NULL
 DESCRIBE
 Escape Identifier
 SubstitutionVariables( &), Double ampersandSubstitutionVariables( &&)
 Define andVerifyCommands
8. SQL Functions- (single row functions, multiple row functions)
-CharacterFunctions - case conversionfunctions
 INITCAP
 UPPER
 LOWER
-CharacterFunctions - character manipulationfunctions
 CONCAT
 LENGTH
 Padding(LPAD,RPAD)
 TRIM (RTRIM,LTRIM)
 INSTR
 SUBSTR
 REPLACE
-NumericFunctions
 ROUND
 TRUNC
 MOD
-Date Functions
 MONTHS_BETWEEN
 ADD_MONTHS
 NEXT_DAY
 LAST_DAY
 ROUND (DATE,format)
 TRUNC (DATE,format)
 GETDATE
 DATEDIFF
 DATEPART
 DATEADD
-Aggregate Functions
 COUNT
 SUM
 MAX
 MIN
 AVG
-General Functions
 NVL
 NVL2
 COALESCE
 ALIAS
 ROWNUM
 ROWID
-ConditionalFunctions
 DECODE
 CASE
-ConversionFunctions
 TO_CHAR - isusedto typecasta numericor date inputto character type
 TO_DATE - it takescharacter or numbervaluesandreturnsformatteddate equivalentof the same
 TO_NAUBER - thisfunctiontakescharacterinputsandreturnsnumberoutputaftersuitable
formatting
9. Sub Query,Co-relatedSub Queryand ExistClause
 Single rowsubquery
 Multiple rowsubquery
 Correlatedsubquery
 Multiple Columnsubquery
 EXISTS- thisoperatortestsfor existenceof rowsinthe resultsetof the sub query.
Syntax>
> SELECT DNAME FROM DEPT WHERE EXISTS(SELECT DEPT.DEPTNO= EMP.DEPTNO) ;
10. Views, Inline Views and Materialized Views
 Views - types
 Simple Views
 Complex Views
 Inline View-
 Materialized View-
11. Indexes, Synonym, Dblink, Backup Copies
 Indexes - types
-Unique Index
-Non-Unique Index
-Btree Index
-Bitmap Index
-Composite Index
-Function-based Index
-Cluster Index
 Sequence - (nextval, currval)
 Synonym -
Types -
-Private
-Public
 Dblink - to access tables or views or sequence from one database to another database.
Syntax>
Example> CREATE DATABASE LINK CAASEDW CONNECT TO ITO_ASA IDENTIFIED BY exact123 USING
'CAASEDW'
SQL> SELECT * FROM EMP@ CAASEDW ;
 Backup Copies -
12. Miscellaneous Functions & Terms
 RANK
 DENSE RANK
 PIVOT
 IDENTITY, @@IDENTITY,SCOPE_IDENTITY, IDENT_CURRENT
 CAST -(SQL 92), CONVERT
 ACID PROPERTIES
 ROLLUP
 CUBE
 COUNT_BIG
 BINARY_CHECKSUM
 CHECKSUM_AGG
 LOCAL TEMPORARY TABLE/ GLOBAL TEMPORARY TABLE
########################## SQL END ###########################
Ad

More Related Content

What's hot (20)

Sql and Sql commands
Sql and Sql commandsSql and Sql commands
Sql and Sql commands
Knowledge Center Computer
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 
Introduction to mysql part 1
Introduction to mysql part 1Introduction to mysql part 1
Introduction to mysql part 1
baabtra.com - No. 1 supplier of quality freshers
 
SQL commands
SQL commandsSQL commands
SQL commands
GirdharRatne
 
Mysql
MysqlMysql
Mysql
TSUBHASHRI
 
Sql 2009
Sql 2009Sql 2009
Sql 2009
Cathie101
 
Sql
SqlSql
Sql
Mona Visalakshi
 
Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL
Abdul Rehman
 
SQL
SQLSQL
SQL
Rajesh-QA
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
Sachidananda M H
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
MUHAMMED MASHAHIL PUKKUNNUMMAL
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
Vibrant Technologies & Computers
 
Sql commands
Sql commandsSql commands
Sql commands
Prof. Dr. K. Adisesha
 
Adbms
AdbmsAdbms
Adbms
jass12345
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
Shrija Madhu
 
Assignment#02
Assignment#02Assignment#02
Assignment#02
Sunita Milind Dol
 
SQL Tutorial - How To Create, Drop, and Truncate Table
SQL Tutorial - How To Create, Drop, and Truncate TableSQL Tutorial - How To Create, Drop, and Truncate Table
SQL Tutorial - How To Create, Drop, and Truncate Table
1keydata
 
Sql commands
Sql commandsSql commands
Sql commands
Pooja Dixit
 
Assignment#07
Assignment#07Assignment#07
Assignment#07
Sunita Milind Dol
 
8. sql
8. sql8. sql
8. sql
khoahuy82
 

Similar to Oracle 11g SQL Overview (20)

lovely
lovelylovely
lovely
love0323
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
EliasPetros
 
SQL2.pptx
SQL2.pptxSQL2.pptx
SQL2.pptx
RareDeath
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
DrRShaliniVISTAS
 
Group Members
Group MembersGroup Members
Group Members
Farhan Shahani
 
Database Management System (DBMS).pptx
Database Management System (DBMS).pptxDatabase Management System (DBMS).pptx
Database Management System (DBMS).pptx
GevitaChinnaiah
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
Sheethal Aji Mani
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
EliasPetros
 
Assignment#01
Assignment#01Assignment#01
Assignment#01
Sunita Milind Dol
 
Bank mangement system
Bank mangement systemBank mangement system
Bank mangement system
FaisalGhffar
 
SQL: Data Definition Language(DDL) command
SQL: Data Definition Language(DDL) commandSQL: Data Definition Language(DDL) command
SQL: Data Definition Language(DDL) command
sonali sonavane
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
Balqees Al.Mubarak
 
PO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - SqlPO WER - Piotr Mariat - Sql
PO WER - Piotr Mariat - Sql
Zespół Szkół nr 26
 
SQL_NOTES.pdf
SQL_NOTES.pdfSQL_NOTES.pdf
SQL_NOTES.pdf
AnshumanDwivedi14
 
SQL Query
SQL QuerySQL Query
SQL Query
Imam340267
 
CS3481_Database Management Laboratory .pdf
CS3481_Database Management Laboratory .pdfCS3481_Database Management Laboratory .pdf
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
COMPUTERS SQL
COMPUTERS SQL COMPUTERS SQL
COMPUTERS SQL
Rc Os
 
Sql queries
Sql queriesSql queries
Sql queries
sabapathi shanmugam
 
Mysql Ppt
Mysql PptMysql Ppt
Mysql Ppt
Hema Prasanth
 
BASIC_OF_DATABASE_PPT__new[1].pptx
BASIC_OF_DATABASE_PPT__new[1].pptxBASIC_OF_DATABASE_PPT__new[1].pptx
BASIC_OF_DATABASE_PPT__new[1].pptx
NiyatiMandaliya
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
EliasPetros
 
Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
DrRShaliniVISTAS
 
Database Management System (DBMS).pptx
Database Management System (DBMS).pptxDatabase Management System (DBMS).pptx
Database Management System (DBMS).pptx
GevitaChinnaiah
 
Relational Database Language.pptx
Relational Database Language.pptxRelational Database Language.pptx
Relational Database Language.pptx
Sheethal Aji Mani
 
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptxhjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
EliasPetros
 
Bank mangement system
Bank mangement systemBank mangement system
Bank mangement system
FaisalGhffar
 
SQL: Data Definition Language(DDL) command
SQL: Data Definition Language(DDL) commandSQL: Data Definition Language(DDL) command
SQL: Data Definition Language(DDL) command
sonali sonavane
 
CS3481_Database Management Laboratory .pdf
CS3481_Database Management Laboratory .pdfCS3481_Database Management Laboratory .pdf
CS3481_Database Management Laboratory .pdf
Kirubaburi R
 
COMPUTERS SQL
COMPUTERS SQL COMPUTERS SQL
COMPUTERS SQL
Rc Os
 
BASIC_OF_DATABASE_PPT__new[1].pptx
BASIC_OF_DATABASE_PPT__new[1].pptxBASIC_OF_DATABASE_PPT__new[1].pptx
BASIC_OF_DATABASE_PPT__new[1].pptx
NiyatiMandaliya
 
Ad

Recently uploaded (20)

IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Mike Mingos
 
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
CSUC - Consorci de Serveis Universitaris de Catalunya
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptxTop 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
Top 5 Benefits of Using Molybdenum Rods in Industrial Applications.pptx
mkubeusa
 
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Optima Cyber - Maritime Cyber Security - MSSP Services - Manolis Sfakianakis ...
Mike Mingos
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Everything You Need to Know About Agentforce? (Put AI Agents to Work)
Cyntexa
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Config 2025 presentation recap covering both days
Config 2025 presentation recap covering both daysConfig 2025 presentation recap covering both days
Config 2025 presentation recap covering both days
TrishAntoni1
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Ad

Oracle 11g SQL Overview

  • 1. Oracle 11g - SQL Date Document Version V 1.0 Original Date: Last Revision Date: Document Revision History Date Version Section/Page Update Description Contact Name 20.06.2012 V 1.0 Initial document Prathap Narayanappa References Document Title Description Owner Location Copied
  • 2. Table of Contents 1. Overview………………………………………………………………………………………………………………………………….. 3 2. Oracle – SQL.…………………………………………………………………………………………………………………………….. 3 2.1 Classification of SQLStatements………………………………………………………………………………. 3 2.1.0 Data Types………………………………………………………………………………………………………………..4 VARCHAR2 NUMBER (P,S) DATE 2.1.1 DDL Statements……………………………………………………………………………………………….. ……..5 CREATE ALTER DROP TRUNCATE See also (FLASHBACK, RENAME, PURGE, COMMENT, UNDROP, ANALYZE, AUDIT, NOAUDIT, ASSOCIATE STATISTICS, DISASSOCIATE STATISTICS) 2.1.2 DML Statements……………………………………………………………………….. ……………………………. INSERT UPDATE DELETE MERGE See also (CALL, EXPLAIN PLAN, LOCK TABLE) 2.1.3 DRL Statements………………………………………………………………………………………………………… SELECT 2.1.4 TCL Statements………………………………………………………………………………………………………….. COMMIT ROLLBACK SAVEPOINT SET TRANSACTION 2.1.5 DCL Statements…………………………………………………………………………………………………………. GRANT REVOKE 2.1.6 Session ControlStatements ………………………………………………………………………………………. ALTER SESSION SET ROLE 2.1.7 SystemControl Statements………………………………………………………………………………………. ALTER SYSTEM 3. Constraints…………………………………………………………………………………………………………………………………. NOT NULL UNIQUE PRIMARY KEY FOREIGN KEY -ON DELETE CASCADE-ON DELETE SET NULL CHECK 4. Joins……………………………………………………………………………………………………………………………………………. ANSI (SQL-1999 Standards) JOINS - Types ORACLE JOINS - Types 5. Set Operators…………………………………………………………………………………………………………………………….. UNION UNION ALL MINUS
  • 3. INTERSECT 6. Clauses………………………………………………………………………………………………………………………………………… GROUP BY HAVING WHERE DISTINCT ORDER BY - ASC , DESC 7. SQLExpressions and Operators…………………………………………………………………………………………………… Arithmeticoperators Comparisonoperators BETWEEN Operator Logical Operators OtherOperators 8. SQLFunctions………………………………………………………………………………………………………………………………. Character Functions - case conversionfunctions Character Functions - charactermanipulationfunctions NumericFunctions Date Functions Aggregate Functions General Functions Conditional Functions ConversionFunctions 9. Sub query, Co-Related Sub query, Exist Clause………………………………………………………………………………… Single rowsubquery Multiple row subquery Correlatedsubquery Multiple Columnsubquery EXISTS 10. Views, Inline Views and Materialized Views…………………………………………………………………………………. Views – types -Simple Views -Complex Views Inline View Materialized View 11. Indexes, Synonym, Dblink, Backup Copies……………………………………………………………………………………… Indexes - types Sequence - (nextval, currval) Synonym - Types - Private,-Public Dblink Backup Copies 12. Miscellaneous Functions……………………………………………………………………………………………………………… RANK DENSE RANK PIVOT IDENTITY, @@IDENTITY,SCOPE_IDENTITY, IDENT_CURRENT CAST -(SQL 92), CONVERT ACID PROPERTIES ROLLUP CUBE COUNT_BIG BINARY_CHECKSUM
  • 4. CHECKSUM_AGG LOCAL TEMPORARY TABLE/ GLOBAL TEMPORARY TABLE 1. Overview This document provides simplified and detailed level of information with examples about Oracle - SQL (including 11g new features) based on the syllabus of 11g Oracle SQL - Exam 1Z0-051. 2. Oracle and SQL Oracle is a Database, which is developed by Oracle Corporation. Organizations can store data on various media and in different formats, such as hard copy document in a filing cabinet or data stored in electronic spreadsheets or in databases. A Database is an organized collection of information. To manage databases, you need Database Management Systems (DBMS). A DBMS is a program that stores, retrieves and modifies data in the database on request. There arefour main types of databases: Hierarchical, Network, Relational and Object relational (ORDBMS). SQL SQL (Structured Query Language) is a simple computer language used to create, access, and manipulate the data and structure in relational Databases. 2.1 Classification of SQLStatements DDL (Data Definition Language)  CREATE  ALTER  DROP  TRUNCATE Refer also (FLASHBACK, RENAME, PURGE, COMMENT, UNDROP, ANALYZE, AUDIT, NOAUDIT, ASSOCIATE STATISTICS, DISASSOCIATE STATISTICS) DML (Data Manipulation Language)  INSERT  UPDATE  DELETE  MERGE
  • 5. Refer also (CALL, EXPLAIN PLAN, LOCK TABLE) DQL or DRL (Data Querying Language or Data Retrieval Language)  SELECT DCL (Data Control Language)  GRANT  REVOKE TCL (Transaction Control Language)  COMMIT  ROLLBACK  SAVEPOINT  SET TRANSACTION Session Control Statements  ALTER SESSION  SET ROLE System Control Statement  ALTER SYSTEM 2.1.0 Data types  VARCHAR2 (length) – Alpha numeric type of data can be stored, length range 1 to 60 can be specified  NUMBER (P,S) – Number values can be stored, Number having precision P can range1 to 38, scale S can range -84 to 127  DATE – Valid date range can be stored refer also  (NUMBER - NUMBER (p),NUMBER (S), FLOAT [(P)] )  (DATE - TIMESTAMP[fractional_seconds_precision], INTERVAL YEAR TO MONTH, INTERVAL DAY TO SECOND)  (CHARACTER - CHAR, VARCHAR, VARCHAR2, LONG, NCHAR(n), NVARCHAR2(n),)  (BINARY - RAW, LONGRAW)  (BLOB, CLOB, NCLOB, BFILE, ROWID, UROWID(n) ) 2.1.1 DDL (Data Definition Language)Statements DDL statements areused to build and modify the structure of tables and other objects in the Database.
  • 6.  CREATE – to create tables and other objects Syntax > CREATE TABLE table_name (column_name1 data_type,column_name2 data_type,column_name3 data_type,....); Example> CREATE TABLE EMP (EMPNO NUMBER, ENAME VARCHAR2(20), DEPTNO NUMBER, JOB VARCHAR2(15), MGR NUMBER, HIREDATE DATE, SAL NUMBER, COMM NUMBER)  ALTER – to alter tables and other objects Syntax> >ALTER TABLE EMP RENAME TO EMP_NEW; to rename table name >ALTER TABLE EMPADD (MAILID VARCHAR2(25)); to add new column into table >ALTER TABLE EMP DROP COLUMN MAILID; to remove existing column from table >ALTER TABLE EMP MODIFY MAILID NUMBER; to change datatype of a column >ALTER TABLE EMP RENAME COLUMN MAILID TO EMAILID; torename a column name >ALTER TABLE EMP ADD PRIMARY KEY (EMPNO); to add primary key >ALTER TABLE EMP ADD CONSTRAINT UK1_EMP UNIQUE (EMAILID); to add unique constraint >ALTER TABLE EMP MODIFY COMM DEFAULT 10; to modify values of a column >ALTER TABLE EMP MODIFY EMAILID VARCHAR2 (30); to increase & decrease length of a column >ALTER TABLE EMP MODIFY SAL NOT NULL; to make a column not null constraint >ALTER TABLE EMP DROP PRIMARY KEY; to remove primary key >ALTER TABLE EMP READ ONLY; to make table read only access  DROP – to delete tables and other objects Syntax> DROP TABLE <TABLE_NAME>; >DROP TABLE EMP;  TRUNCATE – to delete data in a table permanently Syntax> TRUNCATE TABLE <TABLE_NAME>; >TRUNCATE TABLE EMP; refer also (FLASHBACK, RENAME, PURGE, COMMENT, UNDROP, ANALYZE, AUDIT, NOAUDIT, ASSOCIATE STATISTICS, DISASSOCIATE STATISTICS) 2.1.2 DML (Data Manipulation Language)Statements DML statements are used to maintain and managedata within tables.  INSERT – to insert data into tables Syntax> INSERT INTO table_name VALUES (value1, value2, value3,...); > INSERT INTOtable_name (column1, column2, column3,...)VALUES (value1, value2, value3,...);
  • 7.  UPDATE – to update (modify) existing data in tables Syntax> UPDATE table_name SET column1=value, column2=value2,...WHERE some_column=some_value ;  DELETE – to delete data from tables Syntax> DELETE FROM table_name ; > DELETE FROM table_name WHERE some_column=some_value ;  MERGE – to perform insert and update in a single statement. Syntax> Example> Refer also (CALL, EXPLAIN PLAN, LOCK TABLE) The CALL and EXPLAIN PLAN statements are supported in PL/SQL only when executed dynamically. All other DML statements are fully supported in PL/SQL. 2.1.3 DRL (Data Retrieval Language)Statement DRL statement is used to read data from tables.  SELECT - to retrieve data from tables Syntax> SELECT column_name(s)FROM table_name ; > SELECT * FROM table_name; > SELECT * FROM EMP ; > select * from all_objects where object_type='TABLE' ; 2.1.4 TCL (Transaction ControlLanguage)Statements  COMMIT – saves the work done Commit is of two types - -Implicit Commit : This will be issued by Oracle internally, When DDL is performed. -Explicit Commit : This will be issued by user.  ROLLBACK - restore the database to original since the last COMMIT Rollback will be applied in two methods - -Upto Previous Commit -Upto Previous Rollback  SAVEPOINT – saves the work done up to some point. Used with Rollback.  SET TRANSACTION -  Locking Mechanism -
  • 8. 2.1.5 DCL (Data Control Language)Statements DCL statements areused for access control in the Database.  GRANT – gives access privileges to users for database  REVOKE – withdraws access privileges to users for database Use the GRANT or REVOKE statement to give privileges to a specific user or role, or to all users, to perform actions on database objects. These privileges can be any combination of select, insert, update, delete, references, alter, and index. Below is an explanation of what each privilege means. Privilege Description Select Ability to query the table with a select statement. Insert Ability to add new rows to the table with the insert statement. Update Ability to update rows in the table with the update statement. Delete Ability to delete rows from the table with the delete statement. References Ability to create a constraint that refers to the table. Alter Ability to change the table definition with the alter table statement. Index Ability to create an index on the table with the create index statement. 2.1.6 Session ControlStatements Session control statements dynamically managethe properties of a user session. These statements do not implicitly commit the current transaction. PL/SQL does not support session control statements. • ALTER SESSION > alter session set current_schema = <schemaname> ; > alter session set optimizer_mode = <mode> ; • SET ROLE > SET TIME ZONE > SET SESSION AUTHORIZATION > SET SESSION CHARACTERISTICS 2.1.7 SystemControl Statements  ALTER SYSTEM - dynamically manages the properties of an Oracle Databaseinstance. This statement does not implicitly commit the current transaction and is not supported in PL/SQL. Syntax> alter system kill session 'session-id, session-serial' ; > alter system checkpoint ; > alter system kill session 'session-id, session-serial' ; > Alter system archive log [start, stop, all, ...] ;
  • 9. 3. CONSTRAINTS Constraintsare the rulesdefinedinoracle tablestoimplementdataintegrity.These rulescanbe placed for each column i.e, at column level, or at the end of the column prototypingi.e, table level. Wheneveranyactionisdone onthe table,these rules are invokedandraise exceptionupon violation.  NOT NULL  UNIQUE  PRIMARY KEY  FOREIGN KEY  CHECK  NOT NULL - isusedto restrictNULL valuesina columnof a table.  UNIQUE - Unique constraintensuresthatthe columnvaluesare distinct,withoutany duplicates. The columnsof the table withunique constraintare calledunique key.The null able columnswith unique constraintscancontainNULLS. Unique Constraintcanbe imposedonmultiplecolumns also(composite uniquekey).  PRIMARY KEY - ishybrid constraintevolvedfromfunctionalcombinationof NOTNULLandUNIQUE constraints.The columnsof the table enforcedunderprimarykeyare restrictedfromNULLSand Duplicate values. FewkeypointsonPrimaryKey -A Table can have onlyone primarykey -Multiple columnscanbe clubbedundercomposite primarykey -Oracle internallycreatesuniqueindex topreventduplicationinthe columnvalues  FOREIGN KEY - If primarykeyof one table takespart in anothertable thenitiscalled foreign key, the table withprimarykeyiscalledparenttable andtable withforeignkeyiscalledchildtable. -ON DELETE CASCADE -ON DELETE SET NULL  CHECK - usedtolimitthe value range thatcan be placedina column. 4. Joins  ANSISQL-1999 Standards JOINS–types
  • 10. 1) Natural Join -joinwithUSINGclause -joinwithON clause 2) OuterJoin -Leftouterjoin -RightOuterJoin -Full OuterJoin 3) Cross Join  ORACLE JOINS JOINS– types 1) InnerJoin(simple join), -Equi Join -NonEqui Join -Self Join 2) OuterJoin -LeftOuterJoin -RightOuterJoin -Full OuterJoin 3) CartesianProduct 5. SetOperators  UNION  UNION ALL  MINUS  INTERSECT 6. Clauses  GROUP BY  HAVING
  • 11.  WHERE  DISTINCT  ORDER BY - ASC , DESC 7. SQL Expressionsand Operators  Arithmeticoperators[ +, -, *, /, (),]  Comparisonoperators(single rowandmultiple row operators) -Equality( = ) -Inequalityoperator( >,< ) -Composite inequalityoperator( <=, >= )  BETWEEN Operator( BETWEEN expression1ANDexpression2)  Logical Operators (AND,OR,NOT)  IN,NOT IN  EXIST,NOT EXIST  LIKE  ESCAPEIdentifier  IS NULL  IS NOTNULL  StringConcatenationoperators  Literals  Quote Operator(from10g onwards)  NULL  DESCRIBE  Escape Identifier  SubstitutionVariables( &), Double ampersandSubstitutionVariables( &&)  Define andVerifyCommands 8. SQL Functions- (single row functions, multiple row functions) -CharacterFunctions - case conversionfunctions  INITCAP  UPPER  LOWER
  • 12. -CharacterFunctions - character manipulationfunctions  CONCAT  LENGTH  Padding(LPAD,RPAD)  TRIM (RTRIM,LTRIM)  INSTR  SUBSTR  REPLACE -NumericFunctions  ROUND  TRUNC  MOD -Date Functions  MONTHS_BETWEEN  ADD_MONTHS  NEXT_DAY  LAST_DAY  ROUND (DATE,format)  TRUNC (DATE,format)  GETDATE  DATEDIFF  DATEPART  DATEADD -Aggregate Functions  COUNT  SUM  MAX  MIN  AVG -General Functions  NVL  NVL2  COALESCE  ALIAS  ROWNUM  ROWID -ConditionalFunctions  DECODE  CASE -ConversionFunctions  TO_CHAR - isusedto typecasta numericor date inputto character type  TO_DATE - it takescharacter or numbervaluesandreturnsformatteddate equivalentof the same
  • 13.  TO_NAUBER - thisfunctiontakescharacterinputsandreturnsnumberoutputaftersuitable formatting 9. Sub Query,Co-relatedSub Queryand ExistClause  Single rowsubquery  Multiple rowsubquery  Correlatedsubquery  Multiple Columnsubquery  EXISTS- thisoperatortestsfor existenceof rowsinthe resultsetof the sub query. Syntax> > SELECT DNAME FROM DEPT WHERE EXISTS(SELECT DEPT.DEPTNO= EMP.DEPTNO) ; 10. Views, Inline Views and Materialized Views  Views - types  Simple Views  Complex Views  Inline View-  Materialized View- 11. Indexes, Synonym, Dblink, Backup Copies  Indexes - types -Unique Index -Non-Unique Index -Btree Index -Bitmap Index -Composite Index -Function-based Index -Cluster Index  Sequence - (nextval, currval)  Synonym -
  • 14. Types - -Private -Public  Dblink - to access tables or views or sequence from one database to another database. Syntax> Example> CREATE DATABASE LINK CAASEDW CONNECT TO ITO_ASA IDENTIFIED BY exact123 USING 'CAASEDW' SQL> SELECT * FROM EMP@ CAASEDW ;  Backup Copies - 12. Miscellaneous Functions & Terms  RANK  DENSE RANK  PIVOT  IDENTITY, @@IDENTITY,SCOPE_IDENTITY, IDENT_CURRENT  CAST -(SQL 92), CONVERT  ACID PROPERTIES  ROLLUP  CUBE  COUNT_BIG  BINARY_CHECKSUM  CHECKSUM_AGG  LOCAL TEMPORARY TABLE/ GLOBAL TEMPORARY TABLE ########################## SQL END ###########################
  翻译: