DB NAME的修改

DB NAME的修改:

数据库原名为ORCL,实例名为hyjt,我们在这里把数据库名ORCL改为跟实例名对应的hyjt

查看原数据库名
idle> select name from v$database;
NAME
------------------------------
ORCL

修改数据库名
需要把数据哭关闭并启动到mount状态
idle> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

idle> startup mount
ORACLE instance started.

Total System Global Area  184549376 bytes
Fixed Size                  1218412 bytes
Variable Size              62916756 bytes
Database Buffers          117440512 bytes
Redo Buffers                2973696 bytes
Database mounted.

显示nid命令帮助
[oracle@rhel5 ~]$ nid -help

DBNEWID: Release 10.2.0.1.0 - Production on Sun Dec 5 21:17:25 2010

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

修改数据库名dbname
[oracle@rhel5 ~]$ nid target=sys/oracle dbname=hyjt setname=y

DBNEWID: Release 10.2.0.1.0 - Production on Sun Dec 5 21:18:23 2010
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to database ORCL (DBID=1264786455)
Connected to server version 10.2.0
Control Files in database:
    /u01/app/oracle/oradata/orcl/control01.ctl
    /u01/app/oracle/oradata/orcl/control02.ctl
    /u01/app/oracle/oradata/orcl/control03.ctl

Change database name of database ORCL to HYJT? (Y/[N]) => y

Proceeding with operation
Changing database name from ORCL to HYJT
    Control File /u01/app/oracle/oradata/orcl/control01.ctl - modified
    Control File /u01/app/oracle/oradata/orcl/control02.ctl - modified
    Control File /u01/app/oracle/oradata/orcl/control03.ctl - modified
    Datafile /u01/app/oracle/oradata/orcl/system01.dbf - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/undotbs01.dbf - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/sysaux01.dbf - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/users01.dbf - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/stone01.dbf - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/ts1.1 - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/big01.dbf - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/t4k.4 - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/tnolog.dbf - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/ts3.dbf - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/ts4.dbf - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/undo2.dbf - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/tm2.dbf - wrote new name
    Datafile /u01/app/oracle/oradata/orcl/temp01.dbf - wrote new name
    Control File /u01/app/oracle/oradata/orcl/control01.ctl - wrote new name
    Control File /u01/app/oracle/oradata/orcl/control02.ctl - wrote new name
    Control File /u01/app/oracle/oradata/orcl/control03.ctl - wrote new name
    Instance shut down

Database name changed to HYJT.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.


修改参数文件pfile里对应的db_name 参数值为新的dbname
[oracle@rhel5 dbs]$ vi $ORACLE_HOME/dbs/inithyjt.ora
修改db_name
一行,值为‘hyjt’
*.db_name='hyjt'

重新登录sqlplus
[oracle@rhel5 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Dec 5 21:26:37 2010
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

利用修改后的参数文件启动数据库
idle> startup pfile=/u01/app/oracle/product/10.2/dbs/inithyjt.ora
ORACLE instance started.

Total System Global Area  184549376 bytes
Fixed Size                  1218412 bytes
Variable Size              62916756 bytes
Database Buffers          117440512 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.

查看数据库名字修改成功
idle> select name from v$database;
NAME
------------------------------
HYJT

创建spfile
idle> create spfile from pfile;
File created.

查看spfile参数没有内容,这说明数据库目前是用pfile启动的。
idle> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string

重启数据库
idle> startup force
ORACLE instance started.

Total System Global Area  184549376 bytes
Fixed Size                  1218412 bytes
Variable Size              62916756 bytes
Database Buffers          117440512 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.

检验spfile启动启动成功
idle> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/10.2/d
                                                 bs/spfilehyjt.ora
数据库名字修改成功
idle> select name from v$database;

NAME
------------------------------
HYJT

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25402324/viewspace-715404/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/25402324/viewspace-715404/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值