Annexe SQLPlus Commands

Embed Size (px)

Citation preview

  • 7/25/2019 Annexe SQLPlus Commands

    1/20

    Introduction to SQL*Plus

    Basic Orders

  • 7/25/2019 Annexe SQLPlus Commands

    2/20

    Preview

    Editing orders

    Files manipulation

    Environment personalization

    Formatting commands

    Creating reports

    Introduction to SQL*Plus

  • 7/25/2019 Annexe SQLPlus Commands

    3/20

    Introduction to SQL*Plus

    Buffer in SQL*Plus:

    Editing commands

  • 7/25/2019 Annexe SQLPlus Commands

    4/20

    Introduction to SQL*Plus

    Buffer in SQL*Plus:

    Editing commands

    Open Notepad to edit easily the latest SQL command.

    Block your environment until you close it.

    afiedt.buf cant containt SQL*Plus environment orders.

    For SQL*Plus environment orders, use an SQL script.

    ED[IT]

  • 7/25/2019 Annexe SQLPlus Commands

    5/20

    Introduction to SQL*Plus

    Command list (non-exhaustive)

    Editing commands

    A[PPEND] text

    C[HANGE] / old / new

    CL[EAR] BUFF[ER]

    CL[EAR] SCR[EEN]

    DEL

    DEL n

    DEL m n

  • 7/25/2019 Annexe SQLPlus Commands

    6/20

    Introduction to SQL*Plus

    Command list (non-exhaustive)

    Editing commands

    I[NPUT]

    I[NPUT] text

    L[IST]

    L[IST] n

    L[IST] m n

    R[UN]

    n

    n text

    0 text

  • 7/25/2019 Annexe SQLPlus Commands

    7/20

    Introduction to SQL*Plus

    Example: Using LIST, n andAPPEND

    Editing commands

    SQL> LIST1 SELECT last_name2* FROM employees

    SQL> 11* SELECT last_name

    SQL> A , job_id1* SELECT last_name, job_id

    SQL> L1 SELECT last_name, job_id

    2* FROM employees

  • 7/25/2019 Annexe SQLPlus Commands

    8/20

    Introduction to SQL*Plus

    Example: Using CHANGE

    Editing commands

    SQL> L1 SELECT * FROM employees

    SQL> c/employees/departments1* SELECT * FROM departments

    SQL> L1 SELECT * FROM departments

  • 7/25/2019 Annexe SQLPlus Commands

    9/20

    Introduction to SQL*Plus

    Command list (non-exhaustive)

    Files manipulation

    SAV[E] filename[.ext] [RE[PLACE]]|[APP[END]]

    GET filename[.ext]

    STA[RT] filename[.ext]

    @ filename[.ext]

    ED[IT] [filename[.ext]]

    SPO[OL] filename[.ext] [OFF|OUT]

    EXIT

  • 7/25/2019 Annexe SQLPlus Commands

    10/20

    Introduction to SQL*Plus

    Some commands:

    Environment personalization

    Use SET to control the current session

    Verify your configuration with SHOW

    SET system_variable value

    SQL> SET ECHO ONSQL> SHOW ECHO

    echo ON

  • 7/25/2019 Annexe SQLPlus Commands

    11/20

    Introduction to SQL*Plus

    Some SET variables:

    Environment personalization

    ARRAYSIZE {15 | n}FEEDBACK {6 | n | OFF | ON}HEADING {OFF | ON}LONG {80 | n | ON | text}LINESIZE {80 | n}

    PAGESIZE {14 | n}

    SQL> SET HEADING OFFSQL> SHOW HEADING

    heading OFF

  • 7/25/2019 Annexe SQLPlus Commands

    12/20

    Introduction to SQL*Plus

    Some commands:

    Formatting commands

    COL[UMN] [column option]TTITLE [text | OFF | ON]BTITLE [text | OFF | ON]BREAK [ON report_element]

  • 7/25/2019 Annexe SQLPlus Commands

    13/20

    Introduction to SQL*Plus

    The COLUMN command

    Formatting commands

    To control the column display

    CLE[AR]: Removes all formatting options on the column

    HEA[DING] text: Change the column heading

    FOR[MAT] format: Modify the column display using

    formatting options

    NOPRINT | PRINT: Displays or not the column

    NULL: ReplacesNULL values

    COL[UMN] [{column | alias} [option]]

  • 7/25/2019 Annexe SQLPlus Commands

    14/20

    Introduction to SQL*Plus

    The COLUMN command

    Formatting commands

    Create a column heading:

    Display current configuration for the LAST_NAME column:

    Remove the column configuration:

    COLUMN last_name HEADING 'Employee|Name'COLUMN salary JUSTIFY LEFT FORMAT $99,990.00COLUMN manager FORMAT 999999999 NULL 'No manager'

    COLUMN last_name

    COLUMN last_name CLEAR

    St t t

  • 7/25/2019 Annexe SQLPlus Commands

    15/20

    Element

    9

    0

    $

    SELECT Statement

    Formatting commandsCOLUMN format models

    L

    .

    ,

    Result

    1234

    001234

    $1234

    L1234

    1234.00

    1,234

    Example

    999999

    099999

    $9999

    L9999

    9999.99

    9,999

    Description

    Represents a number

    Adds 0

    Dollar currency

    Locale currency

    Decimal position

    Thousands separator

    I t d ti t SQL*Pl

  • 7/25/2019 Annexe SQLPlus Commands

    16/20

    Introduction to SQL*Plus

    The BREAK command

    Formatting commands

    Avoid duplicate values on display

    BREAK ON job_id

    I t d ti t SQL*Pl

  • 7/25/2019 Annexe SQLPlus Commands

    17/20

    Introduction to SQL*Plus

    The TTILE and BTITLE commands

    Formatting commands

    Displays pages headers and footers

    Configure reports headers

    Configure reports footers

    TTI[TLE] [text | OFF | ON]

    TTITLE 'Salary|Report'

    BTITLE 'Confidential'

    I t d ti t SQL*Pl

  • 7/25/2019 Annexe SQLPlus Commands

    18/20

    Introduction to SQL*Plus

    Create a script file (.sql) to generate a report

    Creating reports

    1. Create and test your SQL statement.

    2. Save your statement in a script file (.sql).

    3. Edit your file in a text editor (Notepad).

    4. Add formatting commands before the statement.

    5. Verify the SQL terminator at the end of the statement (;).

    6. Remove formatting commands after the statement.

    7. Save your file.8. Load and execute your file.

    I t d ti t SQL*Pl

  • 7/25/2019 Annexe SQLPlus Commands

    19/20

    Introduction to SQL*Plus

    Example output

    Creating reports

    Introd ction to SQL*Pl s

  • 7/25/2019 Annexe SQLPlus Commands

    20/20

    SQL*Pluscommands

    Edit the buffer

    Createformatted

    reports

    Part 2 Summary

    Introduction to SQL*Plus

    Format thedisplay