1,查看原有的db_unique_name信息
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
sql>
2,创建临时pfile,修改db_unique_name
sql> create pfile='/oracle/p1.ora' from spfile;
File created.
sql> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sql>
修改临时pfile文件(/oracle/p1.ora)里面的db_unique_name值为orcl_m1,以临时pfile启动
vim /oracle/p1.ora
*.db_unique_name=orcl_m1
3,更新spfile、pile文件
sql> create spfile from pfile='/oracle/p1.ora';
File created.
sql>
根据新的spfile,然后更新默认的pfile
sql> create pfile from spfile;
File created.
sql>
4,启动数据库,查看db_unique_name已经变成新的名称
sql> startup;
ORACLE instance started.
Total System Global Area 2.6991E+10 bytes
Fixed Size 2213976 bytes
Variable Size 1.9596E+10 bytes
Database Buffers 7247757312 bytes
Redo Buffers 145174528 bytes
Database mounted.
Database opened.
sql>
sql> show parameter name;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string /home/oradata/orcl,/home/
oradata/orcl
db_name string orcl
db_unique_name string orcl_m1
global_names boolean FALSE
instance_name string orcl
lock_name_space string
log_file_name_convert string /home/oradata/orcl,/home/
oradata/orcl
service_names string orcl
sql>
5,最后有一种直接在线上online改然后重启生效
sql> alter system set db_unique_name='orcl_m1' scope=spfile;
System altered.
sql> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sql>
sql> startup ;
ORACLE instance started.
Total System Global Area 2.6991E+10 bytes
Fixed Size 2213976 bytes
Variable Size 1.9596E+10 bytes
Database Buffers 7247757312 bytes
Redo Buffers 145174528 bytes
Database mounted.
Database opened.
sql>
sql> show parameter db_unique_name;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string orcl_m1
sql>