How to format SQL in Oracle SQL Developer
Oracle SQL Developer has formatted SQL and PL/SQL for years, on a shortcut most people never find because F7 is not where anyone looks for a format command. The formatter itself is capable and the preferences screen is unusually deep — deep enough that its reputation is for being fiddly rather than for being bad. The trick is knowing that there are two layers of settings, a basic Format page and a separate Advanced Format page, and that almost everything you actually want to change lives on the second one.
Short answer
Built in, on Ctrl+F7
Press Ctrl+F7 to format the current editor, or right-click and choose Format. Options are under Tools → Preferences → Code Editor → Format, with the detailed controls behind Advanced Format.
- Windows
- Ctrl+F7
- macOS
- Cmd+F7
Step by step in Oracle SQL Developer
- 01
Format the worksheet
Ctrl+F7 reformats the SQL or PL/SQL in the active editor. The same command is on the right-click menu as Format. There is a second command, Advanced Format on Ctrl+Shift+F7, which opens the formatting options against the current statement so you can see the effect before committing.
- 02
Find the preferences
Tools → Preferences → Code Editor → Format. The main page carries the everyday choices, and the preview panel on the right redraws as you change them, so you can see exactly what each option does to a sample before you apply it to a real package body.
- 03
Go to Advanced Format for the real controls
Tools → Preferences → Format → Advanced Format is where line-break behaviour, case handling and alignment actually live. If you have changed something on the main page and the output did not move, this is where the setting you meant is.
- 04
Set case for keywords and identifiers separately
SQL Developer treats keyword case and identifier case as independent settings, which is the right model for Oracle work — upper-case keywords against unchanged identifiers is the convention most Oracle codebases follow, and getting there needs both switches set deliberately.
- 05
Export the profile so the team shares it
Formatting preferences can be exported and imported through the preferences dialog. Committing that file to the repository is the only realistic way to stop three developers producing three different diffs for the same package.
Oracle (PL/SQL), before and after
The unformatted query below is the sample loaded into the editor above, and the output is exactly what this formatter returns for it with the default options. Nothing was tidied up by hand.
SELECT e.employee_id, e.first_name || ' ' || e.last_name AS full_name, d.department_name, e.salary, RANK() OVER (PARTITION BY e.department_id ORDER BY e.salary DESC) AS salary_rank FROM hr.employees e JOIN hr.departments d ON d.department_id = e.department_id WHERE e.hire_date >= :hired_since AND e.salary BETWEEN :min_salary AND :max_salary AND d.location_id = :location_id ORDER BY d.department_name, salary_rank; SELECT
e.employee_id,
e.first_name || ' ' || e.last_name AS full_name,
d.department_name,
e.salary,
RANK() OVER (
PARTITION BY
e.department_id
ORDER BY
e.salary DESC
) AS salary_rank
FROM
hr.employees e
JOIN hr.departments d ON d.department_id = e.department_id
WHERE
e.hire_date >= :hired_since
AND e.salary BETWEEN :min_salary AND :max_salary
AND d.location_id = :location_id
ORDER BY
d.department_name,
salary_rank; What SQL Developer still won't do
None of this is a knock on SQL Developer — these are just the edges of what an in-editor formatter is for. They are also the reason there is a formatter at the top of this page.
- It formats what it can parse, and it parses Oracle. A Snowflake or BigQuery query pasted into a worksheet is not something SQL Developer will lay out sensibly.
- The two-layer preferences split is genuinely confusing, and there is no way to preview a whole file — only the statement under the cursor.
- The formatter is tied to a desktop install that starts slowly; for a one-off query out of a log file it is a heavy way to get an answer.
- Bind variables are highlighted but never collected — there is nothing that groups the repeated ones so you fill each value once.
SQL Developer SQL formatting FAQ
How do I format a SQL query in Oracle SQL Developer?
Open the query in the SQL Worksheet and press Ctrl+F7 to format the current editor, or right-click and choose Format. Ctrl+Shift+F7 opens Advanced Format, which shows the formatting options applied to the current statement so you can preview before committing.
Where do I change SQL Developer's formatting options?
Tools → Preferences → Code Editor → Format for the basics, and Tools → Preferences → Format → Advanced Format for line breaks, casing and alignment. Most of the settings people go looking for are on the Advanced page.
Why did changing a format preference not change the output?
Almost always because the effective setting is on the Advanced Format page rather than the main Format page. Check there before concluding the option does not work.
How do I uppercase keywords but leave table names alone?
SQL Developer keeps keyword case and identifier case as separate settings, so set keywords to upper case and identifiers to unchanged. Both live in the format preferences.
Can SQL Developer format non-Oracle SQL?
Not usefully — the formatter is built around Oracle SQL and PL/SQL. For other engines use a formatter carrying that grammar; the one on this page supports nineteen dialects and keeps Oracle PL/SQL among them.
How do I share one formatting style across an Oracle team?
Export the formatting preferences from the preferences dialog and commit the file, then have everyone import it. Without that, formatting differences show up as noise in every code review.
Verified 2026-08-20 against