时间:2021-07-01 10:21:17 帮助过:47人阅读
声明: 本文均为作者本人(iihero@CSDN)探索学习Oracle数据库过程当中的经验总结,其方法或过程只能用于开发和学习,不能将其用于商业产品发布,违者后果自负。 Oracle数据库的客户端向来以“肥大”著称,即使是它的instant client,也不算瘦。个人以为,虽然i
声明: 本文均为作者本人(iihero@CSDN)探索学习Oracle数据库过程当中的经验总结,其方法或过程只能用于开发和学习,不能将其用于商业产品发布,违者后果自负。
Oracle数据库的客户端向来以“肥大”著称,即使是它的instant client,也不算瘦。个人以为,虽然instant client发布并使用了有一段时间,但是比起它的原装产品来说,稳定性和安全性肯定有些差距。所以,我宁可自己手动extract一些有用的包,为开发所用,也不愿意去单独折腾个instant client来配置。
这里就以9i为例,在你安装完一份Oracle服务器版或Oracle客户端,在安装的目标目录会有一份完整的目录列表。有很多很多都是用不着的文件。
我们通常要用的功能也就是:
1. sqlplus命令行,imp, exp, tnsping, sqlldr (用于管理)
2. oci接口库,pro*c库,jdbc, odbc (甚或oledb)等 (用于开发)
有了这些功能,基本上可以做很多事情了。
制作原理:
1. 抽取相关目录,发布到一个新目录。
2. 生成注册表文件到这个新目录。
3. 将这个新目录复制或移动到新机器的新目录里边,就可以注册使用了。
下边是我编写的一个发布的批处理脚本oraclient_dist.bat,以及过滤文件exclude.txt
exclude.txt 文件要与oraclient_dist.bat文件位于同一目录当中
其命令格式是:
oraclient_dist.bat -from d:/oracle/ora92 -to e:/dist -inst d://ora92client
意思是从源:d:/oracle/ora92目录下边提取免安装包到目录e:/dist里头,最终安装目录定制在d:/ora92client。
@echo off rem rem Copyright (c) 2005 ~ 2009, iihero@CSDN rem rem This script will ship an Simple Oracle client from an rem installed Oracle9i/10g server or client package. rem rem Any issues, please notify me: iiihero@hotmail.com rem This script only can be used for learning/researching on oracle db. rem setlocal :LOOP set arg=%1 if %arg%! == ! goto END_LOOP if %arg%! == -help! goto SET_HELP if %arg%! == -h! goto SET_HELP if %arg%! == -from! goto SET_FROM if %arg%! == -to! goto SET_TO if %arg%! == -inst! goto SET_INST goto LOOP :SET_FROM shift set ORA_FROM=%1 shift goto LOOP :SET_TO shift set ORA_TO=%1 shift goto LOOP :SET_INST shift set INSTALL_DIR=%1 shift goto LOOP :END_LOOP echo ORA_FROM = %ORA_FROM% if %ORA_FROM%! == ! set ORA_FROM=%ORACLE_HOME% if %ORA_FROM%! == ! goto ERROR_RUNTIME if %ORA_TO%! == ! goto SET_HELP if not exist %ORA_TO% goto SET_HELP if %INSTALL_DIR%! == ! goto SET_HELP mkdir %ORA_TO%\oracle set ORACLIENT="%ORA_TO%\oracle" echo "Begin distribute files into %ORACLIENT%" mkdir "%ORACLIENT%\network" xcopy "%ORA_FROM%\network\admin" "%ORACLIENT%\network\admin" /Q /S /I xcopy "%ORA_FROM%\network\mesg" "%ORACLIENT%\network\mesg" /Q /S /I xcopy "%ORA_FROM%\ocommon\nls\admin" "%ORACLIENT%\ocommon\nls\admin" /Q /S /I xcopy "%ORA_FROM%\ocommon\nls\mesg" "%ORACLIENT%\ocommon\nls\mesg" /Q /S /I xcopy "%ORA_FROM%\odbc" "%ORACLIENT%\odbc" /Q /S /I xcopy "%ORA_FROM%\oracore" "%ORACLIENT%\oracore" /Q /S /I xcopy "%ORA_FROM%\rdbms\mesg" "%ORACLIENT%\rdbms\mesg" /Q /S /I xcopy "%ORA_FROM%\sqlplus\mesg" "%ORACLIENT%\sqlplus\mesg" /Q /S /I xcopy "%ORA_FROM%\bin" "%ORACLIENT%\bin" /Q /S /I /EXCLUDE:exclude.txt xcopy "%ORA_FROM%\oci\lib" "%ORACLIENT%\oci\lib" /Q /S /I xcopy "%ORA_FROM%\oci\include" "%ORACLIENT%\oci\include" /Q /S /I xcopy "%ORA_FROM%\jdbc\lib" "%ORACLIENT%\jdbc\lib" /Q /S /I xcopy "%ORA_FROM%\jdbc\Readme.txt" "%ORACLIENT%\jdbc\" /Q /S /I xcopy "%ORA_FROM%\precomp\admin" "%ORACLIENT%\precomp\admin" /Q /S /I xcopy "%ORA_FROM%\precomp\mesg" "%ORACLIENT%\precomp\mesg" /Q /S /I xcopy "%ORA_FROM%\precomp\lib" "%ORACLIENT%\precomp\lib" /Q /S /I xcopy "%ORA_FROM%\precomp\public" "%ORACLIENT%\precomp\public" /Q /S /I echo "Begin register entry into %ORACLIENT%\oraclient.reg" echo Windows Registry Editor Version 5.00 >> %ORACLIENT%\oraclient.reg echo [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\Oracle in OraHome] >> %ORACLIENT%\oraclient.reg echo "APILevel"="1" >> %ORACLIENT%\oraclient.reg echo "CPTimeout"="60" >> %ORACLIENT%\oraclient.reg echo "ConnectFunctions"="YYY" >> %ORACLIENT%\oraclient.reg echo "Driver"="%INSTALL_DIR%\\BIN\\SQORA32.DLL" >> %ORACLIENT%\oraclient.reg echo "DriverODBCVer"="03.51" >> %ORACLIENT%\oraclient.reg echo "FileUsage"="0" >> %ORACLIENT%\oraclient.reg echo "Setup"="%INSTALL_DIR%\\BIN\\SQORAS32.DLL" >> %ORACLIENT%\oraclient.reg echo "SQLLevel"="1" >> %ORACLIENT%\oraclient.reg echo [HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE] >> %ORACLIENT%\oraclient.reg echo "ORACLE_HOME"="%INSTALL_DIR%" >> %ORACLIENT%\oraclient.reg echo "ORACLE_HOME_NAME"="OraHome" >> %ORACLIENT%\oraclient.reg echo "NLS_LANG"="NA" >> %ORACLIENT%\oraclient.reg echo [HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\ALL_HOMES] >> %ORACLIENT%\oraclient.reg echo "HOME_COUNTER"="1" >> %ORACLIENT%\oraclient.reg echo "DEFAULT_HOME"="OraHome" >> %ORACLIENT%\oraclient.reg echo "LAST_HOME"="0" >> %ORACLIENT%\oraclient.reg echo [HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\ALL_HOMES\ID0] >> %ORACLIENT%\oraclient.reg echo "NAME"="OraHome" >> %ORACLIENT%\oraclient.reg echo "PATH"="%INSTALL_DIR%" >> %ORACLIENT%\oraclient.reg echo "NLS_LANG"="NA" >> %ORACLIENT%\oraclient.reg echo [HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0] >> %ORACLIENT%\oraclient.reg echo "ID"="0" >> %ORACLIENT%\oraclient.reg echo "ORACLE_GROUP_NAME"="Oracle - OraHome" >> %ORACLIENT%\oraclient.reg echo "ORACLE_HOME_NAME"="OraHome" >> %ORACLIENT%\oraclient.reg echo "ORACLE_HOME"="%INSTALL_DIR%" >> %ORACLIENT%\oraclient.reg echo "NLS_LANG"="SIMPLIFIED CHINESE_CHINA.ZHS16GBK" >> %ORACLIENT%\oraclient.reg echo "ORACLE_HOME_KEY"="Software\\ORACLE\\HOME0" >> %ORACLIENT%\oraclient.reg echo "Begin genrating readme file for Oracle client into %ORACLIENT%\readme.txt" echo 本程序是Oracle 9.2 for windows的简化客户端版本。>> %ORACLIENT%\readme.txt echo 带有最基础的一些功能: sqlplus(w), exp, imp, oci, pro*c, ocopy, tkprof, tnsping, odbc, jdbc>> %ORACLIENT%\readme.txt echo 1. 将%ORACLIENT%目录移动到目标目录: %INSTALL_DIR", >> %ORACLIENT%\readme.txt echo 2. 导入注册表oracleint.reg之后,将bin目录全路径添加到path之后,>> %ORACLIENT%\readme.txt echo 3. 编辑%INSTALL_DIR%\network\admin\tnsnames.ora文件,添加适当的servicename>> %ORACLIENT%\readme.txt echo 就可以正常使用.>> %ORACLIENT%\readme.txt>> %ORACLIENT%\readme.txt echo 有问题,欢迎联系:iiihero@hotmail.com (iihero@CSDN)>> %ORACLIENT%\readme.txt echo "Successfully distribute oracle client into %ORACLIENT%!!!" goto END :SET_HELP echo "Usage:" echo "oraclient_dist -from-to -inst " echo "eg: oraclient_dist -from d:\oracle\ora92 -to f:\income -inst d:\\ora92" echo "InstallDir format: d:\\ora92 (there should be 2 '\' in the path)" echo "Thanks! iiihero@hotmail.com (iihero@CSDN) " goto END :ERROR_RUNTIME echo "Please set ORACLE_HOME or use as the help" :END endlocal
最终你还可以将目标目录压缩,也就30来M,最终使用时,参见发布后生成的readme.txt文件。
exclude.txt文件内容如下:
C-sharp代码