SlideShare ist ein Scribd-Unternehmen logo
1 von 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

--

Weitere Àhnliche Inhalte

Was ist angesagt? (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
 

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

Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricksYanli Liu
 
1670595076250.pdf
1670595076250.pdf1670595076250.pdf
1670595076250.pdfGaneshR321894
 
SQL đŸŒŸđŸŒŸđŸ”„.pdf
SQL đŸŒŸđŸŒŸđŸ”„.pdfSQL đŸŒŸđŸŒŸđŸ”„.pdf
SQL đŸŒŸđŸŒŸđŸ”„.pdfLightWolf2
 
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.pdf79TarannumMulla
 
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 understandingVivekanandaGN1
 
SQL Server Select Topics
SQL Server Select TopicsSQL Server Select Topics
SQL Server Select TopicsJay Coskey
 
Most useful queries
Most useful queriesMost useful queries
Most useful queriesSam Depp
 
Sql Queries
Sql QueriesSql Queries
Sql Querieswebicon
 
Mysql1
Mysql1Mysql1
Mysql1rajikaa
 
Oracle Training in Kochi | Trivandrum |Thrissur
Oracle Training in Kochi | Trivandrum |ThrissurOracle Training in Kochi | Trivandrum |Thrissur
Oracle Training in Kochi | Trivandrum |ThrissurIndiaOptions Softwares
 
Introduction to sql new
Introduction to sql newIntroduction to sql new
Introduction to sql newSANTOSH RATH
 
Oracle SQL AND PL/SQL
Oracle SQL AND PL/SQLOracle SQL AND PL/SQL
Oracle SQL AND PL/SQLsuriyae1
 

Ähnlich wie 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
 
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
 
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 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
 

KĂŒrzlich hochgeladen

Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...SeĂĄn Kennedy
 
HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...
HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...
HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...Nguyen Thanh Tu Collection
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 

KĂŒrzlich hochgeladen (20)

Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...
HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...
HỌC TỐT TIáșŸNG ANH 11 THEO CHÆŻÆ NG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIáșŸT - Cáșą NĂ...
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPSÂź Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 

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 --