237 lines
8.6 KiB
Batchfile
237 lines
8.6 KiB
Batchfile
@echo off
|
|
rem 相关参数设置
|
|
set OracleConnectString=sys/qrwl@Orcl as sysdba
|
|
set DataFile=D:\OraDataFile\DataFile\
|
|
set TempFile=D:\OraDataFile\TempFile\
|
|
|
|
:menu_content
|
|
echo 批处理功能列表
|
|
:menu_select
|
|
echo ----------------------------------------
|
|
echo (1):创建数据库
|
|
echo (11):创建表空间
|
|
echo (12):创建临时表空间
|
|
echo (13):创建用户
|
|
echo (2):恢复数据库
|
|
echo (21):恢复用户_platform_data
|
|
echo (3):删除数据库
|
|
echo (31):删除表空间
|
|
echo (32):删除临时表空间
|
|
echo (33):删除用户
|
|
echo (4):备份数据库
|
|
echo (41):备份用户_platform_data
|
|
echo (X):退出
|
|
echo ----------------------------------------
|
|
if exist temp.sql del /s/q temp.sql>nul
|
|
set select=
|
|
set /p select=请选择下列编号:
|
|
if /i "%select%" == "1" goto Event_CreateDataBase
|
|
if /i "%select%" == "11" goto Event_CreateDataBase11
|
|
if /i "%select%" == "12" goto Event_CreateDataBase12
|
|
if /i "%select%" == "13" goto Event_CreateDataBase13
|
|
if /i "%select%" == "2" goto Event_RestoreDataBase
|
|
if /i "%select%" == "21" goto Event_RestoreDataBase21
|
|
if /i "%select%" == "3" goto Event_DeleteDataBase
|
|
if /i "%select%" == "31" goto Event_DeleteDataBase31
|
|
if /i "%select%" == "32" goto Event_DeleteDataBase32
|
|
if /i "%select%" == "33" goto Event_DeleteDataBase33
|
|
if /i "%select%" == "4" goto Event_BackupDataBase
|
|
if /i "%select%" == "41" goto Event_BackupDataBase41
|
|
if /i "%select%" == "x" goto end
|
|
cls
|
|
echo.
|
|
echo 请选择正确的菜单编号
|
|
goto menu_select
|
|
|
|
:Event_CreateDataBase
|
|
echo ----------------------------------------
|
|
echo 正在创建数据库...
|
|
if not exist %DataFile% md %DataFile%
|
|
if not exist %TempFile% md %TempFile%
|
|
sqlplus %OracleConnectString% @10_创建数据库.sql
|
|
goto menu_select
|
|
|
|
:Event_CreateDataBase11
|
|
echo ----------------------------------------
|
|
echo 正在创建表空间...
|
|
if not exist %DataFile% md %DataFile%
|
|
if not exist %TempFile% md %TempFile%
|
|
echo @ScriptFile\CreateTablespaces.sql>temp.sql
|
|
echo quit>>temp.sql
|
|
sqlplus %OracleConnectString% @temp.sql
|
|
del temp.sql
|
|
goto menu_select
|
|
|
|
:Event_CreateDataBase12
|
|
echo ----------------------------------------
|
|
echo 正在创建临时表空间...
|
|
if not exist %DataFile% md %DataFile%
|
|
if not exist %TempFile% md %TempFile%
|
|
echo @ScriptFile\CreateTablespaces_Temporary.sql>temp.sql
|
|
echo quit>>temp.sql
|
|
sqlplus %OracleConnectString% @temp.sql
|
|
del temp.sql
|
|
goto menu_select
|
|
|
|
:Event_CreateDataBase13
|
|
echo ----------------------------------------
|
|
echo 正在创建用户...
|
|
if not exist %DataFile% md %DataFile%
|
|
if not exist %TempFile% md %TempFile%
|
|
echo @ScriptFile\CreateUsers.sql>temp.sql
|
|
echo quit>>temp.sql
|
|
sqlplus %OracleConnectString% @temp.sql
|
|
del temp.sql
|
|
goto menu_select
|
|
|
|
:Event_RestoreDataBase
|
|
echo ----------------------------------------
|
|
call 20_恢复数据库.bat %OracleConnectString%
|
|
goto menu_select
|
|
|
|
:Event_RestoreDataBase21
|
|
echo ----------------------------------------
|
|
echo create or replace procedure trade_dictionary.droptables_sequences_views >temp.sql
|
|
echo is >>temp.sql
|
|
echo v_sql varchar2(4000); >>temp.sql
|
|
echo cursor curtable is select table_name from user_tables order by table_name;>>temp.sql
|
|
echo cursor cursequence is select sequence_name from user_sequences order by sequence_name; >>temp.sql
|
|
echo begin >>temp.sql
|
|
echo for currrow in curtable loop >>temp.sql
|
|
echo v_sql := 'drop table ' ^|^| currrow.table_name ^|^| ' cascade constraints'; >>temp.sql
|
|
echo dbms_output.put_line(v_sql); >>temp.sql
|
|
echo execute immediate v_sql; >>temp.sql
|
|
echo end loop;>>temp.sql
|
|
echo for currrow in cursequence loop >>temp.sql
|
|
echo v_sql := 'drop sequence ' ^|^| currrow.sequence_name; >>temp.sql
|
|
echo dbms_output.put_line(v_sql); >>temp.sql
|
|
echo execute immediate v_sql; >>temp.sql
|
|
echo end loop;>>temp.sql
|
|
echo end droptables_sequences_views;>>temp.sql
|
|
echo />>temp.sql
|
|
echo execute trade_dictionary.droptables_sequences_views();>>temp.sql
|
|
echo drop procedure trade_dictionary.droptables_sequences_views;>>temp.sql
|
|
echo quit;>>temp.sql
|
|
sqlplus %OracleConnectString% @temp.sql
|
|
del temp.sql
|
|
imp %OracleConnectString% file=datafile\trade_dictionary.dmp rows=y fromuser=(trade_dictionary) touser=(trade_dictionary) destroy=y ignore=y commit=y log=datafile\trade_dictionary_imp.log
|
|
goto menu_select
|
|
|
|
:Event_RestoreDataBase22
|
|
echo ----------------------------------------
|
|
echo create or replace procedure trade_framework.droptables_sequences_views >temp.sql
|
|
echo is >>temp.sql
|
|
echo v_sql varchar2(4000); >>temp.sql
|
|
echo cursor curtable is select table_name from user_tables order by table_name;>>temp.sql
|
|
echo cursor cursequence is select sequence_name from user_sequences order by sequence_name; >>temp.sql
|
|
echo begin >>temp.sql
|
|
echo for currrow in curtable loop >>temp.sql
|
|
echo v_sql := 'drop table ' ^|^| currrow.table_name ^|^| ' cascade constraints'; >>temp.sql
|
|
echo dbms_output.put_line(v_sql); >>temp.sql
|
|
echo execute immediate v_sql; >>temp.sql
|
|
echo end loop;>>temp.sql
|
|
echo for currrow in cursequence loop >>temp.sql
|
|
echo v_sql := 'drop sequence ' ^|^| currrow.sequence_name; >>temp.sql
|
|
echo dbms_output.put_line(v_sql); >>temp.sql
|
|
echo execute immediate v_sql; >>temp.sql
|
|
echo end loop;>>temp.sql
|
|
echo end droptables_sequences_views;>>temp.sql
|
|
echo />>temp.sql
|
|
echo execute trade_framework.droptables_sequences_views();>>temp.sql
|
|
echo drop procedure trade_framework.droptables_sequences_views;>>temp.sql
|
|
echo quit;>>temp.sql
|
|
sqlplus %OracleConnectString% @temp.sql
|
|
del temp.sql
|
|
imp %OracleConnectString% file=datafile\trade_framework.dmp rows=y fromuser=(trade_framework) touser=(trade_framework) destroy=y ignore=y commit=y log=datafile\trade_framework_imp.log
|
|
goto menu_select
|
|
|
|
:Event_RestoreDataBase23
|
|
echo ----------------------------------------
|
|
echo create or replace procedure trade_module.droptables_sequences_views >temp.sql
|
|
echo is >>temp.sql
|
|
echo v_sql varchar2(4000); >>temp.sql
|
|
echo cursor curtable is select table_name from user_tables order by table_name;>>temp.sql
|
|
echo cursor cursequence is select sequence_name from user_sequences order by sequence_name; >>temp.sql
|
|
echo begin >>temp.sql
|
|
echo for currrow in curtable loop >>temp.sql
|
|
echo v_sql := 'drop table ' ^|^| currrow.table_name ^|^| ' cascade constraints'; >>temp.sql
|
|
echo dbms_output.put_line(v_sql); >>temp.sql
|
|
echo execute immediate v_sql; >>temp.sql
|
|
echo end loop;>>temp.sql
|
|
echo for currrow in cursequence loop >>temp.sql
|
|
echo v_sql := 'drop sequence ' ^|^| currrow.sequence_name; >>temp.sql
|
|
echo dbms_output.put_line(v_sql); >>temp.sql
|
|
echo execute immediate v_sql; >>temp.sql
|
|
echo end loop;>>temp.sql
|
|
echo end droptables_sequences_views;>>temp.sql
|
|
echo />>temp.sql
|
|
echo execute trade_module.droptables_sequences_views();>>temp.sql
|
|
echo drop procedure trade_module.droptables_sequences_views;>>temp.sql
|
|
echo quit;>>temp.sql
|
|
sqlplus %OracleConnectString% @temp.sql
|
|
del temp.sql
|
|
imp %OracleConnectString% file=datafile\trade_module.dmp rows=y fromuser=(trade_module) touser=(trade_module) destroy=y ignore=y commit=y log=datafile\trade_module_imp.log
|
|
goto menu_select
|
|
|
|
:Event_DeleteDataBase
|
|
echo ----------------------------------------
|
|
echo 正在删除数据库...
|
|
sqlplus %OracleConnectString% @30_删除数据库.sql
|
|
goto menu_select
|
|
|
|
:Event_DeleteDataBase31
|
|
echo ----------------------------------------
|
|
echo 正在删除表空间...
|
|
echo @ScriptFile\DropTableSpace.sql>temp.sql
|
|
echo quit>>temp.sql
|
|
sqlplus %OracleConnectString% @temp.sql
|
|
del temp.sql
|
|
goto menu_select
|
|
|
|
:Event_DeleteDataBase32
|
|
echo ----------------------------------------
|
|
echo 正在删除临时表空间...
|
|
echo @ScriptFile\DropTableSpace_Temporary.sql>temp.sql
|
|
echo quit>>temp.sql
|
|
sqlplus %OracleConnectString% @temp.sql
|
|
del temp.sql
|
|
goto menu_select
|
|
|
|
:Event_DeleteDataBase33
|
|
echo ----------------------------------------
|
|
echo 正在删除用户...
|
|
echo @ScriptFile\DropUsers.sql>temp.sql
|
|
echo quit>>temp.sql
|
|
sqlplus %OracleConnectString% @temp.sql
|
|
del temp.sql
|
|
goto menu_select
|
|
|
|
:Event_BackupDataBase
|
|
echo ----------------------------------------
|
|
echo 正在备份数据库...
|
|
if not exist DataFile md DataFile
|
|
call 40_备份数据库.bat %OracleConnectString%
|
|
goto menu_select
|
|
|
|
:Event_BackupDataBase41
|
|
echo ----------------------------------------
|
|
if not exist DataFile md DataFile
|
|
exp %OracleConnectString% owner=(trade_dictionary) rows=y file=datafile\trade_dictionary.dmp log=datafile\trade_dictionary_exp.log
|
|
goto menu_select
|
|
|
|
:Event_BackupDataBase42
|
|
echo ----------------------------------------
|
|
if not exist DataFile md DataFile
|
|
exp %OracleConnectString% owner=(trade_framework) rows=y file=datafile\trade_framework.dmp log=datafile\trade_framework_exp.log
|
|
goto menu_select
|
|
|
|
:Event_BackupDataBase43
|
|
echo ----------------------------------------
|
|
if not exist DataFile md DataFile
|
|
exp %OracleConnectString% owner=(trade_module) rows=y file=datafile\trade_module.dmp log=datafile\trade_module_exp.log
|
|
goto menu_select
|
|
|
|
:end
|
|
@echo on
|
|
|