Sql plus script file
This presentation is the property of its rightful owner.
Sponsored Links
1 / 8

SQL*Plus Script File PowerPoint PPT Presentation


  • 71 Views
  • Uploaded on
  • Presentation posted in: General

SQL*Plus Script File. SQL*Plus editor can have only one SQL command Insert command inserts only one record at a time Use Oracle script file A program in SQL. Creating SQL*Plus Script File. DO NOT use Oracle editor to create script file Use any Test editor such as NotePad or .NET

Download Presentation

SQL*Plus Script File

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Sql plus script file

SQL*Plus Script File

  • SQL*Plus editor can have only one SQL command

  • Insert command inserts only one record at a time

  • Use Oracle script file

  • A program in SQL


Creating sql plus script file

Creating SQL*Plus Script File

  • DO NOT use Oracle editor to create script file

  • Use any Test editor such as NotePad or .NET

    File extension: *.sql

    DOS file name conversion: no space

    Multiple SQL commands

    Use semicolon at the end of each command


Change the working folder

Change the Working Folder

  • SQL*Plus has a default working folder

    We may not have full rights in the folder

  • Change the working folder

    File menu

    Open…

    Browse to the folder (J:\CS 3630\Oracle)

    Select a file (Lab7.sql)

    Open

  • This does not execute the script file

    You could get an error message

    Enter to get SQL*Plus prompt


Execute script file

Execute Script File

  • Make sure the script file is in the working folder

  • Execute SQL script file

    @Lab7

    @Lab7.SQL

  • Do not use command run!


Dropping tables before creating

Dropping Tables before Creating

  • Cannot create a table if a table with the same name exists in the database

    Drop table test1;

    -- You may get an error message

    -- Since no table exists

    Create table test1 (


Parent and child tables

Parent and Child Tables

Drop table test2;

Drop table test1;

create table test1(

c1 char(4) primary key,

…);

Create Table test2(

b1 char(4) references test1(c1),

b2 integer);


Script file style

Script File: Style

  • File Header

    Full Name

    UserName

    Date

    Course

  • Add some comments

  • Blank lines to separate commands

  • Each line is not too long

  • Alignment

  • Different clauses on separate lines


Example

Example

OraclePlus.sql

SQL*Plus command Pause

Enter to continue


  • Login