當前位置:首頁 » 操作系統 » linux連接遠程oracle資料庫

linux連接遠程oracle資料庫

發布時間: 2023-03-12 04:33:44

㈠ 如何在linux下連接遠程oracle資料庫

很簡單,你在A電腦安裝一個ORACLE 客戶端,然後,在你所安裝的ORACLE主目錄文件找到tnsnames.ora文件打開,然後,(testdb是你要連接的B伺服器實例名)加入一條記錄如:
TESTDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.xx)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = testdb)
)
)

或者,你在A機器上Oracle Net Manager 手動添加一條記錄,按步驟來。Linux詳細知識需求可參考下《Linux就該這么學》。

㈡ linux系統oracle執行sqlplus找不到

linux系統oracle執行sqlplus找不到是設置錯誤造成的,解決方法為:

1、將ORACLE客戶端rpm安裝包傳輸到linux系統。

㈢ 嵌入式linux設備如何遠程訪問oracle資料庫

不需要客戶端,只要在項目中添加連接oracle資料庫的介面就行了。
比如「c++連接oracle資料庫」的.h文件。

㈣ 本地PLSQL如何通過堡壘機連接遠程linux伺服器上的oracle資料庫

在oracle中配置plsql developer的方法:
1、安裝後,直接打開運行,界面如下:

因為一開始因為未做設置,所以也無法登錄,就點cancel進去,然後點Tools-Preferences,在裡面設置下instantclient basic包的解壓路徑。
2、設置如下兩項:
Oracle Home(empty is autodetect)
D:\instantclient_11_2
OCI library(empty is autodetect)
D:\instantclient_11_2\oci.dll

設置完畢,點OK即可。
3、更改配置文件:
在instantclient basic包目錄下面新建兩個文件,裡面內容如下:
sqlnet.ora:
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES,EZCONNECT)
TNSNAMES.ORA(這是其中一個標簽,可以設置多個這樣的,其中黑斜體部分是需要更改的):
PODS =

(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=
(PROTOCOL=TCP)
(Host=192.168.0.113)
(Port=1521)
)
)
(CONNECT_DATA=
(SID=PODS)
)
)
4、設置環境變數:
添加環境變數:
TNS_ADMIN = D:\instantclient_11_2
5、 現在打開PL/SQL Developer即可去登錄了。

㈤ linux下c++遠程連接oracle資料庫

你說的復合結構應該是結構體吧。若是舉個例子給你看看

/*
* sample2.pc
*
* This program connects to ORACLE, declares and opens a cursor,
* fetches the names, salaries, and commissions of all
* salespeople, displays the results, then closes the cursor.
*/
#include <stdio.h>
#include <sqlca.h>
#define UNAME_LEN 20
#define PWD_LEN 40
/*
* Use the precompiler typedef』ing capability to create
* null-terminated strings for the authentication host
* variables. (This isn』t really necessary--plain char *』s
* does work as well. This is just for illustration.)
*/
typedef char asciiz[PWD_LEN];
EXEC SQL TYPE asciiz IS STRING(PWD_LEN) REFERENCE;
asciiz username;
asciiz password;
struct emp_info
{
asciiz emp_name;
float salary;
float commission;
};
/* Declare function to handle unrecoverable errors. */
void sql_error();
main()
{
struct emp_info *emp_rec_ptr;
/* Allocate memory for emp_info struct. */
if ((emp_rec_ptr =
(struct emp_info *) malloc(sizeof(struct emp_info))) == 0)
{
fprintf(stderr, "Memory allocation error. ");
exit(1);
}
/* Connect to ORACLE. */
strcpy(username, "SCOTT");
strcpy(password, "TIGER");
EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--");
EXEC SQL CONNECT :username IDENTIFIED BY :password;
printf(" Connected to ORACLE as user: %s ", username);
/* Declare the cursor. All static SQL explicit cursors
* contain SELECT commands. 』salespeople』 is a SQL identifier,
* not a (C) host variable.
*/
EXEC SQL DECLARE salespeople CURSOR FOR
SELECT ENAME, SAL, COMM FROM EMP WHERE JOB LIKE 』SALES%』;
/* Open the cursor. */
EXEC SQL OPEN salespeople;
/* Get ready to print results. */
printf(" The company』s salespeople are-- ");
printf("Salesperson Salary Commission ");
printf("----------- ------ ---------- ");
/* Loop, fetching all salesperson』s statistics.
* Cause the program to break the loop when no more
* data can be retrieved on the cursor.
*/
EXEC SQL WHENEVER NOT FOUND DO break;
for (;;)
{
EXEC SQL FETCH salespeople INTO :emp_rec_ptr;
printf("%-11s%9.2f%13.2f ", emp_rec_ptr->emp_name,emp_rec_ptr->salary, emp_rec_ptr->commission);
}
/* Close the cursor. */
EXEC SQL CLOSE salespeople;
printf(" Arrivederci. ");
EXEC SQL COMMIT WORK RELEASE;
exit(0);
}
void sql_error(msg) char *msg;
{
char err_msg[512];
int buf_len, msg_len;
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf(" %s ", msg);
/* Call sqlglm() to get the complete text of the
* error message.
*/
buf_len = sizeof (err_msg);
sqlglm(err_msg, &buf_len, &msg_len);
printf("%.*s ", msg_len, err_msg);
EXEC SQL ROLLBACK RELEASE;
exit(1);
}

㈥ 如何連接到linux上的oracle資料庫

