Explain Codes LogoExplain Codes Logo

How to run .sql file in Oracle SQL developer tool to import database?

sql
database-import
sql-developer
oracle
Alex KataevbyAlex Kataev·Oct 31, 2024
TLDR

To import a .sql file in Oracle SQL Developer:

  1. Connect to your desired database.
  2. Open the .sql file via File > Open or drag and drop into the workspace.
  3. Execute the script by clicking the Run Script button or press F5.

Example:

-- Remember the "@" before file path, like a boss @C:\path\to\your_file.sql

Don't forget to end your script with a COMMIT; statement, because changes like to stick around!

Importing .sql files: Things to know

Size matters: Dealing with large .sql files

For mammoth-sized .sql files, running them as scripts is your best bet—your F5 key will thank you, and so will your mouse. Think of it as the 'tapas' style of executing SQL, bite-sized pieces one after another.

Operation File-Open vs. Operation Import

Make sure you master the art of Open File vs. Import. The wizard works well for exports done by SQL Developer's export utility, but for running standard scripts, the open-and-run method won't fail you.

"@" is your new best friend

Anytime you're pointing SQL Developer to an external file, remember to place an "@" before the file path. Think of it as the VIP pass for your script into the Oracle mansion. Don't lose it!

Extra tips and common pitfalls

Check your gear before the climb

Ensure SQL Developer is all set up right with ready JDBC drivers. It's like forgetting your parachute when skydiving, nobody wants that!

Don't get lost in translation

Make sure your .sql script and the database character set are on the same page—encoding-wise. You don't want any miscommunications between parties, causing a linguistic mess!

Syntax—The difference between doing and 'dooing'

Ensure your .sql script isn't riddled with syntax errors, or SQL Developer might send it to the sin-bin! Be sure that the statements are clean and correct.