How can I execute a sql file for Oracle from a terminal?

I'm planning to run a SQL file which I expect would run for several hours, so I would like it to run in terminal on my dev server with tmux.  I suppose there should be some way sqlplus can accept a sql file as one of the predicates and execute the sql file.  Is my assumption correct?  If so, could you please provide me with the appropriate syntax?  Thanks.
Who is Participating?
YZlatConnect With a Mentor Commented:
you could run

>sqlplus username@DatabaseName

from command line tool and then enter a password when prompted, provided that Databasename is the entry that exists in tnsnames.ora file

then from SQL propmt run your file as:

SQL> start C:\Test\myfile.sql
Geert GConnect With a Mentor Oracle dbaCommented:
navigate to the directory containing the sqlscript.sql

sqlplus user/password@database @sqlscript

if it runs for several hours, then i assume tuning is still possible
HuaMinChenConnect With a Mentor Business AnalystCommented:
Do like this:

/.../bin/sqlplus /root/@file1.sql

Open in new window

Geert GConnect With a Mentor Oracle dbaCommented:
there is a few docs on how to use sqlplus

hit contents in the top left to learn all there is to know about sqlplus
thomaszhwangAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.