Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2002
    Posts
    227

    Unanswered: to change the dbname

    hi,
    I've a database with dbname='dboracle', but I'd like to change his name with 'dblocal'.
    How can I change the dbname without to create a new database???

    Thanks
    Raf

  2. #2
    Join Date
    Oct 2002
    Location
    Boston, MA
    Posts
    5

    Smile

    To change the "db_name" for a database:

    1. Login to Server Manager

    % svrmgrl
    SVRMGR> connect internal

    2. Type

    SVRMGR> alter system switch logfile; -- to force a checkpoint.

    3. Type

    SVRMGR> alter database backup controlfile to trace resetlogs;

    This will create a trace file containing the "CREATE CONTROLFILE"
    command to recreate the controlfile in its current form.

    4. Shutdown the database and exit SVRMGR

    SVRMGR> shutdown

    SVRMGR> exit

    The database must be shutdown with SHUTDOWN NORMAL or SHUTDOWN IMMEDIATE. It
    must not be shutdown abnormally using SHUTDOWN ABORT.

    5. Change locations to the directory where your trace files are located. They
    are usually in the "$ORACLE_HOME/rdbms/log" directory. If "user_dump_dest" is
    set in the "init<SID>.ora" file, then go to the directory listed in the
    "user_dump_dest" variable. The trace file will have the form "ora_NNNN.trc with
    NNNN being a number.

    6. Get the "CREATE CONTROLFILE" command from the trace file and put it in a
    new file called something like "ccf.sql".

    7. Edit the "ccf.sql" file

    FROM: CREATE CONTROLFILE REUSE DATABASE "olddbname" NORESETLOGS ...
    TO: CREATE CONTROLFILE set DATABASE "newdbname" RESETLOGS ...

    FROM:
    # Recovery is required if any of the datafiles are restored backups,
    # or if the last shutdown was not normal or immediate.
    RECOVER DATABASE USING BACKUP CONTROLFILE
    TO:
    # Recovery is required if any of the datafiles are restored backups,
    # or if the last shutdown was not normal or immediate.
    # RECOVER DATABASE USING BACKUP CONTROLFILE

    8. Save and exit the "ccf.sql" file

    9. Rename the old control files for backup purposes and so that they do not
    exist when creating the new ones.

    10. Edit the "init<SID>.ora" file so that db_name="newdb_name" .

    11. Login to Server Manager

    % svrmgrl
    SVRMGR> connect internal

    12. Run the "ccf.sql" script

    SVRMGR> @ccf

    This will issue a startup nomount, and then recreate the controlfile.

    If, at this point, you receive the error that a file needs media recovery,
    the database was not shutdown normally as specified in step 4. You can try
    recovering the database using the redo in the current logfile, by issuing:

    SVRMGRL> recover database using backup controlfile;

    This will prompt for an archived redologfile. To apply the necessary redo, you need to check the online logfiles and apply the one with the same sequence number as reported in the message. This usually is the logfile with status=CURRENT.

    To find a list of the online logfiles:

    SVRMGR> select group#, seq#, status from v$log;
    GROUP# SEQUENCE# STATUS
    ---------- --------- ----------------
    1 123 CURRENT <== this redo needs to be applied
    2 124 INACTIVE
    3 125 INACTIVE
    4 126 INACTIVE
    5 127 INACTIVE
    6 128 INACTIVE
    7 129 INACTIVE

    7 rows selected.

    SVRMGR> select member
    from v$logfile
    where GROUP# = 1;

    Member
    ------------------------------------
    /u02/oradata/V815/redoV81501.log

    The last command in ccf.sql should be:

    SVRMGR> alter database open resetlogs;

    13. You may also need to change the global database name:

    alter database rename global_name to <newdb_name>.<domain>

    See <Note:1018634.102> for further detail.

    14. Make sure the database is working.

    15. Shutdown and backup the database.

    Found in OraTechNet "ask tom"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •