oracle 更改數(shù)據(jù)庫名的方法
更新時(shí)間:2009年10月24日 00:32:11 作者:
這兩天一朋友問如何更改數(shù)據(jù)庫名,于是做個(gè)測(cè)試,簡(jiǎn)單記錄下,以便說明問題。
如何修改數(shù)據(jù)庫名(db_name)及實(shí)例名(Instance_name or Service_name)
Nid是Oracle從9iR2開始提供的工具,可以用來更改數(shù)據(jù)庫名稱,而無需通過之前重建控制文件等繁瑣方式。
nid是自帶的工具,在oracle_home/bin目錄中.以下方法假設(shè)登陸到數(shù)據(jù)庫本機(jī)做。
目的:在本例中,假設(shè)原來的數(shù)據(jù)庫名為orcl,要改成dborcl,原實(shí)例名(service_name,instance_name)orcl,要改成dborcl.
步驟概述:
1.檢查當(dāng)前的參數(shù)情況
2.shutdown數(shù)據(jù)庫,然后mount數(shù)據(jù)庫
3.運(yùn)行nid命令
4.更改參數(shù)文件pfile.ora(db_name,instance_name)
5.檢測(cè)更改情況
6.如果是windows平臺(tái),要修改服務(wù)
7.修改監(jiān)聽服務(wù)
C:\Documents and Settings\Administrator>sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 10月 22 11:56:33 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
1. 查看更改前的相應(yīng)名稱
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string orcl
db_unique_name string orcl
global_names boolean FALSE
instance_name string orcl
lock_name_space string
log_file_name_convert string
service_names string orcl
2. --先shutdown數(shù)據(jù)庫
SQL> shutdown immediate
數(shù)據(jù)庫已經(jīng)關(guān)閉。
已經(jīng)卸載數(shù)據(jù)庫。
ORACLE 例程已經(jīng)關(guān)閉。
3. --nid需要在mount狀態(tài)下才能做。因?yàn)橐目刂莆募男畔?
SQL> startup mount
ORACLE 例程已經(jīng)啟動(dòng)。
Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 180358020 bytes
Database Buffers 423624704 bytes
Redo Buffers 7135232 bytes
數(shù)據(jù)庫裝載完畢。
nid是操作系統(tǒng)的命令,所以要用host
SQL> host nid -help
DBNEWID: Release 10.2.0.1.0 - Production on Fri Oct 23 13:40:54 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Keyword Description (Default)
----------------------------------------------------
TARGET Username/Password (NONE)
DBNAME New database name (NONE)
LOGFILE Output Log (NONE)
REVERT Revert failed change NO
SETNAME Set a new database name only NO
APPEND Append to output log NO
HELP Displays these messages NO
以上是nid命令的語法
4。 --運(yùn)行nid命令
SQL> host nid target=sys/aibo dbname=dborcl
DBNEWID: Release 10.2.0.1.0 - Production on 星期四 10月 22 11:58:27 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
已連接數(shù)據(jù)庫 ORCL (DBID=1224293825)
已連接服務(wù)器版本 10.2.0
數(shù)據(jù)庫中的控制文件數(shù):
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CTL
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL03.CTL
是否將數(shù)據(jù)庫 ID 和數(shù)據(jù)庫名 ORCL 更改為 DBORCL? (Y/[N]) => y
操作繼續(xù)進(jìn)行
將數(shù)據(jù)庫 ID 從 1224293825 更改為 3277448932
將數(shù)據(jù)庫名從 ORCL 更改為 DBORCL
控制文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CTL - 已修改
控制文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL - 已修改
控制文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL03.CTL - 已修改
數(shù)據(jù)文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF - dbid 已更改,
已寫入新名稱
數(shù)據(jù)文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF - dbid 已更改,
已寫入新名稱
數(shù)據(jù)文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF - dbid 已更改,
已寫入新名稱
數(shù)據(jù)文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF - dbid 已更改, 已
寫入新名稱
數(shù)據(jù)文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF - dbid 已更改,
已寫入新名稱
數(shù)據(jù)文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF - dbid 已更改, 已
寫入新名稱
控制文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CTL - dbid 已更改,
已寫入新名稱
控制文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL - dbid 已更改,
已寫入新名稱
控制文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL03.CTL - dbid 已更改,
已寫入新名稱
實(shí)例關(guān)閉
數(shù)據(jù)庫名已更改為 DBORCL。
修改參數(shù)文件并在重新啟動(dòng)前生成新的口令文件。
數(shù)據(jù)庫 DBORCL 的數(shù)據(jù)庫 ID 已更改為 3277448932。
此數(shù)據(jù)庫的所有以前的備份和歸檔重做日志均不可用。
數(shù)據(jù)庫無法識(shí)別恢復(fù)區(qū)中以前的備份和歸檔日志。
數(shù)據(jù)庫已關(guān)閉, 用 RESETLOGS 選項(xiàng)打開數(shù)據(jù)庫。
已成功更改數(shù)據(jù)庫名和 ID。
DBNEWID - 已成功完成。
5. ---shutdown數(shù)據(jù)庫
SQL> shutdown immediate
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SQL> startup nomount
ORACLE 例程已經(jīng)啟動(dòng)。
Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 180358020 bytes
Database Buffers 423624704 bytes
Redo Buffers 7135232 bytes
SQL> create pfile='D:\oracle\product\10.2.0\pfile20091022.ora' from spfile;
文件已創(chuàng)建。
SQL> shutdown immediate;
ORA-01507: ??????
6. ---修改初始化參數(shù)文件、spfile文件(init.ora/spfile)
###########################################
instance_name=eyglen
#instance_name=eyglev
###########################################
db_domain=""
db_name=eyglen
# db_name=eyglev
###########################################
7. ---以修改后的參數(shù)啟動(dòng)數(shù)據(jù)庫
SQL> startup pfile='D:\oracle\product\10.2.0\pfile20091022.ora'
ORACLE 例程已經(jīng)啟動(dòng)。
Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 180358020 bytes
Database Buffers 423624704 bytes
Redo Buffers 7135232 bytes
數(shù)據(jù)庫裝載完畢。
ORA-01589: 要打開數(shù)據(jù)庫則必須使用 RESETLOGS 或 NORESETLOGS 選項(xiàng)
SQL> create spfile from pfile='D:\oracle\product\10.2.0\pfile20091022.ora'
2 ;
文件已創(chuàng)建。
SQL> shutdown immediate
ORA-01109: 數(shù)據(jù)庫未打開
已經(jīng)卸載數(shù)據(jù)庫。
ORACLE 例程已經(jīng)關(guān)閉。
SQL> startup
ORACLE 例程已經(jīng)啟動(dòng)。
Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 180358020 bytes
Database Buffers 423624704 bytes
Redo Buffers 7135232 bytes
數(shù)據(jù)庫裝載完畢。
ORA-01589: 要打開數(shù)據(jù)庫則必須使用 RESETLOGS 或 NORESETLOGS 選項(xiàng)
SQL> alter database open noresetlogs
2 ;
alter database open noresetlogs
*
第 1 行出現(xiàn)錯(cuò)誤:
ORA-01588: 要打開數(shù)據(jù)庫則必須使用 RESETLOGS 選項(xiàng)
SQL> alter database open resetlogs
2 ;
數(shù)據(jù)庫已更改。
8. --現(xiàn)在數(shù)據(jù)庫已經(jīng)啟動(dòng)了啊,那就檢查下吧,看看是否已經(jīng)修改了
SQL> select open_mode from v$database;
OPEN_MODE
----------
READ WRITE
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string dborcl
db_unique_name string dborcl
global_names boolean FALSE
instance_name string dborcl
lock_name_space string
log_file_name_convert string
service_names string dborcl
SQL>
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
orcl
9. 發(fā)現(xiàn)v$instance里的沒有修改過來,這是因?yàn)樵趙indows平臺(tái),繼續(xù)如下操作
********如果是windows平臺(tái),v$instance里的instanc_name沒有變, 繼續(xù)如下操作
passwd文件通常放在oracle_home/database目錄下,文件命名形式為PWDsid.ora,sid為實(shí)例名(Service_name),
如當(dāng)前的數(shù)據(jù)庫名及service_name為orcl,則passwd文件為PWDorcl.ora
C:\Documents and Settings\Administrator>orapwd file=D:\oracle\product\10.2.0\db_
1\database\PWDdborcl.ora password=aibo entries=5
要注意一下,此時(shí)雖然數(shù)據(jù)庫名已經(jīng)改成dborcl了,但instance_name還是orcl,所以,passwd文件必須跟以前一樣。否則會(huì)出錯(cuò)。
10. 刪除以前的實(shí)例orcl
C:\Documents and Settings\Administrator>oradim -delete -sid orcl
實(shí)例已刪除。
11. 創(chuàng)建新的實(shí)例名 dborcl
C:\Documents and Settings\Administrator>oradim -new -sid dborcl -intpwd aibo -st
artmode a -pfile D:\oracle\product\10.2.0\pfile20091022.ora
OPW-00005: 存在相同名稱的文件 - 請(qǐng)刪除或重命名
實(shí)例已創(chuàng)建。
12.
C:\Documents and Settings\Administrator>set oracle_sid=dborcl
C:\Documents and Settings\Administrator>sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 10月 22 13:41:12 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> quit
從 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 斷開
13.檢查服務(wù)名
C:\Documents and Settings\Administrator>lsnrctl reload
LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 22-10月-2009 13:4
3:13
Copyright (c) 1991, 2005, Oracle. All rights reserved.
正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.56)(PORT=1521)))
命令執(zhí)行成功
C:\Documents and Settings\Administrator>sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 10月 22 13:43:21 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select open_mode from v$database;
OPEN_MODE
----------
READ WRITE
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
dborcl
SQL> show parameter name;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string dborcl
db_unique_name string dborcl
global_names boolean FALSE
instance_name string dborcl
lock_name_space string
log_file_name_convert string
service_names string dborcl
SQL> quit
從 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 斷開
檢查service是否被更改
C:\Documents and Settings\Administrator>tnsping dborcl
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 22-10月-
2009 13:50:00
Copyright (c) 1997, 2005, Oracle. All rights reserved.
已使用的參數(shù)文件:
D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
已使用 EZCONNECT 適配器來解析別名
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=dborcl.gdgg.local
))(ADDRESS=(PROTOCOL=TCP)(HOST=202.106.195.30)(PORT=1521)))
^C
測(cè)試不通過,說明dborcl配置有問題
修改tnsnames.ora文件,添加如下內(nèi)容:
×××××××××××××××××××××××××××××××××××××××××××××××××××××
DBORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.56)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dborcl)
)
)
×××××××××××××××××××××××××××××××××××××××××××××××××××××
--重啟監(jiān)聽
C:\Documents and Settings\Administrator>lsnrctl reload
LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 22-10月-2009 13:5
0:46
Copyright (c) 1991, 2005, Oracle. All rights reserved.
正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.56)(PORT=1521)))
命令執(zhí)行成功
---在測(cè)試
C:\Documents and Settings\Administrator>tnsping dborcl
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 22-10月-
2009 13:52:18
Copyright (c) 1997, 2005, Oracle. All rights reserved.
已使用的參數(shù)文件:
D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
已使用 TNSNAMES 適配器來解析別名
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.
2.56)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = dborcl)
))
OK (20 毫秒)
到此所有的 數(shù)據(jù)庫名(db_name)及實(shí)例名(Instance_name or Service_name) ,都已經(jīng)更改
Nid是Oracle從9iR2開始提供的工具,可以用來更改數(shù)據(jù)庫名稱,而無需通過之前重建控制文件等繁瑣方式。
nid是自帶的工具,在oracle_home/bin目錄中.以下方法假設(shè)登陸到數(shù)據(jù)庫本機(jī)做。
目的:在本例中,假設(shè)原來的數(shù)據(jù)庫名為orcl,要改成dborcl,原實(shí)例名(service_name,instance_name)orcl,要改成dborcl.
步驟概述:
1.檢查當(dāng)前的參數(shù)情況
2.shutdown數(shù)據(jù)庫,然后mount數(shù)據(jù)庫
3.運(yùn)行nid命令
4.更改參數(shù)文件pfile.ora(db_name,instance_name)
5.檢測(cè)更改情況
6.如果是windows平臺(tái),要修改服務(wù)
7.修改監(jiān)聽服務(wù)
C:\Documents and Settings\Administrator>sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 10月 22 11:56:33 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
1. 查看更改前的相應(yīng)名稱
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string orcl
db_unique_name string orcl
global_names boolean FALSE
instance_name string orcl
lock_name_space string
log_file_name_convert string
service_names string orcl
2. --先shutdown數(shù)據(jù)庫
SQL> shutdown immediate
數(shù)據(jù)庫已經(jīng)關(guān)閉。
已經(jīng)卸載數(shù)據(jù)庫。
ORACLE 例程已經(jīng)關(guān)閉。
3. --nid需要在mount狀態(tài)下才能做。因?yàn)橐目刂莆募男畔?
SQL> startup mount
ORACLE 例程已經(jīng)啟動(dòng)。
Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 180358020 bytes
Database Buffers 423624704 bytes
Redo Buffers 7135232 bytes
數(shù)據(jù)庫裝載完畢。
nid是操作系統(tǒng)的命令,所以要用host
SQL> host nid -help
DBNEWID: Release 10.2.0.1.0 - Production on Fri Oct 23 13:40:54 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Keyword Description (Default)
----------------------------------------------------
TARGET Username/Password (NONE)
DBNAME New database name (NONE)
LOGFILE Output Log (NONE)
REVERT Revert failed change NO
SETNAME Set a new database name only NO
APPEND Append to output log NO
HELP Displays these messages NO
以上是nid命令的語法
4。 --運(yùn)行nid命令
SQL> host nid target=sys/aibo dbname=dborcl
DBNEWID: Release 10.2.0.1.0 - Production on 星期四 10月 22 11:58:27 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
已連接數(shù)據(jù)庫 ORCL (DBID=1224293825)
已連接服務(wù)器版本 10.2.0
數(shù)據(jù)庫中的控制文件數(shù):
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CTL
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL
D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL03.CTL
是否將數(shù)據(jù)庫 ID 和數(shù)據(jù)庫名 ORCL 更改為 DBORCL? (Y/[N]) => y
操作繼續(xù)進(jìn)行
將數(shù)據(jù)庫 ID 從 1224293825 更改為 3277448932
將數(shù)據(jù)庫名從 ORCL 更改為 DBORCL
控制文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CTL - 已修改
控制文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL - 已修改
控制文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL03.CTL - 已修改
數(shù)據(jù)文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF - dbid 已更改,
已寫入新名稱
數(shù)據(jù)文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF - dbid 已更改,
已寫入新名稱
數(shù)據(jù)文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF - dbid 已更改,
已寫入新名稱
數(shù)據(jù)文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF - dbid 已更改, 已
寫入新名稱
數(shù)據(jù)文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF - dbid 已更改,
已寫入新名稱
數(shù)據(jù)文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF - dbid 已更改, 已
寫入新名稱
控制文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CTL - dbid 已更改,
已寫入新名稱
控制文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL - dbid 已更改,
已寫入新名稱
控制文件 D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL03.CTL - dbid 已更改,
已寫入新名稱
實(shí)例關(guān)閉
數(shù)據(jù)庫名已更改為 DBORCL。
修改參數(shù)文件并在重新啟動(dòng)前生成新的口令文件。
數(shù)據(jù)庫 DBORCL 的數(shù)據(jù)庫 ID 已更改為 3277448932。
此數(shù)據(jù)庫的所有以前的備份和歸檔重做日志均不可用。
數(shù)據(jù)庫無法識(shí)別恢復(fù)區(qū)中以前的備份和歸檔日志。
數(shù)據(jù)庫已關(guān)閉, 用 RESETLOGS 選項(xiàng)打開數(shù)據(jù)庫。
已成功更改數(shù)據(jù)庫名和 ID。
DBNEWID - 已成功完成。
5. ---shutdown數(shù)據(jù)庫
SQL> shutdown immediate
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
SQL> startup nomount
ORACLE 例程已經(jīng)啟動(dòng)。
Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 180358020 bytes
Database Buffers 423624704 bytes
Redo Buffers 7135232 bytes
SQL> create pfile='D:\oracle\product\10.2.0\pfile20091022.ora' from spfile;
文件已創(chuàng)建。
SQL> shutdown immediate;
ORA-01507: ??????
6. ---修改初始化參數(shù)文件、spfile文件(init.ora/spfile)
###########################################
instance_name=eyglen
#instance_name=eyglev
###########################################
db_domain=""
db_name=eyglen
# db_name=eyglev
###########################################
7. ---以修改后的參數(shù)啟動(dòng)數(shù)據(jù)庫
SQL> startup pfile='D:\oracle\product\10.2.0\pfile20091022.ora'
ORACLE 例程已經(jīng)啟動(dòng)。
Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 180358020 bytes
Database Buffers 423624704 bytes
Redo Buffers 7135232 bytes
數(shù)據(jù)庫裝載完畢。
ORA-01589: 要打開數(shù)據(jù)庫則必須使用 RESETLOGS 或 NORESETLOGS 選項(xiàng)
SQL> create spfile from pfile='D:\oracle\product\10.2.0\pfile20091022.ora'
2 ;
文件已創(chuàng)建。
SQL> shutdown immediate
ORA-01109: 數(shù)據(jù)庫未打開
已經(jīng)卸載數(shù)據(jù)庫。
ORACLE 例程已經(jīng)關(guān)閉。
SQL> startup
ORACLE 例程已經(jīng)啟動(dòng)。
Total System Global Area 612368384 bytes
Fixed Size 1250428 bytes
Variable Size 180358020 bytes
Database Buffers 423624704 bytes
Redo Buffers 7135232 bytes
數(shù)據(jù)庫裝載完畢。
ORA-01589: 要打開數(shù)據(jù)庫則必須使用 RESETLOGS 或 NORESETLOGS 選項(xiàng)
SQL> alter database open noresetlogs
2 ;
alter database open noresetlogs
*
第 1 行出現(xiàn)錯(cuò)誤:
ORA-01588: 要打開數(shù)據(jù)庫則必須使用 RESETLOGS 選項(xiàng)
SQL> alter database open resetlogs
2 ;
數(shù)據(jù)庫已更改。
8. --現(xiàn)在數(shù)據(jù)庫已經(jīng)啟動(dòng)了啊,那就檢查下吧,看看是否已經(jīng)修改了
SQL> select open_mode from v$database;
OPEN_MODE
----------
READ WRITE
SQL> show parameter name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string dborcl
db_unique_name string dborcl
global_names boolean FALSE
instance_name string dborcl
lock_name_space string
log_file_name_convert string
service_names string dborcl
SQL>
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
orcl
9. 發(fā)現(xiàn)v$instance里的沒有修改過來,這是因?yàn)樵趙indows平臺(tái),繼續(xù)如下操作
********如果是windows平臺(tái),v$instance里的instanc_name沒有變, 繼續(xù)如下操作
passwd文件通常放在oracle_home/database目錄下,文件命名形式為PWDsid.ora,sid為實(shí)例名(Service_name),
如當(dāng)前的數(shù)據(jù)庫名及service_name為orcl,則passwd文件為PWDorcl.ora
C:\Documents and Settings\Administrator>orapwd file=D:\oracle\product\10.2.0\db_
1\database\PWDdborcl.ora password=aibo entries=5
要注意一下,此時(shí)雖然數(shù)據(jù)庫名已經(jīng)改成dborcl了,但instance_name還是orcl,所以,passwd文件必須跟以前一樣。否則會(huì)出錯(cuò)。
10. 刪除以前的實(shí)例orcl
C:\Documents and Settings\Administrator>oradim -delete -sid orcl
實(shí)例已刪除。
11. 創(chuàng)建新的實(shí)例名 dborcl
C:\Documents and Settings\Administrator>oradim -new -sid dborcl -intpwd aibo -st
artmode a -pfile D:\oracle\product\10.2.0\pfile20091022.ora
OPW-00005: 存在相同名稱的文件 - 請(qǐng)刪除或重命名
實(shí)例已創(chuàng)建。
12.
C:\Documents and Settings\Administrator>set oracle_sid=dborcl
C:\Documents and Settings\Administrator>sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 10月 22 13:41:12 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> quit
從 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 斷開
13.檢查服務(wù)名
C:\Documents and Settings\Administrator>lsnrctl reload
LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 22-10月-2009 13:4
3:13
Copyright (c) 1991, 2005, Oracle. All rights reserved.
正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.56)(PORT=1521)))
命令執(zhí)行成功
C:\Documents and Settings\Administrator>sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on 星期四 10月 22 13:43:21 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連接到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select open_mode from v$database;
OPEN_MODE
----------
READ WRITE
SQL> select instance_name from v$instance;
INSTANCE_NAME
----------------
dborcl
SQL> show parameter name;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string dborcl
db_unique_name string dborcl
global_names boolean FALSE
instance_name string dborcl
lock_name_space string
log_file_name_convert string
service_names string dborcl
SQL> quit
從 Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options 斷開
檢查service是否被更改
C:\Documents and Settings\Administrator>tnsping dborcl
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 22-10月-
2009 13:50:00
Copyright (c) 1997, 2005, Oracle. All rights reserved.
已使用的參數(shù)文件:
D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
已使用 EZCONNECT 適配器來解析別名
Attempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=dborcl.gdgg.local
))(ADDRESS=(PROTOCOL=TCP)(HOST=202.106.195.30)(PORT=1521)))
^C
測(cè)試不通過,說明dborcl配置有問題
修改tnsnames.ora文件,添加如下內(nèi)容:
×××××××××××××××××××××××××××××××××××××××××××××××××××××
DBORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.56)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dborcl)
)
)
×××××××××××××××××××××××××××××××××××××××××××××××××××××
--重啟監(jiān)聽
C:\Documents and Settings\Administrator>lsnrctl reload
LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on 22-10月-2009 13:5
0:46
Copyright (c) 1991, 2005, Oracle. All rights reserved.
正在連接到 (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.2.56)(PORT=1521)))
命令執(zhí)行成功
---在測(cè)試
C:\Documents and Settings\Administrator>tnsping dborcl
TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 22-10月-
2009 13:52:18
Copyright (c) 1997, 2005, Oracle. All rights reserved.
已使用的參數(shù)文件:
D:\oracle\product\10.2.0\db_1\network\admin\sqlnet.ora
已使用 TNSNAMES 適配器來解析別名
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.
2.56)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = dborcl)
))
OK (20 毫秒)
到此所有的 數(shù)據(jù)庫名(db_name)及實(shí)例名(Instance_name or Service_name) ,都已經(jīng)更改
相關(guān)文章
Oracle中簡(jiǎn)單查詢、限定查詢、數(shù)據(jù)排序SQL語句范例和詳細(xì)注解
這篇文章主要介紹了Oracle中簡(jiǎn)單查詢、限定查詢、數(shù)據(jù)排序SQL語句范例和詳細(xì)注解,對(duì)查詢語法一并做了介紹,需要的朋友可以參考下2014-07-07Oracle單實(shí)例升級(jí)補(bǔ)丁全過程記錄
這篇文章主要介紹了Oracle單實(shí)例升級(jí)補(bǔ)丁,oracle19.3升級(jí)補(bǔ)丁到19.18,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-08-08Oracle系列學(xué)習(xí)之Oracle正則表達(dá)式詳解
正則表達(dá)式應(yīng)用廣泛,在數(shù)據(jù)庫中也有很大的應(yīng)用空間,這篇文章主要給大家介紹了關(guān)于Oracle系列學(xué)習(xí)之Oracle正則表達(dá)式的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-12-12Oracle和MySQL的數(shù)據(jù)導(dǎo)入為何差別這么大
這篇文章主要介紹了Oracle和MySQL的數(shù)據(jù)導(dǎo)入有哪些區(qū)別,幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下2020-08-08Oracle報(bào)錯(cuò):ORA-28001:口令已失效解決辦法
最近在工作中遇到了一個(gè)問題,錯(cuò)誤是Oracle報(bào)錯(cuò)ORA-28001:口令已失效,下面這篇文章主要給大家介紹了關(guān)于Oracle報(bào)錯(cuò):ORA-28001:口令已失效的解決辦法,需要的朋友可以參考下2023-04-04Oracle 實(shí)現(xiàn)類似SQL Server中自增字段的一個(gè)辦法
由于Oracle中沒有類似SQL Server中的自增字段,所以我們?nèi)绻胍ㄟ^設(shè)定類似ID性質(zhì)的唯一列的話,需要借助Oracle的sequence,先建立一個(gè)序列,然后在每次插入數(shù)據(jù)的時(shí)候,通過前觸發(fā)器來更新ID值,并將序列的序號(hào)加1,這樣的迂回方式來實(shí)現(xiàn)。2009-07-07通過實(shí)例了解Oracle序列Sequence使用方法
這篇文章主要介紹了通過實(shí)例了解Oracle序列Sequence使用方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-09-09