less_04.ppt

download less_04.ppt

of 27

Transcript of less_04.ppt

  • 8/13/2019 less_04.ppt

    1/27

    4Copyright 2004, Oracle. All rights reserved.

    Database Interfaces

  • 8/13/2019 less_04.ppt

    2/27

    4-2 Copyright 2004, Oracle. All rights reserved.

    Objectives

    After completing this lesson, you should be able to do

    the following:

    Use S!"#lus and iS!"#lus to access the Oracle

    Database $%g Describe the logical structure of tables

    Use S! to &uery, manipulate, and define data

    Identify common database interfaces

  • 8/13/2019 less_04.ppt

    3/27

    4-3 Copyright 2004, Oracle. All rights reserved.

    'hat Is S!(

    S! provides statements for a variety of tas)s,

    including:

    uerying data

    Inserting, updating, and deleting rows in a table *reating, replacing, altering, and dropping objects

    *ontrolling access to the database and its objects

    S! unifies all of the preceding tas)s in one

    consistent language+

  • 8/13/2019 less_04.ppt

    4/27

    4-4 Copyright 2004, Oracle. All rights reserved.

    Using S!

    here are several tools for interfacing with the

    database using S!:

    Oracle S!"#lus and iS!"#lus

    Oracle -orms, .eports, and Discoverer Oracle /nterprise 0anager

    hird1party tools

  • 8/13/2019 less_04.ppt

    5/27

    4-5 Copyright 2004, Oracle. All rights reserved.

    /nterprise 0anager: Seeing the S!

  • 8/13/2019 less_04.ppt

    6/27

    4-6 Copyright 2004, Oracle. All rights reserved.

    'hat Is S!"#lus(

    *ommand1line tool

    Used interactively or in batch mode

    $ sqlplus /nologSQL*Plus: Release 10.1.0.2.0 - Production on Tue

    e! 1" 0#:1":1 200%op&rig't (c) 1+2, 200, racle. ll rig'tsresered.SQL connect ricnter passord:%onnected.

    SQL SL%T * R3 dual4

    5-6SQL

  • 8/13/2019 less_04.ppt

    7/274-7 Copyright 2004, Oracle. All rights reserved.

    'hat Is iS!"#lus(

  • 8/13/2019 less_04.ppt

    8/274- Copyright 2004, Oracle. All rights reserved.

    Using iS!"#lus

  • 8/13/2019 less_04.ppt

    9/274-!0 Copyright 2004, Oracle. All rights reserved.

    Describing Data

  • 8/13/2019 less_04.ppt

    10/274-!! Copyright 2004, Oracle. All rights reserved.

    uerying Data

    heSL%T

    has three basic parts:

    he SL%T!ist

    he R3clause

    he78Rcondition 2optional3

  • 8/13/2019 less_04.ppt

    11/274-!2 Copyright 2004, Oracle. All rights reserved.

    Sorting the Data

    SQL SL%T last9nae, departent9id, p'one9nu!er 2 R3 eplo&ees ; R5R 3 5PRT3>T9?5 P8>9>@3

  • 8/13/2019 less_04.ppt

    12/274-!3 Copyright 2004, Oracle. All rights reserved.

    4oining ables

    5etting data from more than one table

  • 8/13/2019 less_04.ppt

    13/274-!5 Copyright 2004, Oracle. All rights reserved.

    0anipulating Data

    SQL ?>SRT ?>T eplo&ees 2 (3PL=9?5,?RST9>3,LST9>3,3?L,P8>9>@3DR9?5,5PRT3>T9?5) B EL@S # (,F

  • 8/13/2019 less_04.ppt

    14/274-!6 Copyright 2004, Oracle. All rights reserved.

    Defining Data

  • 8/13/2019 less_04.ppt

    15/274-!7 Copyright 2004, Oracle. All rights reserved.

    Overview of ransactions

    ransaction $ ransaction 6%33?T4

  • 8/13/2019 less_04.ppt

    16/274-!" Copyright 2004, Oracle. All rights reserved.

    ransaction *ontrol Statements

    SQL SL%T * R3 local9tep4no ros selected

    SQL ?>SRT ?>T local9tep EL@S 2 (S=S5T, "#, B+)41 ro created.

    SQL SL%T * Jro local9tep4T3P95T 8?9T3P L9T3P--------- ---------- ----------2"-%T-0; "# B+

    SQL RLL

  • 8/13/2019 less_04.ppt

    17/274-! Copyright 2004, Oracle. All rights reserved.

    !oc)ing Data

    Oracle Database $%g automatically loc)s data so that

    only one user can ma)e changes at a time+

  • 8/13/2019 less_04.ppt

    18/274-20 Copyright 2004, Oracle. All rights reserved.

    Other Statement *ategories

    Session control statements: 0anage the

    properties of a user session

    System control statement: 0anages the properties

    of an Oracle instance

    /mbedded S! statements: S! statements

    within a procedural language program

  • 8/13/2019 less_04.ppt

    19/274-2! Copyright 2004, Oracle. All rights reserved.

    'hat Is #!7S!(

    #!7S! is a bloc)1structured language, which e8tends

    S! with:

    Declarations:

    # 9ariables# *onstants

    # *ursors

    *ontrol structures:

    # *onditional control

    # Iterative control

    # Se&uential control

    /rror handling

  • 8/13/2019 less_04.ppt

    20/274-22 Copyright 2004, Oracle. All rights reserved.

    /8ample #!7S! loc)

    5%LR qt&9on9'and >@3T qt&9on9'and R3 inentor& 78R product I FT>>?S R%KTF R @P5T quantit&4 ? qt&9on9'and 0 T8> -- c'ecA quantit& @P5T inentor& ST quantit& I quantit& - 1 78R product I FT>>?S R%KTF4 ?>SRT ?>T purc'ase9record EL@S (FTennis racAet purc'asedF, S=S5T)4

    LS ?>SRT ?>T purc'ase9record EL@S (Fut oJ tennis racAetsF, S=S5T)4 >5 ?4 %33?T4>54

  • 8/13/2019 less_04.ppt

    21/274-23 Copyright 2004, Oracle. All rights reserved.

    Uses of #!7S!

    loc)s of #!7S! are used in:

    Anonymous bloc)s

    -unctions

    #rocedures #ac)ages

    riggers

    Object types

  • 8/13/2019 less_04.ppt

    22/274-24 Copyright 2004, Oracle. All rights reserved.

    'hat Is 4ava(

    4ava is an industry1standard, object1oriented

    programming language+ It includes the following

    concepts:

    A 4ava 9irtual 0achine 24903, which provides

    platform independence Automated storage management techni&ues

    !anguage synta8 that borrows from * and

    enforces strong typing

  • 8/13/2019 less_04.ppt

    23/274-25 Copyright 2004, Oracle. All rights reserved.

    Oracle and 4ava

    A #!7S! function:

    %alla!leStateent

    cstt I conn.prepare%all(MN I %LL !alance(N)O)4cstt.registerutParaeter(1, T&pes.LT)4cstt.set?nt(2, acct>o)4cstt.eecute@pdate()4Jloat acct%T?> !alance (acct9id >@3 >@3@3T acct9!al R3 accts 78R acct9no I acct9id4

    RT@R> acct9!al4>54

    *alling the function with 4ava:

  • 8/13/2019 less_04.ppt

    24/274-26 Copyright 2004, Oracle. All rights reserved.

    'hat Is O*I(

    O*I provides for: he Oracle *all Interface 2O*I3 is how all database

    features are made accessible to application

    developers+

    O*I ma)es scalable and high1performanceapplications possible+

    ;igher1level A#Is and tools use O*I indirectly for

    database access+

  • 8/13/2019 less_04.ppt

    25/274-27 Copyright 2004, Oracle. All rights reserved.

    Other A#Is

    4ava Database *onnectivity 24D*3

    #ro"*7*

  • 8/13/2019 less_04.ppt

    26/27

    4-2 Copyright 2004, Oracle. All rights reserved.

    Summary

    In this lesson, you should have learned how to:

    Use S!"#lus and iS!"#lus to access Oracle

    Database $%g

    Describe the logical structure of tables Use S! to &uery, manipulate, and define data

    Identify common database interfaces

  • 8/13/2019 less_04.ppt

    27/27

    #ractice >: Using S!

    his practice covers using iS!"#lus to:

    Describe tables

    Select from tables

    Update a table Delete from a table

    Undo changes