Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dept. of Computer & Information Sciences

Similar presentations


Presentation on theme: "Dept. of Computer & Information Sciences"— Presentation transcript:

1 Dept. of Computer & Information Sciences
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems (ORACLE SQL*Plus)

2 SQL*Plus - Introduction
SQL*Plus is essentially an interactive command editor which enables the user to interrogate the database, e.g.: CREATE, ALTER, and DROP tables. INSERT, UPDATE, and DELETE rows. Specify primary keys , foreign keys, and indexes. GRANT and REVOKE access privileges. In order to perform these functions, the user enters a series of SQL statements. ORACLE SQL*Plus 6

3 SQL*Plus - Getting Started
When you open SQL*Plus, you will be promoted for Name, Password, & Host string. scott psu stddata ORACLE SQL*Plus 7

4 SQL*Plus - Getting Started
If the previous information have been entered correctly, SQL*Plus displays its own command line prompt; by default, SQL>. Any SQL command can be entered here ORACLE SQL*Plus 8

5 SQL*Plus - Getting Help
Full on-line help is available while using SQL*Plus. To get help: Select the help menu option, or Enter help at the SQL*Plus prompt ORACLE SQL*Plus 9

6 SQL*Plus - Entering and Executing SQL Statements
SQL statements entered at the SQL*Plus prompt are held in a multi- line command buffer. Non-SQL statements (such as help) may be entered without changing the contents of the SQL buffer. The buffer retains the contents of the latest SQL statement until a new SQL statement is entered or the buffer is cleared using the clear buffer command. The contents of the SQL buffer can be edited using several commands. (see manual) ORACLE SQL*Plus 10

7 SQL*Plus - Entering and Executing SQL Statements
An SQL statement is executed immediately if the last line of the statement is terminated with a semi-colon. Additionally, the statement currently in the SQL buffer can be executed by entering: A / (on its own), or The keyword run At the SQL*Plus prompt. ORACLE SQL*Plus 11

8 SQL*Plus - Saving Buffer Contents
The contents of the SQL buffer can be saved in an operating system file by entering the command: save filename[.ext] [replace] If the .ext is omitted, the file will be given the extension .sql. The optional argument replace allows an existing file to be overwritten. Using the optional argument append instead of replace allows the contents of the SQL buffer to be appended to an existing file. ORACLE SQL*Plus 12

9 SQL*Plus - Retrieving and Executing SQL Files
Either of the following commands can be issued at the SQL*Plus prompt: start filename[.ext] or @filename[.ext] In either case the specified file is executed and the final SQL statement in the file is retained in the buffer. ORACLE SQL*Plus 13

10 SQL*Plus - Retrieving a File into the SQL Buffer
To load an SQL file into the buffer without executing it the following command may be issued: get filename[.ext] ORACLE SQL*Plus 14

11 SQL*Plus - Using a Text Editor
To overcome the limitations of the SQL buffer, a host operating system text editor or notepad may be used instead. The main benefit of using a text editor (apart from its editing capabilities) is the ability to create files containing multiple SQL statements. Each statement (except optionally the last) must be terminated by a semi-colon. ORACLE SQL*Plus 15

12 SQL*Plus - Describing Tables
The structure of any table within the database may be displayed by entering the command describe at the SQL*Plus prompt. Syntax: describe tablename The names and types of each column within the specified table will be displayed. ORACLE SQL*Plus 16

13 SQL*Plus - Quitting To quit SQL*Plus, either one of the following commands can be used: quit, or exit. Both commands automatically commit any outstanding changes to the database. ORACLE SQL*Plus 17


Download ppt "Dept. of Computer & Information Sciences"

Similar presentations


Ads by Google