Border's profileBorder's logBlogListsNetwork Tools Help

Blog


    March 12

    ORACLE数据的导出(EXP)导入(IMP)

        在CMD 窗口敲入exp help=y  即可看到所有的EXP参数。 Imp命令也一样。如果提示错误的话,就得确定系统环境变量中的PATH 参数有没有指向你的ORACLE安装目录下的 BIN目录。
        Export/Import有三个级别: 表级, 用户级和全数据库级.
        1. 一个导出整库的命令( 系统管理员的权限):
         exp user/password@database full=y file=full_Lot2.dmp log=expLog.txt
      2. 一个borderj用户下的数据:
         exp user/password@database owner=borderj file=borderj_Lot2.dmp log=expLog.txt

    导入文件基本相同,建议在导入导出时通过脚本在做并出个log文件.

    常用技巧:
      1. 把数据库对象从一个用户移到另一个用户

          Oracle 不允许直接改变表的拥有者, 利用Export/Import可以达到这一目的.

          假设要把表 T 的拥有者User1改为User2,  具体步骤是:

             - exp system/manager tables = User1.T

             - imp system/manager fromuser = User1 touser = User2 tables = T

             - drop table User1.T

             - 把数据库对象从一个表空间移到另一个表空间

        2.  建表时可以指定表空间, 表空间一经确定就部能随意改变. 若要表 T 从表空间 tbs1移到表空间 tbs2, 就要采用以下方法:

             - exp <user/passwd> tables = T

             - imp <user/passwd> tables = T indexfile =  temp.sql

             - drop table T

             - 编辑 temp.sql 只保留所需的建表命令并指定表空间为tbs2

             - 以表的所有者执行temp.sql

             - imp <user/passwd> tables = T ignore = Y

         3. 只输出一个的表空间

          通常数据库设计成用户若属于某个表空间, 那么这个用户创建的数据库对象也在该表空间内.

       Export某个表空间可用如下方法:

             a. 查看表空间内所有用户

                 spool owners
              
                 select owner

                 from dba_segments

                 where tablespace_name = '<TablespaceName>';
              

                spool off

                
             b. 查看表空间内所有数据库对象

                 spool objects

                 select owner, object_name, object_type

                 from  dba_objects

                 where owner = 'owner1'

                 or   owner = 'owner2'

                      ...

                 or   owner = 'ownern';

                 spool off      

    参考:http://www.oracle.com.cn

    --
      Border

    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://borderj.spaces.live.com/blog/cns!61B003A9307DEAC6!120.trak
    Weblogs that reference this entry
    • None