ITPub博客

首页 > Linux操作系统 > Linux操作系统 > DB NAME的修改

DB NAME的修改

原创 Linux操作系统 作者:chengxideng 时间:2012-02-01 10:43:13 0 删除 编辑

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/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 记录工作的点滴
下一篇: 重建控制文件
请登录后发表评论 登录
全部评论

注册时间:2011-02-18

  • 博文量
    19
  • 访问量
    11489