裝好oracle資料庫,我們准備用PLSQL Developer 這個軟體來連接伺服器的資料庫!

下面簡單介紹設置此軟體並連接oracle資料庫的方法:

一、下載並安裝好PLSQL Developer(綠色版的也可以);

二、下載並解壓

Oracle免安裝版的客戶端:

http://download.oracle.com/otn/nt/instantclient/112030/instantclient-basic-nt-11.2.0.3.0.zip



三、建立tns配置文件。
1、在解壓的:「nstantclient-basic-nt-11.2.0.3.0」文件夾的下面建文件夾,路徑像這樣「nstantclient-basic-nt-11.2.0.3.0 eidownadmin「,其實這個倒是無所謂的,只是看起來與服務端上的更接近而已,與文章後面的環境變數要對應。
2、拷貝服務端目錄「$ORACLE_HOME$ etworkadmin nsnames.ora」到客戶端的「nstantclient-basic-nt-11.2.0.3.0 eidownadmin「目錄,這個文件的內容如下:(也可自行建立)

  • # tnsnames.ora Network Configuration File: /home/oradb/oracle/proct/11.2.0/db_1/network/admin/tnsnames.ora

  • # Generated by Oracle configuration tools.

  • ORCL =

  • (DESCRIPTION =

  • (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))

  • (CONNECT_DATA =

  • (SERVER = DEDICATED)

  • (SERVICE_NAME = orcl.localdomain)

  • )

  • )

  • 復制代碼以上的代碼 做個簡要的介紹,本例中安裝在linux中的oracle資料庫,其環境配置如下:
  • ORACLE_BASE=/home/oradb/oracle

  • ORACLE_HOME=$ORACLE_BASE/proct/11.2.0/db_1

  • ORACLE_SID=orcl

  • PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

  • LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

  • LANG=C

  • 復制代碼拷貝到客戶端後,用記事本打開它,修改如下幾個參數:
  • # tnsnames.ora Network Configuration File: /home/oradb/oracle/proct/11.2.0/db_1/network/admin/tnsnames.ora

  • # Generated by Oracle configuration tools.

  • ORCL =

  • (DESCRIPTION =

  • (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.10)(PORT = 1521))

  • (CONNECT_DATA =

  • (SERVER = DEDICATED)

  • (SERVICE_NAME = orcl.localdomain)

  • )

  • )

  • 復制代碼重要:以上除了HOST是伺服器ip外,其他三個紅字必須與服務端的這個文件一致,否則連接的時候將會導致ORA-12514錯誤。


  • 四、設置PLSQL Developer程序的oci庫路徑。

  • 運行PLSQL Developer程序,在彈出的登錄框點「取消」

  • 在菜單「工具-首選項」中的「連接」中,

    找到「Oracle主目錄名」,輸入

  • 解壓的:「nstantclient-basic-nt-11.2.0.3.0」文件夾的路徑 比如:

  • "D:PLSQLinstantclient_11_2"

  • 找到「OCI庫」,輸入

  • 解壓的:「nstantclient-basic-nt-11.2.0.3.0」文件夾下oci.dll文件的路徑,比如:

  • "D:PLSQLinstantclient_11_2oci.dll"

  • 如下圖:



  • 如果伺服器中的資料庫字元編碼是GBK則設置為:SIMPLIFIED CHINESE_CHINA.ZHS16GBK

  • 如果設置不對會亂碼。

  • 注意:設定了環境變數之後,要注銷或者重啟電腦生效。

㈦ telnet 遠程linux伺服器導出oracle資料庫到本地,命令要怎麼寫

操作順序:
1、打開本地終端,輸入telnet命令:
>> telnet 伺服器ip
輸入用戶名 密碼 登陸成功
2、轉到oracle用戶下,輸入:
>> su - oracle
>> exp
根據Oracle的exp命令提供的到處向導,導出用戶需要的數據到dmp文件中 myxxxoutxxx.dmp
3、接下來是講這個dmp文件傳到本地
兩種方式
1、如果伺服器端開啟了ftpd 或者 sshd ,可以從本地連接過去,把dmp文件下載到本地
重新打開一個本地終端
>> ftp 伺服器ip
輸入用戶名 密碼 登陸成功
>> cd dmp文件目錄的相對路徑
>> get myxxxoutxxx.dmp
2、如果本地伺服器開啟了相關服務 可以從伺服器端上傳dmp文件到本地
>> cd dmp文件目錄的路徑
>> ftp 伺服器ip
輸入用戶名 密碼 登陸成功
>> put myxxxoutxxx.dmp
最後就是本地庫的導入了
在終端中輸入 imp 根據向導一步一步設置導入
或者用開發工具幫助導入

熱點內容
sql獲取小時 發布:2025-08-22 22:10:58 瀏覽:670
大同網通dns伺服器地址 發布:2025-08-22 22:02:22 瀏覽:591
javarsa的是 發布:2025-08-22 21:51:58 瀏覽:712
ftp解析域名解析 發布:2025-08-22 21:48:30 瀏覽:538
與佛論道加密 發布:2025-08-22 21:41:42 瀏覽:345
cs架構語言 發布:2025-08-22 21:34:35 瀏覽:883
安防監控存儲 發布:2025-08-22 21:20:38 瀏覽:800
java高級培訓哪裡好 發布:2025-08-22 21:16:56 瀏覽:170
套杯演算法 發布:2025-08-22 21:15:20 瀏覽:253
unrealengine源碼 發布:2025-08-22 21:02:13 瀏覽:96