Download presentation
Presentation is loading. Please wait.
Published byAlvin Hoover Modified over 9 years ago
1
1 Introduction to SQL *Plus Oracle SQL Interface MIS309 Database Systems
2
2 Connect to Oracle SQL *Plus In MS Windows, open “Run SQL Command Line” from the “start” menu. Type, “Connect” Enter “hr” for the name and password or enter “system” and the admin password you created during the Oracle install.
3
3 The SQL Command Prompt
4
4 Show all Tables
5
5
6
6 Introduction to SQL Plus Oracle’s proprietary SQL is named SQL*Plus. Besides the standard SQL statements, it provides an environment where you can create, save, run SQL statements and do other chores. Some common SQL*Plus Commands: REMARKSET HEADSEPTTITLE(top title) BTITLECOLUMNBREAK ON COMPUTE SUMSET LINESIZE n SET PAGESIZE nSPOOL SET PAUSE (ON | OFF)
7
7 Examples
8
8 The SQL*Plus Editor. In Windows, the NotePad is typically assigned as the SQL*Plus Editor. SQL*Plus always keeps the last SQL statement (not command) in the editor. If you do a mistake, you mat activate the editor to make correction. The command to activate the editor is Edit or simply Ed. When you save the edited file, by default, the system will save it in a file named afidt.buf.
9
9 Edit the statement, save and close the file. You will be back to the SQL screen. Issue a / Command. The system will run the saved statement. No semicolon
10
10 The “ED” command
11
11 New query will remove the past query from the edit buffer
12
12 Get Files to Run
13
13 Introduction to SQL*Plus Scripts A Script file is a text file which may contain several SQL statements and some selected SQL*Plus commands. Rather than doing the queries interactively, we may write the statements in a text file and then run the statements in batch mode. We will use the Notepad to develop a simple script. WE will save it as myScript1.txt in some directory. Then we will run the script in SQL*Plus using the START or @ command.
14
14 Script is a text file
15
15
16
16
17
17 Run Example Script
18
18
19
19 Copying a table to another table (with data & structure)
20
20 Copying the structure of a table to another table (without data) The BETWEEN Operator
21
21 Parameter Query
22
22 The ACCEPT command Like a variable
23
23
24
24
25
25 A list of employees with budgeted compensation. Budget is (fixed salary + quota*commRate)
26
26 Some employees do not have fixed salary. In that case we want the budget to be quota*copmmRate. If some employees do not have quota, we want to treat it as 0.
27
27 Using Special Pseudo-columns
28
28 End of Introduction Other commands and information can be found in the Oracle Documentation available online.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.