appear by default in blue and other statement criteria appear in black. Syntax highlighting, illustrated in Figure 12, can greatly
improve your code’s readability, enabling
you and others to spot errors more readily.
Syntax highlighting, along with the other
Oracle SQL Developer formatting facilities
I’ve described in this article, can be edited or
disabled via Tools -> Preferences. By default,
they are enabled and exhibit the behavior
and results shown in this article.
Figure 10: SQL Formatter options in Oracle SQL Developer
Worksheet and choose Format (or type Ctrl-
F7). (Be aware that selecting this option
affects all the code in the SQL Worksheet—
as of Oracle SQL Developer Release 3.0.04).
To set your preferences for this option, select
Tools -> Preferences -> Database -> SQL
Formatter -> Oracle Formatting and click
Edit. Figure 10 shows some of the available
formatting options.
CONCLUSION
This article has shown you how to construct
and execute simple SQL SELECT statements
with Oracle SQL Developer and the SQL
Workshop SQL Commands facility in Oracle
Application Express. You’ve also seen how
the formatting, syntax highlighting, and
code completion facilities in Oracle SQL
Developer can enhance your code’s readability and accuracy.
The next installment of SQL 101 will
examine the WHERE and ORDER BY clauses
of a SQL statement and take a closer look at
Oracle’s SQL*Plus tool.
Figure 11: Code completion facility in Oracle SQL
Developer
FINISHING YOUR THOUGHT
You might occasionally need to refer to your
schema diagram to identify the table(s)
you want to include in a query or to look up
the syntax for correct statement construction in the Oracle documentation. The code
completion facility in Oracle SQL Developer
helps you with both tasks. If you pause while
typing your statement, the code completion
facility will prompt you with a list of appropriate table names, column names, and
commands you can select from. Figure 11
shows an example of this feature in action.
Melanie Caffrey is
a senior development
manager at Oracle. She
coauthored Expert
PL/SQL Practices
for Oracle Developers
and DBAs (Apress, 2011) and Expert Oracle
Practices: Oracle Database Administration from
the Oak Table (Apress, 2010).
NEXT STEPS
Figure 12: Syntax highlighting in Oracle SQL
Developer
SQL Worksheet, and selecting To Upper/
Lower/InitCap (or typing Ctrl+Quote), as
shown in Figure 8.
Figure 9 shows the result of changing a
statement’s keywords to uppercase via the
mechanism illustrated in Figure 8.
Another way to control your code’s
formatting is to right-click in the SQL
HIGHLIGHT YOUR CODE
Syntax highlighting in Oracle SQL Developer
marks the SQL language keywords in your
code with a color different from that of the
table names, column names, and other
statement criteria. When this feature is
enabled, your SQL language commands
READ more about relational database design,
concepts, and SQL
Oracle Database Concepts 11g Release 2 ( 11. 2)
bit.ly/aonqPP
Oracle Database SQL Language Reference 11g
Release 1 ( 11. 1)
bit.ly/jYXQZn
Oracle SQL Developer User’s Guide Release 2. 1
bit.ly/sueELL
DOWNLOAD
Oracle Database, Express Edition 11g
bit.ly/tRw2un
Oracle SQL Developer
bit.ly/tGl3GL
Oracle Application Express
bit.ly/sYcjow
JANUARY/FEBRUARY 2012 ORACLE.COM/ORACLEMAGAZINE