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

          oracle導(dǎo)入dmp文件

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

          授權(quán)
          grant resource,connect,dba to test; 

          提交
          commit; 

          刪除用戶實(shí)例:

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

          drop user test cascade;

          exp本地導(dǎo)出與imp本地導(dǎo)入

          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ù)庫對(duì)應(yīng)的oracle服務(wù)名)數(shù)據(jù)庫進(jìn)行整體導(dǎo)出
          2將屬于用戶ly的所有表導(dǎo)出
          3將表grid1,與grid2導(dǎo)出
          d:test.dmp是導(dǎo)出的文件地址

          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表示如果被導(dǎo)入的數(shù)據(jù)庫中某個(gè)表已經(jīng)存在就忽略不導(dǎo)入那個(gè)表
          3表示只導(dǎo)入grid1這個(gè)表

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


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

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

          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)建一個(gè)服務(wù)命名TEST_ORCL,主機(jī)IP為:192.168.1.110,服務(wù)名orcl,端口1521


          二、測(cè)試遠(yuǎn)程服務(wù)器是否暢通

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

          三、遠(yuǎn)程操作數(shù)據(jù)庫
          導(dǎo)出:

          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 客服端服務(wù)名,bak_filepath 備份文件存放的路徑

          導(dǎo)入:

          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 客服端服務(wù)名,bak_filepath 備份文件存放的路徑
          fromadmin 備份數(shù)據(jù)的用戶名,toadmin 還原數(shù)據(jù)庫的用戶名。database_name 還原到那個(gè)數(shù)據(jù)庫上

          full=y 將數(shù)據(jù)庫整體導(dǎo)出,包括表結(jié)構(gòu)等。





          給用戶增加導(dǎo)入數(shù)據(jù)權(quán)限的操作
           第一,啟動(dòng)sql*puls
           第二,以system/manager登陸
          需要?jiǎng)?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 密碼 (如果已經(jīng)創(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 用戶名字 
           第五, 運(yùn)行-cmd-進(jìn)入dmp文件所在的目錄, 
                imp userid=system/manager full=y file=*.dmp
                或者 imp userid=system/manager full=y file=filename.dmp




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


          來自網(wǎng)絡(luò),以便備忘

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 集安市| 安徽省| 弥渡县| 长兴县| 晋城| 湖南省| 莫力| 普洱| 兰考县| 丘北县| 无极县| 临城县| 友谊县| 海口市| 常宁市| 新乡市| 四川省| 雷州市| 定远县| 交口县| 沧源| 邻水| 江都市| 西乡县| 砚山县| 龙海市| 葵青区| 勐海县| 休宁县| 顺平县| 登封市| 延川县| 和顺县| 全州县| 萨迦县| 昔阳县| 如皋市| 昭觉县| 贵州省| 通渭县| 商南县|