posts - 5, comments - 0, trackbacks - 0, articles - 0

          oracle導入dmp文件

          Posted on 2011-10-24 22:58 playingenjoy 閱讀(4611) 評論(0)  編輯  收藏
          創(chuàng)建用戶
          create user test identified by test default tablespace users; 

          授權
          grant resource,connect,dba to test; 

          提交
          commit; 

          刪除用戶實例:

          刪除用戶后邊必須跟cascade,否則失敗 

          drop user test cascade;

          exp本地導出與imp本地導入

          exp命令:
          1 exp username/psw@TEST file=d:test.dmp full=y
          2 exp username/psw@TEST file=d:test.dmp owner=(ly)
          3 exp username/psw@TEST file= d:test.dmp tables=(grid1,grid2) 
          1其中一是將Test(與某一數(shù)據(jù)庫對應的oracle服務名)數(shù)據(jù)庫進行整體導出
          2將屬于用戶ly的所有表導出
          3將表grid1,與grid2導出
          d:test.dmp是導出的文件地址

          imp命令:
          1 imp system/psw@TEST file=d:test.dmp
          2 imp system/psw@TEST full=y file=d:test.dmp ignore=y
          3 imp system/psw@TEST file=d:test.dmp tables=(grid1)ignore=y表示如果被導入的數(shù)據(jù)庫中某個表已經存在就忽略不導入那個表
          3表示只導入grid1這個表

          在導入導出前要先測試下對應的數(shù)據(jù)庫是否是通的:tnsping test來測試,同樣test是服務名
          所有命令可在cmd下執(zhí)行


          用exp/imp遠程操作數(shù)據(jù)庫

          對ORACLE數(shù)據(jù)庫進行遠程操作,假設數(shù)據(jù)庫在192.168.1.110上,具體方法如下:
          一、在客戶端創(chuàng)建和服務端對應的服務名
          方法1:
          修改tnsnames.ora文件
          加入遠程服務器的命名:

          Sql代碼 
          TEST_ORCL =   
          (DESCRIPTION =   
              (ADDRESS_LIST =   
                (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.110)(PORT = 1521))   
              )   
              (CONNECT_DATA =   
                (SERVICE_NAME = orcl)   
              )   
          )

          方法2:

          在oracle客戶端,打開net manager。

          創(chuàng)建一個服務命名TEST_ORCL,主機IP為:192.168.1.110,服務名orcl,端口1521


          二、測試遠程服務器是否暢通

          進入到cmd后,執(zhí)行命令:tnsping TEST_ORCL。

          三、遠程操作數(shù)據(jù)庫
          導出:

          Sql代碼 
          1:exp username/password@TEST_ORCL file=bak_filepath 
          2:exp username/password@TEST_ORCL full=y file=bak_filepath
          username 用戶名,password 密碼,TEST_ORCL 客服端服務名,bak_filepath 備份文件存放的路徑

          導入:

          Sql代碼 
          1:imp username/password@TEST_ORCL file=bak_filepath full=y 
          2:imp username/password@TEST_ORCL/database_name file=bak_filepath full=y 
          3:imp username/password@TEST_ORCL file=bak_filepath fromuser=fromadmin touser=toadmin

          username 用戶名,password 密碼,TEST_ORCL 客服端服務名,bak_filepath 備份文件存放的路徑
          fromadmin 備份數(shù)據(jù)的用戶名,toadmin 還原數(shù)據(jù)庫的用戶名。database_name 還原到那個數(shù)據(jù)庫上

          full=y 將數(shù)據(jù)庫整體導出,包括表結構等。





          給用戶增加導入數(shù)據(jù)權限的操作
           第一,啟動sql*puls
           第二,以system/manager登陸
          需要創(chuàng)建表空間才行
                   create tablespace 表空間名 datafile 'D:\oracle\product\10.2.0\oradata\groupbuy\表空間名.dbf' size 500M;
          create user 用戶 identified by 密碼 default tablespace 表空間名;
          grant connect,resource to 用戶;
          grant dba to 用戶;
          grant unlimited tablespace to 用戶; 
          grant select any table to 用戶; 
          grant select any dictionary to 用戶;


           //第三,create user 用戶名 IDENTIFIED BY 密碼 (如果已經創(chuàng)建過用戶,這步可以省略)
           //第四,GRANT CREATE USER,DROP USER,ALTER USER ,CREATE ANY VIEW ,
             DROP ANY VIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE,
                DBA,CONNECT,RESOURCE,CREATE SESSION  TO 用戶名字 
           第五, 運行-cmd-進入dmp文件所在的目錄, 
                imp userid=system/manager full=y file=*.dmp
                或者 imp userid=system/manager full=y file=filename.dmp




          在數(shù)據(jù)庫里執(zhí)行一個sequence
          create sequence user_seq
            increment by 1
            start with 100000000
            nomaxvalue
            nocycle
            nocache;


          來自網絡,以便備忘

          只有注冊用戶登錄后才能發(fā)表評論。


          網站導航:
           
          主站蜘蛛池模板: 绍兴市| 巴东县| 曲阳县| 花莲县| 万安县| 苏尼特右旗| 阳春市| 海林市| 浑源县| 株洲县| 澳门| 盖州市| 庆城县| 全椒县| 惠东县| 江孜县| 镶黄旗| 金平| 黎城县| 长海县| 绍兴市| 通城县| 海门市| 阜阳市| 平安县| 武夷山市| 明光市| 澄江县| 将乐县| 宝鸡市| 昌邑市| 黄平县| 砀山县| 拉孜县| 凤山市| 进贤县| 双峰县| 施甸县| 贵定县| 营山县| 大理市|