How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf ·...

29
Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 1 Chapter 2 How to use Oracle SQL Developer and other tools

Transcript of How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf ·...

Page 1: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 1

Chapter 2

How to use Oracle SQL Developer

and other tools

Page 2: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 2

Objectives

Applied • Start or stop the Oracle database server and listener. • Use SQL*Plus to run a SQL statement. • Use Oracle SQL Developer to do any of the following:

Create a database connection Export or import database connections Navigate through the objects of a database View the column definitions for a table View the data for a table Edit the column definitions for a table

• Use Oracle SQL Developer to enter, run, open, and save SQL statements and scripts.

• Use the SQL Reference manual to look up information about SQL statements.

Page 3: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 3

Objectives (continued)

Knowledge • Briefly describe the function of each of these products:

Database Home Page SQL*Plus Oracle SQL Developer SQL Reference manual

Page 4: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 4

How to stop the database • Start All Programs

Oracle Database 10g Express Edition Stop Database

The DOS window when the database is stopped

Page 5: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 5

How to start the database • Start All Programs

Oracle Database 10g Express Edition Start Database

The DOS window when the database is started

Page 6: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 6

Terms to know • Database service (database server, database engine) • Database listener

Page 7: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 7

The Database Home Page

Page 8: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 8

How to start the Database Home Page from the Windows Start menu • All Programs

Oracle Database 10g Express Edition Go To Database Home Page.

• Use the Database Login page to log in.

How to use the Database Home Page to create a user for a database • Log in as the system user. • Administration

Database Users Create User.

• Use the resulting web page to create the user.

Page 9: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 9

The SQL*Plus tool

Page 10: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 10

How to start SQL*Plus • Select the Run command from the Start menu. • Enter “sqlplus”, and click the OK button.

How to connect to a database with SQL*Plus • Enter the username and password.

How to run a SQL statement with SQL*Plus • Type the statement. • Type a semicolon, and press the Enter key.

Page 11: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 11

The SQL Developer dialog box for creating database connections

Page 12: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 12

How to create a database connection • Right-click on the Connections node. • Select the New Connection command. • Enter a connection name, username, and password. • Click the Test button to test the connection. • Click the Save button to save the connection.

Page 13: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 13

How to export database connections • Right-click the Connections node. • Select the Export Connections command. • Select the connections that you want to export. • Specify the path and filename for the XML file for the connections.

How to import database connections • Right-click the Connections node. • Select the Import Connections command. • Navigate to the XML file for the connections. • Select the connections that you want to import.

Page 14: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 14

The Connection Information dialog box

Page 15: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 15

The tables available to the AP user

Page 16: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 16

The column definitions for a table

Page 17: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 17

How to view the column definitions for a table • Click on the name of the table in the Connections window. • By default, the columns are displayed in the sequence in which

they were created.

How to view the data for a table • Click on the Data tab.

Page 18: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 18

Editing the column definition of a table

Page 19: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 19

A SELECT statement and its results

Page 20: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 20

How to change the connection for a worksheet • Use the Connections list

How to comment out or uncomment a line • Press Ctrl+/.

Two ways to execute a SQL statement • Press the F9 key. • Click the Execute Statement button in the toolbar.

Page 21: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 21

Using the snippets window

Page 22: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 22

Handling syntax errors

Page 23: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 23

Common causes of errors • Misspelling the name of a table or column • Misspelling a keyword • Omitting the closing quotation mark • Being connected as the wrong user

Page 24: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 24

The Open File dialog box

Page 25: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 25

Three ways to open a SQL file • Click the Open button in the toolbar. • Press Ctrl+O. • Select the File Open command.

How to switch between open statements • Select the appropriate tab.

How to cut, copy, and paste code • Use the standard Windows techniques.

Page 26: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 26

Three ways to save a SQL file • Click the Save button in the toolbar. • Press Ctrl+S. • Select the File Save command.

How to change the default directory for new statements • Use the Tools Preferences command. • Expand the Database node. • Click on the Worksheet Parameters node. • Change the default path for scripts.

Page 27: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 27

A SQL script and its results

Page 28: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 28

How to run an entire SQL script • Press F5 or click the Run Script button.

How to run one statement within a script 1. Move the cursor into the statement you want to execute. 2. Press F9 or click the Execute Statement button.

Note • The results of a statement are displayed in the Results tab. • The results of a script are displayed in the Script Output tab.

Page 29: How to use Oracle SQL Developer and other toolsfaculty.tnstate.edu/Oracle10g/text/Chapter 2.pdf · Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide

Murach’s Oracle SQL and PL/SQL, C2 © 2008, Mike Murach & Associates, Inc. Slide 29

The Oracle Database SQL Reference manual