Part 1 The Basics Connection setup and running basic queries
Playing with query results sorting, filtering and exporting Part 2
A little more advanced Bind variables, explain, finding objects,
schema browsing Part 3 New features in Version 3 Query Builder New
Schema Browser Exporting to PDF Other Handy Stuff Recommended
preference settings Some handy keyboard shortcuts Questions
Slide 3
Slide 4
Initial Startup Window Consists of a connections window, find
database object (this may not be there initially) and the editor
worksheet (large area on the right). To add connections click the
plus button in the connections window.
Slide 5
That will bring up the connection setup. Type your connection
name (whatever you want) and Userid. Click TNS for the connection
type and select the appropriate database under Network Alias.
Slide 6
To test the connection click Test and it will display Success
if the connection was successful, then click save to save your
connection settings. This will save it to your connection list.
Once all your connections are set up click cancel or connect to
connect to one of them. You should not save your password due to
security considerations and should use something like Keepass to
store them.
Slide 7
You can use something like Keepass to store your database
passwords which has a master password and then use a global
autotype key sequence to autotype the password. To the right is an
example setup for Keepass. Note: To do this you must use the same
password for all databases because the connection window is generic
for each connection. I can provide more info on setup on this
offline if people are interested. SQL developer password prompt
Keepass entry
Slide 8
Once your connections are set you can click the + next to a
connection to connect to the Database. This will open up a list of
objects for your Schema. Generally you wont need these unless you
are creating tables or views under your id. You can collapse this
list back after connecting unless you want to browse the schema
which I will talk about later.
Slide 9
In the Editor Worksheet window type a query. You can Run in a
few different ways. You can click the green arrow or hit
Ctrl+Enter. If you have more than one query you should put a slash
or semicolon to indicate the end of the prior query. This allows
the editor to recognize the end of a query, otherwise you need to
highlight the query with your mouse to run (which can be handy also
if you just want to run a part of a query and not utilize all of
the where criteria)
Slide 10
Completion Insight This is Oracles auto-complete feature which
will suggest things as you type. There are settings in the
preferences to set how quick this is and to turn it off if you find
it completely annoying. I usually adjust it so the popup speed is a
second or greater so I have to hesitate a bit before it will
suggest something.
Slide 11
SQL Developer will return a limited set of rows initially and
as you scroll down it will return more. If you want to get a count
of how many were returned you can right click in the results window
and click count rows. Or you can click in the results and do a
Ctrl+Page Down to go to the bottom of the results (not recommended
for large tables since it will load many rows into memory and slow
down your machine).
Slide 12
Update/Insert/Delete SQL will run as a script and display the
results in a script output window. To commit, click the symbol
above with the checkbox, or click the symbol with arrow to rollback
Also, F11 is commit and F12 is rollback.
Slide 13
Multiple database connections results in multiple tabs. You can
open a new connection to a new or the same database by clicking the
sql dropdown above the tab group. You can switch your tab to
another database by changing it on the right side. This is helpful
if you want to run the same query in another database.
Slide 14
At the bottom you should see SQL History. This is a history of
prior queries that you have run. If you double click on a SQL in
the history it will transfer up to the editor window wherever your
cursor is currently positioned. The history is also searchable, and
it shows you number of times executed and an average of how long it
took.
Slide 15
Slide 16
Double clicking on a column will sort the results, it will
toggle between ascending and descending order. An arrow will show
the direction.
Slide 17
To sort by multiple columns, right click on the column headers
and select sort. It will bring up a dialog box where you can select
the columns and the direction to sort by. The result will show the
sort order number and direction.
Slide 18
You can also filter your results by right clicking on the
column header of the column you want to filter. A dialog box will
be presented where you can select or type what you want to filter
on. You can filter on multiple columns.
Slide 19
Here is an example of two columns being filtered (notice the
funnel). You can clear all filters or redo a column filter by right
clicking again on the column header and selecting filter column or
clear all filters. If you just want to clear one column just select
it to filter and erase your filter.
Slide 20
To save a query result for later reference you can pin it by
clicking the pushpin button in the result window above the column
headers. This will open subsequent queries in a new query tab.
Slide 21
Once you pin your query a handy thing you can do is rename the
tab to something meaningful for later reference, you can right
click on the tab and click rename to do this. Note: The pinned
queries hang around for the session only.
Slide 22
Exporting Data You can quickly export data out to various
formats by right clicking on the result grid and clicking Export.
This will export the result of your query to various formats
including Excel, csv and several more.
Slide 23
To the right is a list of formats you can export to. You can
export to a file(s), clipboard or many other options. The Table
Name is used when creating insert statements and some of the other
file types, it defaults to EXPORT_TABLE so you would want to rename
it for those file types. If going to Excel the table name doesnt
really matter. Note: Files will be saved to the remote apps
drives.
Slide 24
Slide 25
Instead of hard coding values for a query you can use bind
variables. This is handy if you are using the same variable
multiple times. When you run the query it will prompt you for the
variables. It remembers your variables during your session and
across queries and connections so you can just adjust a value once
and have it affect multiple things you are checking.
Slide 26
Explain Plan To do an explain to find out the relative cost of
your query and how the query is getting your data, you can execute
an explain plan by clicking on the explain button or F10
Slide 27
Popup Describe - You can do a describe of a table by clicking
on the name and then either right click and click Popup Describe or
press Shift F4. It gives quite a lot of information as shown above.
Some of the more useful is the column info, constraints, and index
information.
Slide 28
One of the better things to have available is the find Database
Object. You can make it viewable by clicking View->Find DB
Object. It will open a new window and I usually drag it below my
connections.
Slide 29
In the window you can select the connection to search and then
some or all of the name. I usually keep the % checked which adds a
% on the end for a like search. It will return many database object
types so you need to know which ones are which. Here is a quick
(not all inclusive guide) Table View Public Synonym Index A Single
click will open up a new tab with information on the object.
Slide 30
Clicking the More button allows you to be more specific in your
search. However, the Schema tends to default to your schema when
you do this so you will want to switch that to ALL so that you can
find all occurrences. Set the type to whatever you are looking for,
TABLE for example. Now the fun part of this. s
Slide 31
If you open a table from Find DB object you can edit it. You
can update columns add new rows, delete rows, filter the results.
Click the commit or rollback buttons to save or cancel your
changes.
Slide 32
A handy option is the Duplicate row which you can invoke by
right clicking on a row and selecting Duplicate row. This allows
you to copy a row and then modify the key fields to make a new row.
Useful if you want to test a specific condition which might be hard
to create otherwise.
Slide 33
Schema Browsing To look at all objects for a user other than
yourself you can expand the Other Users tree under your connection.
I would recommend setting up filters for these since the lists can
be large and take a long time for the tool to query. These stick
around until you unset them.
Slide 34
Once you have the users you want to look at you can look at
their objects, again filters are recommended
Slide 35
Drag and drop SQL from the schema browser. Once you have a list
you can drag tables/views over to the editor to create SQL
statements for you.
Slide 36
Example of a dragged Update statement.
Slide 37
Slide 38
A new feature in version 3 is the query builder. This can be
handy for doing quick joins. Because of performance it is usually
better to start a query in the worksheet with the tables you want
then click the query builder tab and you will see something like
the lower picture.
Slide 39
You can then click and drag to the columns from one table to
the other to create your join keys.
Slide 40
By default an inner join will be done. However you can right
click on the join arrows and select an outer join.
Slide 41
When you click back to the worksheet you will see your SQL has
been altered to reflect what you set up in the query builder.
Slide 42
You can also add criteria and do other things such as getting
counts and sorting. Also you can select the columns you want by
checking them in the table layout above which will add them in the
lower pane. You can also set where criteria in the lower pane as
illustrated above.
Slide 43
So setting the criteria like it was shown on the previous slide
results in the following SQL in the worksheet. The Query Builder
can be a quick handy way to start a SQL for later refining. I
usually only do the join criteria to get a start and then manually
add my own other criteria but there is the capability to do more
than that. Feel free to play around with it.
Slide 44
New Schema Browser There is an enhanced schema browser in
version 3. If you right click on your connection and click Schema
Browser you can invoke it.
Slide 45
The schema browser will create a new tab next to connections.
From there you can select the schema and objects you are looking
for. You can also use the filter at the bottom to narrow down your
search.
Slide 46
From there you can do the same things as the old schema browser
such as drag and drop statements or opening the object to look at
properties or update data. I believe this is a big improvement to
the old schema browser.
Slide 47
Another thing added in version 3 was the ability to export data
to PDF. By right clicking on the results window and clicking
export, you can then select the format of PDF. You get a window
that looks like this.
Slide 48
This produces a PDF. It is somewhat limited since it defaults
to portrait so columns can overflow to other pages and be hard to
match up. It is really only good for small numbers of columns at
this point, hopefully they will provide enhancements to this in
future releases.
Slide 49
Slide 50
Some settings I would recommend under Tools->Preferences
Show Line numbers adds line numbers to your editor window which can
be handy if you get an error and it references a specific line
Slide 51
By default a date is displayed as a DD-MON-RR format which
doesnt show time. You can change this in the NLS section of the
preferences to your preferred format. I prefer to see it as shown
above (personal pref).
Slide 52
Look and feel. I prefer the windows theme. You can try both and
see what you like.
Slide 53
To keep multiple objects windows open when you are doing a Find
DB Object click the Freeze Object Viewer checkbox. I would also
recommend unchecking Open Object on a Single Click which requires a
double click to open an object. If you double click without this
then you get a connection busy popup which can be annoying.
Slide 54
Handy shortcut Keys in the editor window Ctrl + / - will
comment out lines you have selected. It is a toggle so it will
uncomment as well. Ctrl + Enter To run a query F10 Will do an
explain on your query F11 will do a commit (be careful of this one)
F12 will do a rollback Ctrl + F7 will format sql (it does a fairly
decent job and is somewhat customizable in the preferences).
Slide 55
There are many more functions that are available to the DBAs
such as: Database Copy Database Diff Database Export Many more
There other features that I am sure that I have missed but
hopefully this is a good start for most everyone.