Scene:
The DBA gave me the creation scripts for all the storage, functions, and so on, with thousands of files.
Now you need to import these object creation scripts into another library, how do you solve them?
Manual execution is obviously not realistic.
So manually wrote a batch, all the files into one. SQL scripts, which are generated at the end of @. SQL scripts are imported into the target library.
OS Environment: WINDOWS XP
The script reads as follows:
@echo off
if exist List.sql del list.sql/q
: input
cls
set input=:
set/p input= Please enter the path to be judged: C7/>set "Input=%input:" "=%"
:: The above sentence to determine whether there are quotes in the%input%, and then remove.
if "%input%" = = ":" Goto input
if not exist "%input%" goto input
for/f "delims="%%i in (' dir/b/a-d/S "%i nput% "') do echo @@%%~fnxi>>list.sql
if not exist list.sql goto no_file
start List.sql
exit
: No_file
cls
echo %cur_dir% error, List.sql script not successfully generated!
Pause
Use:
Save As. BAT type file, double-click Execute.
Enter the path to your script:
As in my e-disk cry folder, there are the following types of files:
TEST. PRC
...
123test1. FNC (with subfolder 123)
...
TEST2. VW
..
After the batch process is executed, the resulting List.sql script file is as follows (the file is automatically opened with the default editor after the batch is executed):
@@e:crytest.prc
...
@@e:cry123test1.fnc
...
@@e:crytest2.vw
...
Open Sqlplus to specify that the user log on to the database and execute: (My script file is generated in D disk)
@d:list.sql
All objects are automatically generated under the specified user.
---------------------------
Note: Many of these generated objects are not valid because they are not generated sequentially, so it is recommended that you compile any invalid objects after automatic execution.