oracle如何修改数据库
1.用oracle自带的工具nid改数据库名
在本例中,假设原来的数据库名为test,要改成testdb,原实例名(service_name,instance_name)test,要改成testdb.
nid是自带的工具,在oracle_home/bin目录中.以下方法假设登陆到数据库本机做。
1.1 sqlplus "sys/password as sysdba"
1.2 sql>shutdown immediate --先停掉数据库
1.3 sql>startup mount --nid需要在mount状态下才能做。
1.4sql>host nid target=sys/password dbname=new_dbname --nid是一个在操作系统下执行的命令,在sqlplus环境中用host 去调用操作系统环境下的命令。命令中,当你想将数据库名字改为TESTDB时,应写成dbname=testdb
1.5执行后程序会询问:
Change database ID and database name TEST to TESTDB? (Y/[N]) =>y
敲y确定。
之后程序会对控制文件,数据文件进行修改:
Control File C:ORACLEORADATATESTCONTROL01.CTL - modified
Control File C:ORACLEORADATATESTCONTROL02.CTL - modified
Control File C:ORACLEORADATATESTCONTROL03.CTL - modified
Datafile C:ORACLEORADATATEST YSTEM01.DBF - dbid changed, wrote new name
Datafile C:ORACLEORADATATESTUNDOTBS01.DBF - dbid changed, wrote new nam
Datafile C:ORACLEORADATATESTINDX01.DBF - dbid changed, wrote new name
Datafile C:ORACLEORADATATESTTOOLS01.DBF - dbid changed, wrote new name
Datafile C:ORACLEORADATATESTUSERS01.DBF - dbid changed, wrote new name
Datafile D:DATAFILEPORMALS_SPA.DBF - dbid changed, wrote new name
Datafile C:ORACLEORADATATESTOEM_REPOSITORY.DBF - dbid changed, wrote ne
name
Datafile D:DATAFILEPORMALS_SPA_01.DBF - dbid changed, wrote new name
Datafile C:ORACLEORADATATESTTEMP01.DBF - dbid changed, wrote new name
Control File C:ORACLEORADATATESTCONTROL01.CTL - dbid changed, wrote new
name
Control File C:ORACLEORADATATESTCONTROL02.CTL - dbid changed, wrote new
name
Control File C:ORACLEORADATATESTCONTROL03.CTL - dbid changed, wrote new
name
Database name changed to TESTDB.
Modify parameter file and generate a new password file before restarting.
Database ID for database TESTDB changed to 2321050327.
All previous backups and archived redo logs for this database are unusable.
Shut down database and open with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.