SlideShare uma empresa Scribd logo
1 de 6
Oracle 9i is fully SQL:1999 join compliant.

CROSS JOIN (Cartesian Product).

SELECT
            E.ENAME, D.DNAME
     FROM
         EMP E CROSS JOIN DEPT D;

NATURAL JOIN (Equijoin on All Identically Named Columns).

SELECT
            E.ENAME, D.DNAME
     FROM
            EMP E NATURAL JOIN DEPT D;


USING clause (Similar to a Natural Join, but allows for the designation of which
column(s) to use in the equijoin).

SELECT
            E.ENAME, D.DNAME
     FROM
            EMP E JOIN DEPT D USING (DEPTNO);

ON clause (Used to define columns to join on)

SELECT
            E.ENAME, D.DNAME
     FROM
            EMP E JOIN DEPT D ON (E.DEPTNO = D.DEPTNO);


LEFT OUTER JOIN (All records from first table with matching rows from second)

SELECT
            E.ENAME, D.DNAME
     FROM
            EMP E LEFT OUTER JOIN DEPT D ON (E.DEPTNO = D.DEPTNO);


RIGHT OUTER JOIN (All records from second table with matching rows from first)

SELECT
            E.ENAME, D.DNAME
     FROM
            EMP E RIGHT OUTER JOIN DEPT D ON (E.DEPTNO = D.DEPTNO);


FULL OUTER JOIN (All records from both tables—Identical to a union of left outer
join and right outer join)

SELECT
            E.ENAME, D.DNAME
     FROM
            EMP E FULL OUTER JOIN DEPT D ON (E.DEPTNO = D.DEPTNO);

Keyword OUTER is optional with RIGHT,LEFT or FULL.

--------------------------------------------------------------------------------
--


Oracle 9i has also introduced several new functions:
NULLIF(expr1, expr2) —Returns NULL if the first argument is equal to the second,
otherwise returns the first argument.

COALESCE(expr1, expr2, expr3, ...) —Returns the first non-null argument.


CASE Statement

SELECT ENAME, EXTRACT(YEAR FROM HIREDATE) AS YEAR_OF_HIRE,
  (CASE EXTRACT(YEAR FROM HIREDATE)
      WHEN 2002 THEN 'NEW HIRE'
      WHEN 1997 THEN 'FIVE YEARS SERVICE'
      WHEN 1992 THEN 'TEN YEARS SERVICE'
      ELSE 'NO AWARD THIS YEAR'
   END ) AS AWARD
FROM EMP;

CASE Expression

SELECT ENAME, SAL,
         (CASE
              WHEN JOB = —DBA— THEN SAL * 1.5
              WHEN HIREDATE < SYSDATE - TO_YMINTERVAL(—05-00—) THEN SAL * 1.25
              WHEN DEPTNO IN (40,30,10) THEN SAL * 1.1
              ELSE SAL * .9
            END ) AS NEW_SAL
      FROM EMP;



Explicit Defaults —Oracle 9i now allows for the keyword DEFAULT to be used in
INSERT or UPDATE statements:

INSERT INTO EMP (EMPNO, ENAME, DEPTNO)
      VALUES (8000,—MIKE—,DEFAULT);

UPDATE EMP SET COMM = DEFAULT;


MERGE Statement. —This excellent feature also known as an UPSERT will either do
an insert or an update depending on the existence of the record in the target
table.

MERGE INTO T1
      USING T2 ON (T1.C9=T2.C9)
      WHEN MATCHED THEN UPDATE SET T1.C1=T2.C2, T1.C2=T2.C2 ...
      WHEN NOT MATCHED THEN INSERT (C1,C2, ...) VALUES (C1,C2, ...);



Multiple Table Inserts Statement. —Allows for insertion into multiple tables as
part of a single DML statement.

UNCONDITIONAL
INSERT ALL
INTO T1 (C1, C2, ...) VALUES (C1, C2, ...)
INTO T2 (C1, C2, ...) VALUES (C1, C2, ...)
...
SELECT C1, C2, ... FROM T9;

