Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: run sql script from command line?
What you are asking is technical possible, but are you sure that each time
you run your program you want to create a new database rather than just
creating the database separately and then when you run your script bring
the database up and shut it down when you finish? It takes about +15
minutes to create a database while it only takes a few seconds to
mount/open an existing database.
However, if this is what you really want to do, then do it like this:
#!/bin/ksh
svrmgrl <<sqlEOF
connect internal
@createdb.sql
sqlEOF
#more shell commands or program invocations go here
svrmgrl <<sqlEOF
connect internal
shutdown
sqlEOF
# have a command here to delete all of your database files (ctl, dbf, etc) exit 0;
Where createdb.sql is the name of the script in which you create the database.
By the way - I don't recommend that you do it this way unless you really, truely, most assuredly, absolutely want to create and delete your database every time that you run your program and you do not want to preserve the contents of the database between runs.
kev wrote:
> Hi,
>
> I have a script which I currently run in svrmgrl to create a demo
> database.
>
> Can I run svrmgrl, connect to the DB and run my script from the command
> line, preferably with a single command?
> The reason for this is so that I can fire up my demo database from
> within a script, using a "system( <command> )" function.
>
> Thanks in advance,
>
> - Kev
Received on Fri Aug 06 1999 - 12:59:40 CDT
![]() |
![]() |