1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows...

14
1 1 ORACLE SQL iSQLPlus & SQLPLUS Statements

Transcript of 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows...

Page 1: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

11ORACLE

SQLiSQLPlus & SQLPLUS

Statements

ORACLE

SQLiSQLPlus & SQLPLUS

Statements

Page 2: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-2

iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the database•Log in to iSQL*Plus.

•Describe the table structure.

•Edit your SQL statement.

•Execute SQL from SQL*Plus.

•Save SQL statements to files and append SQL statements to files.

•Execute saved files.

•Load commands from file to bufferto edit.

iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the database•Log in to iSQL*Plus.

•Describe the table structure.

•Edit your SQL statement.

•Execute SQL from SQL*Plus.

•Save SQL statements to files and append SQL statements to files.

•Execute saved files.

•Load commands from file to bufferto edit.

iSQLPlus EnvironmentiSQLPlus Environment

Page 3: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-3

SQL and iSQL*Plus InteractionSQL and iSQL*Plus Interaction

SQL*PlusSQL*Plus

SQL StatementsSQL StatementsBufferBuffer

SQL StatementsSQL Statements

Server

Query ResultsQuery ResultsSQL*PlusSQL*Plus CommandsCommands

Formatted ReportFormatted Report

Page 4: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-4

SQL Statements Versus iSQL*Plus Commands

SQL Statements Versus iSQL*Plus Commands

SQLSQLstatementsstatements

SQL SQL

• A languageA language

• ANSI standardANSI standard

• Keyword cannot be Keyword cannot be abbreviatedabbreviated

• Statements manipulate Statements manipulate data and table data and table definitions in the definitions in the databasedatabase

iSQL*PlusiSQL*Plus

• An online environmentAn online environment

• Oracle proprietaryOracle proprietary

• Keywords can be Keywords can be abbreviatedabbreviated

• Commands do not Commands do not allow manipulation of allow manipulation of values in the databasevalues in the database

SQLSQLbufferbuffer

SQL*PlusSQL*Pluscommandscommands

SQL*PlusSQL*Plusbufferbuffer

Page 5: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-5

• Log in to SQL*Plus.

• Describe the table structure.

• Edit your SQL statement.

• Execute SQL from SQL*Plus.

• Save SQL statements to files and append SQL statements to files.

• Execute saved files.

• Load commands from file to bufferto edit.

• Log in to SQL*Plus.

• Describe the table structure.

• Edit your SQL statement.

• Execute SQL from SQL*Plus.

• Save SQL statements to files and append SQL statements to files.

• Execute saved files.

• Load commands from file to bufferto edit.

Things you can do in iSQL*PlusThings you can do in iSQL*Plus

Page 6: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-6

Logging In to SQL*PlusLogging In to SQL*Plus

• From Windows environment (Using the From Windows environment (Using the client software):client software):

• From command line:From command line: sqlplus [sqlplus [usernameusername[/[/password password [@[@databasedatabase]]]]]]

• From Windows environment (Using the From Windows environment (Using the client software):client software):

• From command line:From command line: sqlplus [sqlplus [usernameusername[/[/password password [@[@databasedatabase]]]]]]

Page 7: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-7

Logging In to iSQL*PlusLogging In to iSQL*Plus• From Browser: From Browser:

http://lovelace.cs.missouriwestern.edu:5560/isqlplushttp://lovelace.cs.missouriwestern.edu:5560/isqlplus//

• From Browser: From Browser: http://lovelace.cs.missouriwestern.edu:5560/isqlplushttp://lovelace.cs.missouriwestern.edu:5560/isqlplus//

Page 8: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-8

SQL CommandsCreating a table

SQL CommandsCreating a table

Create Table Dept (Create Table Dept (

DEPT_NODEPT_NO NUMBER(2) Not Null, NUMBER(2) Not Null,

DNAMEDNAME VARCHAR2(14), VARCHAR2(14),

LOCLOC VARCHAR2(13),VARCHAR2(13),

PRIMARY KEY (DEPT_NO));PRIMARY KEY (DEPT_NO));

Create Table Dept (Create Table Dept (

DEPT_NODEPT_NO NUMBER(2) Not Null, NUMBER(2) Not Null,

DNAMEDNAME VARCHAR2(14), VARCHAR2(14),

LOCLOC VARCHAR2(13),VARCHAR2(13),

PRIMARY KEY (DEPT_NO));PRIMARY KEY (DEPT_NO));

Page 9: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-9

Displaying Table StructureDisplaying Table Structure

Use the SQL*Plus DESCRIBE command to Use the SQL*Plus DESCRIBE command to display the structure of a table.display the structure of a table.Use the SQL*Plus DESCRIBE command to Use the SQL*Plus DESCRIBE command to display the structure of a table.display the structure of a table.

DESC[RIBE] tablenameDESC[RIBE] tablename

Page 10: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-10

Displaying Table StructureDisplaying Table Structure

SQL> DESCRIBE deptSQL> DESCRIBE dept

Name Null? Type----------------- -------- ------------DEPTNO NOT NULL NUMBER(2)DNAME VARCHAR2(14)LOC VARCHAR2(13)

Name Null? Type----------------- -------- ------------DEPTNO NOT NULL NUMBER(2)DNAME VARCHAR2(14)LOC VARCHAR2(13)

Page 11: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-11

Running a Script File from iSQLPlusRunning a Script File from iSQLPlus

A.A. Select ‘Load ScripSelect ‘Load Scrip1. make sure your script 1. make sure your script is a text file (.txt or .sql)is a text file (.txt or .sql)

B.B. Browse to find your Browse to find your script, then select itscript, then select it

C.C. Hit ExecuteHit Execute

D.D. Review results at Review results at the bottom of pagethe bottom of page

OROR

Copy/Paste script into Copy/Paste script into window, then window, then ExecuteExecute

A.A. Select ‘Load ScripSelect ‘Load Scrip1. make sure your script 1. make sure your script is a text file (.txt or .sql)is a text file (.txt or .sql)

B.B. Browse to find your Browse to find your script, then select itscript, then select it

C.C. Hit ExecuteHit Execute

D.D. Review results at Review results at the bottom of pagethe bottom of page

OROR

Copy/Paste script into Copy/Paste script into window, then window, then ExecuteExecute

Page 12: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-12

iSQLPlusEnvironment

iSQLPlusEnvironment

Go to preferences

to set environment

Go to History to see and access

previously ran scripts

Page 13: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-13

Set Display CommandsSet Display Commands

Set display Commands to

ON - this will allow the

command to display before the

result. This is the required

format for turning in homework.

Page 14: 1 ORACLE SQL iSQLPlus & SQLPLUS Statements. 1-2 iSQLPlus is a application software layer that allows programmers to utilize SQL to make changes to the.

1-14

SummarySummary

Use iSQL*Plus as an environment to:Use iSQL*Plus as an environment to:

• Execute SQL statements

• Edit SQL statements

Use iSQL*Plus as an environment to:Use iSQL*Plus as an environment to:

• Execute SQL statements

• Edit SQL statements