CONDITIONAL —FIRST will only insert into the first statement that returns true,
ALL will insert into each statement that returns true.
INSERT [ALL|FIRST]
WHEN c1 = 1 THEN INTO T1 (C1, C2, ...) VALUES (C1, C2, ...)
WHEN c1 = 2 THEN INTO T2 (C1, C2, ...) VALUES (C1, C2, ...)
WHEN c2 = 3 THEN INTO T3 (C1, C2, ...) VALUES (C1, C2, ...)
...
SELECT C1, C2, ... FROM T9;



We also have several new conversion functions:

TO_TIMESTAMP —From String to Timestamp.
TO_TIMESTAMP_TZ —From String to Timestamp with Time Zone.

TO_DSINTERVAL —From String to Interval Day to Second.
TO_YMINTERVAL —From String to Interval Year to Month

TO_CHAR —Extended to accept the new format characters.

EXTRACT —Returns the requested value (as a number) from a datetime or interval
datatype. Options are Year, Month, Day, Hour, Minute, Second, Timezone_Hour,
Timezone_Minute, Timezone_Region, or Timezone_ABBR.
SELECT EXTRACT(YEAR FROM SYSDATE) FROM DUAL;



DBMS_METADATA is a package that allows for object DDL to be retrieved from the
database.
This package will work for tables, indexes, views, packages, functions,
procedures, triggers, synonyms, and types.

DBMS_METADATA has functions for casual use:
DBMS_METADATA.GET_DDL(object_type, name, schema)
DBMS_METADATA.GET_XML(object_type, name, schema)

--

