linux下安装oracle客户端,实现远程连接oracle库,导出数据表
工作中用到不安裝oracle服務端,只安裝客戶端。
一:首先要到下載rpm包,使用如下,命令安裝
rpm -ivh oracle/oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.rpm
//yum install glibc.i686 安裝錯版本包 使用這個修復
/usr/lib/oracle/11.2/client64 oracle環境位置
如需要連接遠程oracle,須配置TNS
#mkdir -p /usr/lib/oracle/11.2/client64/network/admin
#vi /usr/lib/oracle/11.2/client64/network/admin/tnsnames.ora
加入一個Oracle數據庫tns信息
#tnsnames.ora Network Configuration File: /usr/lib/oracle/11.2/client64/network/admin/tnsnames.ora
orcl =
(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 10.61.4.43)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
紅色標示字符串各自對應當前服務器的IP地址與全局數據庫名
vi ~/.bashrc 具體配置信息如下
export ORCL_HOME=/usr/lib/oracle/11.2/client64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORCL_HOME/lib
export TNS_ADMIN=$ORCL_HOME/network/admin
export PATH=$PATH:$ORCL_HOME/bin
ORCL_HOME的具體路徑以本地安裝路徑配置
#vi /etc/ld.so.conf 加入
/usr/lib/oracle/11.2/client/lib/
#/sbin/ldconfig
重啟一下環境變量,或者用戶logout/login一次
#source ~/.bashrc
這樣重新運行
# sqlplus /nolog
SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 8 11:09:58 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL>
成功了
測試一下
#sqlplus myOracleUsername/password@PRODB2
SQL*Plus: Release 11.2.0.2.0 Production on Tue Nov 8 11:11:56 2011
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
SQL> select * from tab;
成功。
如果其他用戶需要使用sqlplus,需要在該用戶的~/.bashrc文件中添加上面提到的3行環境變量
sqlplus64 imei3_dev/imei3_dev@10.61.4.43/orcl 登錄命令
二:linux下導出數據LinuxOracle.sql腳本為
set colsep '|'
set echo off
set feedback off
set newpage none
set verify off
set pagesize 0
set term off
set trims on
set heading off
set timing off
SET termout off
set trimout on
set trimspool on
SET linesize 2500
SPOOL root/ccc.txt
SELECT '2017-10-19 17:59:23','20171018', t.* from tyy t;
SPOOL OFF
quit
shell腳本為
#!/bin/sh sqlplus64 imei3_dev/imei3_dev@10.61.4.43/orcl @/root/LinuxOracle.sql
linux下執行shell腳本即可實現遠程將oracle數據庫表數據down到本地。
load data local infile 'F:\ccc.txt' into table out_table_030 character set 'utf8' fields terminated by ' ' (execute_time,batch_no,id,name,score) //導入數據
?
轉載于:https://www.cnblogs.com/tyydevelop/p/7771176.html
總結
以上是生活随笔為你收集整理的linux下安装oracle客户端,实现远程连接oracle库,导出数据表的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Openshift API部分源码学习笔
- 下一篇: 【C#】详解C#委托