遠端存取Oracle資料庫

來源:互聯網
上載者:User

下載Oracle用戶端,net服務名與主機的資料庫相同,主機名稱就是主機的ip,記著沒試下主機的監聽程式是否開啟(在命令列下遠行lsnrctl start)。本機連接字串用strConn.Format(_T("Provider=OraOLEDB.Oracle;Password=%s;User ID=%s;Data Source=%s;Persist Security Info=true;"),m_szPassword,m_szUserID,m_szDataSoure);

如有問題,可在UserID後加上server=ipaddress項。

啟動監聽:lsnrctl start

查看監聽:lsnrctl status

停止監聽:lsnrctl stop

1、oracle 資料服務器包括:執行個體進程和資料庫;

執行個體進程包括:memory structure(sga)以及background process(pmon(進程監控)、smon(系統監控system monitor,空間整理3秒)、dbwr(髒資料處理)、lgwr(將redo buffer檔案寫會log),ckpt(checkpoint,同步資料,先寫日誌、髒資料)等進程);

資料庫包括:資料檔案、控制檔案,redo log 檔案,三者是必須的,至於 參數檔案、密碼檔案、歸檔檔案是可選的,根據資料庫的狀態而定;

2、pga:包括user process 和server process,user process通過server process來與oracle的執行個體進行進行通訊。

3、sga=share pool+database buffer cache+redo log buffer + other structures(large pool,java pool可選)

shared_pool=library cache(sql共用,緩衝sql的執行計畫,採用最近最少使用演算法) + data dictionary cache(row cache,資料字典);

database buffer cache(db_cache_size):oracle以block size最為基本的資料讀寫單位

redo log buffer cache:

4、改變參數:

alter system set shared_pool_size=64m;

alter system set db_cache_size=64m;

alter system set large_pool_size=64m;

5、os驗證使用者:

create user id

create group (ora_dba,ora_databasename_dba,ora_oper,ora_databasename_oper)

add user id to group id

edit sqlnet.ora (sqlnet.authentication_services=(nts))

6、忘記system/sys的密碼:

刪掉E:\oracle\product\10.2.0\db_1\database\pwdtestdb.ora;

使用命令:orapwd file=d:\pwdtestdb.ora password=admin1 entries=10;將密碼設定為admin1;

或則:

sqlplus /@testdb as sysdba

alter user sys identified by 新密碼;

alter user system identified by 新密碼;

7、block(塊) extend(盤區) segment(段) tablespace(資料表空間)

8、網路服務的配置資訊在D:\oracle\product\10.2.0\db_1\NETWORK\ADMIN\tnsnames.ora檔案中記錄

資料庫的啟動命令

1、啟動TNS監聽

C:\Documents and Settings\Administrator>lsnrctl start

2、啟動Oracle Services

C:\Documents and Settings\Administrator>net start OracleServiceOrcl

3、以sysdba身份登入

SQL> connect system as sysdba

4、啟動isqlplus

C:\Documents and Settings\Administrator>isqlplusctl start

5、啟動database control

C:\Documents and Settings\Administrator>emctl start dbconsole

如果啟動錯誤,很可能是ip地址進行了修改,可採取如下措施:

set oracle_hostname=主機名稱

emca -config dbcontrol db,進行相應的配置。

6、http://localhost:1158/em/

<開啟控制台輸出>

1、show all

serveroutput OFF

2、set serveroutput on

啟動及關閉模式

Oracle資料庫的幾種啟動和關閉方式

有以下幾種啟動方式:

1、startup nomount

非安裝啟動,這種方式啟動下可執行:重建控制檔案、重建資料庫

讀取init.ora檔案,啟動instance,即啟動SGA和後台進程,這種啟動只需要init.ora檔案。

2、startup mount dbname

安裝啟動,這種方式啟動下可執行:

資料庫日誌歸檔、

資料庫介質恢複、

使資料檔案聯機或離線,

重新置放資料檔案、重做記錄檔。

執行“nomount”,然後開啟控制檔案,確認資料檔案和聯機記錄檔的位置,

但此時不對資料檔案和記錄檔進行校正檢查。

3、startup open dbname

先執行“nomount”,然後執行“mount”,再開啟包括Redo log檔案在內的所有資料庫檔案,

這種方式下可訪問資料庫中的資料。

4、startup,等於以下三個命令

startup nomount

alter database mount

alter database open

5、startup restrict

約束方式啟動

這種方式能夠啟動資料庫,但只允許具有一定特權的使用者訪問

非特權使用者訪問時,會出現以下提示:

ERROR:

ORA-01035: ORACLE 只允許具有 RESTRICTED SESSION 許可權的使用者使用

6、startup force

強制啟動方式

當不能關閉資料庫時,可以用startup force來完成資料庫的關閉

先關閉資料庫,再執行正常啟動資料庫命令

7、startup pfile=參數檔案名稱

帶初始化參數檔案的啟動方式

先讀取參數檔案,再按參數檔案中的設定啟動資料庫

例:startup pfile=E:\Oracle\admin\oradb\pfile\init.ora

8、startup EXCLUSIVE

============================================

有三種啟動方式:

1、shutdown normal

正常方式關閉資料庫。

2、shutdown immediate

立即方式關閉資料庫。

在SVRMGRL中執行shutdown immediate,資料庫並不立即關閉,

而是在Oracle執行某些清除工作後才關閉(終止會話、釋放會話資源),

當使用shutdown不能關閉資料庫時,shutdown immediate可以完成資料庫關閉的操作。

3、shutdown abort

直接關閉資料庫,正在訪問資料庫的會話會被突然終止,

如果資料庫中有大量操作正在執行,這時執行shutdown abort後,重新啟動資料庫需要很長時間。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.