SELECT DBMS_METADATA.GET_DDL(—TABLE—, —EMP—, —SCOTT—) from dual;
  CREATE TABLE "SCOTT"."EMP"
   (    "EMPNO" NUMBER(4,0),
        "ENAME" VARCHAR2(10),
        "JOB" VARCHAR2(9),
        "MGR" NUMBER(4,0),
        "HIREDATE" DATE,
        "SAL" NUMBER(7,2),
        "COMM" NUMBER(7,2),
        "DEPTNO" NUMBER(2,0),
         CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0
  FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "USERS"   ENABLE,
         CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
  REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE NOVALIDATE
   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0
  FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "USERS"

--

External tables are flat files stored outside of the database that Oracle treats
as a table.
The data is read-only and no indexes can be created.

Object rights are controlled through —SELECT TABLE— and —READ DIRECTORY—
privileges.

UTL_FILE_DIR must be set appropriately.



CREATE DIRECTORY external_tables AS —c:oracleoradataexternal—;

CREATE TABLE EMP_EXT (EMPNO NUMBER(4,0), ENAME VARCHAR2(10), JOB VARCHAR2(9),
MGR NUMBER(4,0), HIREDATE DATE, SAL NUMBER(7,2), COMM NUMBER(7,2), DEPTNO
NUMBER(2,0))
   ORGANIZATION EXTERNAL
   (TYPE oracle_loader
   DEFAULT DIRECTORY external_tables
   ACCESS PARAMETERS
     (RECORDS DELIMITED BY NEWLINE
      BADFILE external_tables:—bad_emp_ext.txt—
      LOGFILE external_tables:—log_emp_ext.txt—
      FIELDS TERMINATED BY —,—
      MISSING FIELD VALUES ARE NULL)
      LOCATION (—emp.txt—))
   REJECT LIMIT UNLIMITED

     --

Once the table metadata has been created (as in the previous slide) , then this
table can be queried just like any other table. This includes functions, joins,
etc.


Two new views help in the administration of these external tables:
DBA_EXTERNAL_TABLES lists the attributes of each external table in the database.
DBA_EXTERNAL_LOCATIONS lists the specific flat files and their associated
directories.

--

Flashback Query allows users to see a consistent view of the database at a point
in time in the past.

This view of the data is read-only.

This view of the data is re-created by undo and is only available if the undo
blocks are still available.

PL/SQL cursors opened in flashback mode are available for DML after flashback
mode is disabled.

Flashback Query is also supported by EXP.

--

EXEC DBMS_FLASHBACK.ENABLE_AT_TIME(
    TO_DATE(—03-20-2002 14:00:00—,—MM-DD-YYYY HH24:MI:SS—));

Oracle uses a new table, SMON_SCN_TIME to translate timestamps to SCNs.
Documentation states that it only tracks the last five days and is only in five
minute increments.

SELECT DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER FROM DUAL;
This is a excellent new feature for capturing the current SCN.

EXEC DBMS_FLASHBACK.DISABLE;

--

Automatic Undo Management

UNDO_MANAGEMENT (MANUAL or AUTO)
Specifies whether or not to use AUM.   Default = MANUAL

UNDO_TABLESPACE (valid tablespace)
Specifies which undo tablespace to use.

UNDO_RETENTION (in seconds default=30)
Specifies how long to keep committed undo.

UNDO_SUPPRESS_ERRORS (TRUE or FALSE)
Specifies whether or not to return an exception when —SET TRANSACTION USE
ROLLBACK SEGMENT— is issued. Default = TRUE

--

DBA_ROLLBACK_SEGS, V$TRANSACTION, V$ROLLSTAT, are V$ROLLNAME are still
available.


DBA_UNDO_EXTENTS shows when each extent in the undo tablespace was committed.
#
V$UNDOSTAT shows the undo usage for the last 24 hours. Each row records a ten
minute interval defined by START_TIME and END_TIME. The key field is
UNDO_BLOCKS.

--

Things You Can Do With Online Redefinition

Move a table or index to a new tablespace
Change a table—s organization (partitioning, index-organized, etc.)
Add, remove, or rename columns in a table
Change the data type of a column in a table
Add new indexes to a table
Change constraint definitions on a table

--

The dbms_redefinition Package

Use the five procedures in this package to redefine an object online.
CAN_REDEF_TABLE
START_REDEF_TABLE
FINISH_REDEF_TABLE
ABORT_REDEF_TABLE
SYNC_INTERIM_TABLE

--

Other Enhancements

Index Monitoring Usage.
ALTER INDEX INDEX_NAME MONOITORING USAGE;
V$OBJECT_USAGE
Skip Scanning of Indexes.
Real Application Clusters (RAC).
Cache Fusion Block Transfer.
Oracle Managed Files (OMF)
DROP TABLESPACE TBS_01 INCLUDING CONTENTS AND DATAFILES;
Default temporary tablespace.
ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP;
Constraints on Views.
Log Miner Enhancements.
CURSOR_SHARING=SIMILAR

--

More Enhancements

EXP TABLESPACES=()
DBMS_STATS.GATHER_SYSTEM_STATS.
RMAN Enhancements.
Data Guard (formerly Standby Database).
Log Transport Services.
 LOG_ARCHIVE_DEST_n where n = 1-10.
 ARCHIVE_LAG_TARGET
Workspace Manager.
Data versioning.
SVRMGR is Deprecated.
CONNECT INTERNAL

--

Mais conteúdo relacionado

Mais procurados (20)

Les03[1] Single-Row Functions
Les03[1] Single-Row FunctionsLes03[1] Single-Row Functions
Les03[1] Single-Row Functions
 
Les12
Les12Les12
Les12
 
Les09[1]Manipulating Data
Les09[1]Manipulating DataLes09[1]Manipulating Data
Les09[1]Manipulating Data
 
Les11 Including Constraints
Les11 Including ConstraintsLes11 Including Constraints
Les11 Including Constraints
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
Les09
Les09Les09
Les09
 
Les11
Les11Les11
Les11
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
 
Oracle: DML
Oracle: DMLOracle: DML
Oracle: DML
 
SQLQueries
SQLQueriesSQLQueries
SQLQueries
 
Les22[1]Advanced Explicit Cursor Concepts
Les22[1]Advanced Explicit Cursor ConceptsLes22[1]Advanced Explicit Cursor Concepts
Les22[1]Advanced Explicit Cursor Concepts
 
MERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known FacetsMERGE SQL Statement: Lesser Known Facets
MERGE SQL Statement: Lesser Known Facets
 
Les03
Les03Les03
Les03
 
Les00 Intoduction
Les00 IntoductionLes00 Intoduction
Les00 Intoduction
 
Les13[1]Other Database Objects
Les13[1]Other Database ObjectsLes13[1]Other Database Objects
Les13[1]Other Database Objects
 
Les01
Les01Les01
Les01
 
Database Oracle Basic
Database Oracle BasicDatabase Oracle Basic
Database Oracle Basic
 
Les07[1]Multiple-Column Subqueries
Les07[1]Multiple-Column SubqueriesLes07[1]Multiple-Column Subqueries
Les07[1]Multiple-Column Subqueries
 
Mysql
MysqlMysql
Mysql
 
Mysql
MysqlMysql
Mysql
 

Semelhante a Oracle 9i notes(kamal.love@gmail.com)

Semelhante a Oracle 9i notes(kamal.love@gmail.com) (20)

Sql dml & tcl 2
Sql   dml & tcl 2Sql   dml & tcl 2
Sql dml & tcl 2
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricks
 
My SQL.pptx
My SQL.pptxMy SQL.pptx
My SQL.pptx
 
1670595076250.pdf
1670595076250.pdf1670595076250.pdf
1670595076250.pdf
 
Cheat sheet SQL commands with examples and easy understanding
Cheat sheet SQL commands with examples and easy understandingCheat sheet SQL commands with examples and easy understanding
Cheat sheet SQL commands with examples and easy understanding
 
SQL 🌟🌟🔥.pdf
SQL 🌟🌟🔥.pdfSQL 🌟🌟🔥.pdf
SQL 🌟🌟🔥.pdf
 
SQL learning notes and all code.pdf
SQL learning notes and all code.pdfSQL learning notes and all code.pdf
SQL learning notes and all code.pdf
 
SQL Server Select Topics
SQL Server Select TopicsSQL Server Select Topics
SQL Server Select Topics
 
ADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASADADVANCE ITT BY PRASAD
ADVANCE ITT BY PRASAD
 
Most useful queries
Most useful queriesMost useful queries
Most useful queries
 
Sql Queries
Sql QueriesSql Queries
Sql Queries
 
Oracle
OracleOracle
Oracle
 
Mysql1
Mysql1Mysql1
Mysql1
 
Oracle Training in Kochi | Trivandrum |Thrissur
Oracle Training in Kochi | Trivandrum |ThrissurOracle Training in Kochi | Trivandrum |Thrissur
Oracle Training in Kochi | Trivandrum |Thrissur
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql new
 
SQL
SQLSQL
SQL
 
Oracle SQL AND PL/SQL
Oracle SQL AND PL/SQLOracle SQL AND PL/SQL
Oracle SQL AND PL/SQL
 
Mysql
MysqlMysql
Mysql
 
Sql
SqlSql
Sql
 
Mysql Ppt
Mysql PptMysql Ppt
Mysql Ppt
 

Último

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIShubhangi Sonawane
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 

Último (20)

Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 

Oracle 9i notes(kamal.love@gmail.com)

  • 1. Oracle 9i is fully SQL:1999 join compliant. CROSS JOIN (Cartesian Product). SELECT E.ENAME, D.DNAME FROM EMP E CROSS JOIN DEPT D; NATURAL JOIN (Equijoin on All Identically Named Columns). SELECT E.ENAME, D.DNAME FROM EMP E NATURAL JOIN DEPT D; USING clause (Similar to a Natural Join, but allows for the designation of which column(s) to use in the equijoin). SELECT E.ENAME, D.DNAME FROM EMP E JOIN DEPT D USING (DEPTNO); ON clause (Used to define columns to join on) SELECT E.ENAME, D.DNAME FROM EMP E JOIN DEPT D ON (E.DEPTNO = D.DEPTNO); LEFT OUTER JOIN (All records from first table with matching rows from second) SELECT E.ENAME, D.DNAME FROM EMP E LEFT OUTER JOIN DEPT D ON (E.DEPTNO = D.DEPTNO); RIGHT OUTER JOIN (All records from second table with matching rows from first) SELECT E.ENAME, D.DNAME FROM EMP E RIGHT OUTER JOIN DEPT D ON (E.DEPTNO = D.DEPTNO); FULL OUTER JOIN (All records from both tables—Identical to a union of left outer join and right outer join) SELECT E.ENAME, D.DNAME FROM EMP E FULL OUTER JOIN DEPT D ON (E.DEPTNO = D.DEPTNO); Keyword OUTER is optional with RIGHT,LEFT or FULL. -------------------------------------------------------------------------------- -- Oracle 9i has also introduced several new functions:
  • 2. NULLIF(expr1, expr2) —Returns NULL if the first argument is equal to the second, otherwise returns the first argument. COALESCE(expr1, expr2, expr3, ...) —Returns the first non-null argument. CASE Statement SELECT ENAME, EXTRACT(YEAR FROM HIREDATE) AS YEAR_OF_HIRE, (CASE EXTRACT(YEAR FROM HIREDATE) WHEN 2002 THEN 'NEW HIRE' WHEN 1997 THEN 'FIVE YEARS SERVICE' WHEN 1992 THEN 'TEN YEARS SERVICE' ELSE 'NO AWARD THIS YEAR' END ) AS AWARD FROM EMP; CASE Expression SELECT ENAME, SAL, (CASE WHEN JOB = —DBA— THEN SAL * 1.5 WHEN HIREDATE < SYSDATE - TO_YMINTERVAL(—05-00—) THEN SAL * 1.25 WHEN DEPTNO IN (40,30,10) THEN SAL * 1.1 ELSE SAL * .9 END ) AS NEW_SAL FROM EMP; Explicit Defaults —Oracle 9i now allows for the keyword DEFAULT to be used in INSERT or UPDATE statements: INSERT INTO EMP (EMPNO, ENAME, DEPTNO) VALUES (8000,—MIKE—,DEFAULT); UPDATE EMP SET COMM = DEFAULT; MERGE Statement. —This excellent feature also known as an UPSERT will either do an insert or an update depending on the existence of the record in the target table. MERGE INTO T1 USING T2 ON (T1.C9=T2.C9) WHEN MATCHED THEN UPDATE SET T1.C1=T2.C2, T1.C2=T2.C2 ... WHEN NOT MATCHED THEN INSERT (C1,C2, ...) VALUES (C1,C2, ...); Multiple Table Inserts Statement. —Allows for insertion into multiple tables as part of a single DML statement. UNCONDITIONAL INSERT ALL INTO T1 (C1, C2, ...) VALUES (C1, C2, ...) INTO T2 (C1, C2, ...) VALUES (C1, C2, ...) ... SELECT C1, C2, ... FROM T9; CONDITIONAL —FIRST will only insert into the first statement that returns true, ALL will insert into each statement that returns true.
  • 3. INSERT [ALL|FIRST] WHEN c1 = 1 THEN INTO T1 (C1, C2, ...) VALUES (C1, C2, ...) WHEN c1 = 2 THEN INTO T2 (C1, C2, ...) VALUES (C1, C2, ...) WHEN c2 = 3 THEN INTO T3 (C1, C2, ...) VALUES (C1, C2, ...) ... SELECT C1, C2, ... FROM T9; We also have several new conversion functions: TO_TIMESTAMP —From String to Timestamp. TO_TIMESTAMP_TZ —From String to Timestamp with Time Zone. TO_DSINTERVAL —From String to Interval Day to Second. TO_YMINTERVAL —From String to Interval Year to Month TO_CHAR —Extended to accept the new format characters. EXTRACT —Returns the requested value (as a number) from a datetime or interval datatype. Options are Year, Month, Day, Hour, Minute, Second, Timezone_Hour, Timezone_Minute, Timezone_Region, or Timezone_ABBR. SELECT EXTRACT(YEAR FROM SYSDATE) FROM DUAL; DBMS_METADATA is a package that allows for object DDL to be retrieved from the database. This package will work for tables, indexes, views, packages, functions, procedures, triggers, synonyms, and types. DBMS_METADATA has functions for casual use: DBMS_METADATA.GET_DDL(object_type, name, schema) DBMS_METADATA.GET_XML(object_type, name, schema) -- SELECT DBMS_METADATA.GET_DDL(—TABLE—, —EMP—, —SCOTT—) from dual; CREATE TABLE "SCOTT"."EMP" ( "EMPNO" NUMBER(4,0), "ENAME" VARCHAR2(10), "JOB" VARCHAR2(9), "MGR" NUMBER(4,0), "HIREDATE" DATE, "SAL" NUMBER(7,2), "COMM" NUMBER(7,2), "DEPTNO" NUMBER(2,0), CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "USERS" ENABLE, CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO") REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE NOVALIDATE ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 LOGGING STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "USERS" -- External tables are flat files stored outside of the database that Oracle treats as a table.
  • 4. The data is read-only and no indexes can be created. Object rights are controlled through —SELECT TABLE— and —READ DIRECTORY— privileges. UTL_FILE_DIR must be set appropriately. CREATE DIRECTORY external_tables AS —c:oracleoradataexternal—; CREATE TABLE EMP_EXT (EMPNO NUMBER(4,0), ENAME VARCHAR2(10), JOB VARCHAR2(9), MGR NUMBER(4,0), HIREDATE DATE, SAL NUMBER(7,2), COMM NUMBER(7,2), DEPTNO NUMBER(2,0)) ORGANIZATION EXTERNAL (TYPE oracle_loader DEFAULT DIRECTORY external_tables ACCESS PARAMETERS (RECORDS DELIMITED BY NEWLINE BADFILE external_tables:—bad_emp_ext.txt— LOGFILE external_tables:—log_emp_ext.txt— FIELDS TERMINATED BY —,— MISSING FIELD VALUES ARE NULL) LOCATION (—emp.txt—)) REJECT LIMIT UNLIMITED -- Once the table metadata has been created (as in the previous slide) , then this table can be queried just like any other table. This includes functions, joins, etc. Two new views help in the administration of these external tables: DBA_EXTERNAL_TABLES lists the attributes of each external table in the database. DBA_EXTERNAL_LOCATIONS lists the specific flat files and their associated directories. -- Flashback Query allows users to see a consistent view of the database at a point in time in the past. This view of the data is read-only. This view of the data is re-created by undo and is only available if the undo blocks are still available. PL/SQL cursors opened in flashback mode are available for DML after flashback mode is disabled. Flashback Query is also supported by EXP. -- EXEC DBMS_FLASHBACK.ENABLE_AT_TIME( TO_DATE(—03-20-2002 14:00:00—,—MM-DD-YYYY HH24:MI:SS—)); Oracle uses a new table, SMON_SCN_TIME to translate timestamps to SCNs. Documentation states that it only tracks the last five days and is only in five minute increments. SELECT DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER FROM DUAL;
  • 5. This is a excellent new feature for capturing the current SCN. EXEC DBMS_FLASHBACK.DISABLE; -- Automatic Undo Management UNDO_MANAGEMENT (MANUAL or AUTO) Specifies whether or not to use AUM. Default = MANUAL UNDO_TABLESPACE (valid tablespace) Specifies which undo tablespace to use. UNDO_RETENTION (in seconds default=30) Specifies how long to keep committed undo. UNDO_SUPPRESS_ERRORS (TRUE or FALSE) Specifies whether or not to return an exception when —SET TRANSACTION USE ROLLBACK SEGMENT— is issued. Default = TRUE -- DBA_ROLLBACK_SEGS, V$TRANSACTION, V$ROLLSTAT, are V$ROLLNAME are still available. DBA_UNDO_EXTENTS shows when each extent in the undo tablespace was committed. # V$UNDOSTAT shows the undo usage for the last 24 hours. Each row records a ten minute interval defined by START_TIME and END_TIME. The key field is UNDO_BLOCKS. -- Things You Can Do With Online Redefinition Move a table or index to a new tablespace Change a table—s organization (partitioning, index-organized, etc.) Add, remove, or rename columns in a table Change the data type of a column in a table Add new indexes to a table Change constraint definitions on a table -- The dbms_redefinition Package Use the five procedures in this package to redefine an object online. CAN_REDEF_TABLE START_REDEF_TABLE FINISH_REDEF_TABLE ABORT_REDEF_TABLE SYNC_INTERIM_TABLE -- Other Enhancements Index Monitoring Usage. ALTER INDEX INDEX_NAME MONOITORING USAGE; V$OBJECT_USAGE Skip Scanning of Indexes. Real Application Clusters (RAC).
  • 6. Cache Fusion Block Transfer. Oracle Managed Files (OMF) DROP TABLESPACE TBS_01 INCLUDING CONTENTS AND DATAFILES; Default temporary tablespace. ALTER DATABASE DEFAULT TEMPORARY TABLESPACE TEMP; Constraints on Views. Log Miner Enhancements. CURSOR_SHARING=SIMILAR -- More Enhancements EXP TABLESPACES=() DBMS_STATS.GATHER_SYSTEM_STATS. RMAN Enhancements. Data Guard (formerly Standby Database). Log Transport Services. LOG_ARCHIVE_DEST_n where n = 1-10. ARCHIVE_LAG_TARGET Workspace Manager. Data versioning. SVRMGR is Deprecated. CONNECT INTERNAL --