Allen's profileLi's spacePhotosBlog Tools Help

Blog


    June 25

    Oracle移动数据库文件

    Oracle数据库由数据文件,控制文件和联机日志文件三种文件组成。
    由于磁盘空间的变化,或者基于数据库磁盘I/O性能的调整等,我們可能会考虑移动数据库文件。(注:恢复数据库时非常有用,属于冷备份)
    查询当前数据库中,相关文件路径
    select * from v$datafile;
    select * from v$controlfile;
    select * from v$logfile;
    根据以上路径,找到当前数据库相应文件路径。

    可以用ALTER DATABASE,ALTER TABLESPAC(这种方法略)两种方法移动数据文件。 用此方法,可以移动任何表空间的数据文件。
    1. 停数据库:
    sqlplus /nolog
    SQL> CONNECT INTERNAL;
    SQL> SHUTDOWN;
    SQL> EXIT;
    2.用操作系统命令移动数据文件:
    将数据文件 'test.dbf' 从/ora/oracle/data1目录移动到/ora/oracle/data2目录下:
    mv /ora/oracle/data1/test.dbf /ora/oracle/data2
    3. Mount数据库,用ALTER DATABASE命令将数据文件改名:
    sqlplus /nolog
    SQL> CONNECT INTERNAL;
    SQL> STARTUP MOUNT;
    SQL> ALTER DATABASE RENAME FILE '/ora/oracle/data1/test.dbf' TO '/ora/oracle/data2/test.dbf';
    4. 打开数据库:
    SQL> ALTER DATABASE OPEN;
    SQL>SELECT NAME,STATUS FROM V$DATAFILE;

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://lislog.spaces.live.com/blog/cns!29F76575168CBBB9!257.trak
    Weblogs that reference this entry
    • None