oracle如何復(fù)制數(shù)據(jù) oracle 拷貝數(shù)據(jù)表

在oracle中怎樣把一個(gè)數(shù)據(jù)庫中的一張表的數(shù)據(jù)復(fù)制到另一個(gè)數(shù)據(jù)庫中的一張表中

1、使用plsql連接上數(shù)據(jù)庫,展開【Tables】菜單項(xiàng),下面出現(xiàn)的就是數(shù)據(jù)庫表。

我們提供的服務(wù)有:網(wǎng)站制作、成都網(wǎng)站建設(shè)、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、光澤ssl等。為上千家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的光澤網(wǎng)站制作公司

2、在數(shù)據(jù)庫表tblTest上面點(diǎn)擊鼠標(biāo)右鍵,選擇【Query data】,此項(xiàng)的目的是查詢這張數(shù)據(jù)庫表的數(shù)據(jù)。

3、點(diǎn)擊完成【Query data】之后,右側(cè)會(huì)出現(xiàn)一個(gè)SQL語句的窗口,默認(rèn)有一條【select * from 表名】的sql語句,下方還有一個(gè)列表,展示這張表中的已有數(shù)據(jù)。

4、然后寫一條insert插入的SQL語句,寫完之后,選中這條SQL,點(diǎn)擊左上角的【次輪狀】圖標(biāo),然后,SQL語句下方會(huì)出現(xiàn)【1 row inserted in xx seconds】,表示語句執(zhí)行成功。此時(shí)數(shù)據(jù)還沒有真正寫入數(shù)據(jù)庫 insert插入sql格式:insert into 表名(字段1, 字段2, 字段n) values(值1, 值2, 值n)。

5、在Oracle數(shù)據(jù)庫中,對(duì)數(shù)據(jù)的變更還需要點(diǎn)擊【Commit】按鈕,也就是左上角向下箭頭的圖標(biāo),如果不點(diǎn)擊這個(gè)按鈕,數(shù)據(jù)其實(shí)不會(huì)真正存入數(shù)據(jù)庫。點(diǎn)擊【Commit】按鈕后,會(huì)彈出一個(gè)Confirm窗口,此時(shí)點(diǎn)擊【Yes】就將數(shù)據(jù)寫入數(shù)據(jù)庫,點(diǎn)擊【No】則不提交到數(shù)據(jù)庫。

如何將一個(gè)oracle數(shù)據(jù)庫復(fù)制成一個(gè)新的數(shù)據(jù)庫

1、在數(shù)據(jù)庫服務(wù)器的開始菜單中找到Datebase Configuration Assistant。

2、在創(chuàng)建畫面第一步選擇:創(chuàng)建新數(shù)據(jù)庫,點(diǎn)擊下一步。

3、根據(jù)需求選擇自己的數(shù)據(jù)庫類型(一般默認(rèn))后,跳轉(zhuǎn)到全局?jǐn)?shù)據(jù)庫名這個(gè)畫面時(shí),重點(diǎn)來了:新建數(shù)據(jù)庫名稱不能和已經(jīng)存在的任何一個(gè)數(shù)據(jù)庫名稱相同。

4、在管理帳戶密碼界面,可以與別的數(shù)據(jù)庫管理帳戶密碼相同也可以不同,需注意的是,Oracle數(shù)據(jù)庫默認(rèn)是區(qū)分密碼大小寫的。

5、跳轉(zhuǎn)到Oracle內(nèi)存分配大小頁面,這里建議將Oracle內(nèi)存調(diào)整為物理主機(jī)內(nèi)存的70%。

6、點(diǎn)擊完成后,等待數(shù)據(jù)庫創(chuàng)建完成。

7、數(shù)據(jù)庫創(chuàng)建完成后,用sqlplus?語句連接數(shù)據(jù)庫,在同一服務(wù)器上建立多個(gè)Oracle數(shù)據(jù)庫操作完成。

在Oracle中實(shí)現(xiàn)數(shù)據(jù)庫的復(fù)制

在Internet上運(yùn)作數(shù)據(jù)庫經(jīng)常會(huì)有這樣的需求 把遍布全國(guó)各城市相似的數(shù)據(jù)庫應(yīng)用統(tǒng)一起來 一個(gè)節(jié)點(diǎn)的數(shù)據(jù)改變不僅體現(xiàn)在本地 還反映到遠(yuǎn)端 復(fù)制技術(shù)給用戶提供了一種快速訪問共享數(shù)據(jù)的辦法 一 實(shí)現(xiàn)數(shù)據(jù)庫復(fù)制的前提條件 數(shù)據(jù)庫支持高級(jí)復(fù)制功能 您可以用system身份登錄數(shù)據(jù)庫 查看v$option視圖 如果其中Advanced replication為TRUE 則支持高級(jí)復(fù)制功能 否則不支持 數(shù)據(jù)庫初始化參數(shù)要求 ① db_domain = 指明數(shù)據(jù)庫的域名(默認(rèn)的是WORLD) 這里可以用您公司的域名 ② global_names = true 它要求數(shù)據(jù)庫鏈接(database link)和被連接的數(shù)據(jù)庫名稱一致 現(xiàn)在全局?jǐn)?shù)據(jù)庫名 db_name+ +db_domain ③ 有跟數(shù)據(jù)庫job執(zhí)行有關(guān)的參數(shù) job_queue_processes = job_queue_interval = distributed_transactions = open_links =  第一行定義SNP進(jìn)程的啟動(dòng)個(gè)數(shù)為n 系統(tǒng)缺省值為 正常定義范圍為 ~ 根據(jù)任務(wù)的多少 可以配置不同的數(shù)值  第二行定義系統(tǒng)每隔N秒喚醒該進(jìn)程一次 系統(tǒng)缺省值為 秒 正常范圍為 ~ 秒 事實(shí)上 該進(jìn)程執(zhí)行完當(dāng)前任務(wù)后 就進(jìn)入睡眠狀態(tài) 睡眠一段時(shí)間后 由系統(tǒng)的總控負(fù)責(zé)將其喚醒  如果修改了以上這幾個(gè)參數(shù) 需要重新啟動(dòng)數(shù)據(jù)庫以使參數(shù)生效 二 實(shí)現(xiàn)數(shù)據(jù)庫同步復(fù)制的步驟 假設(shè)在Internet上我們有兩個(gè)數(shù)據(jù)庫 一個(gè)叫深圳(shenzhen) 一個(gè)叫北京(beijing) 具體配置見下表   確認(rèn)兩臺(tái)數(shù)據(jù)庫之間可以互相訪問 在tnsnames ora里設(shè)置數(shù)據(jù)庫連接字符串 ① 例如 深圳這邊的數(shù)據(jù)庫連接字符串是以下的格式 beijing = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = )) ) (CONNECT_DATA = (SERVICE_NAME = beijing) ) ) 運(yùn)行$tnsping beijing 出現(xiàn)以下提示符 Attempting to contact (ADDRESS=(PROTOCOL=TCP)(HOST= )(PORT= )) OK(n毫秒) 表明深圳數(shù)據(jù)庫可以訪問北京數(shù)據(jù)庫 ② 在北京那邊也同樣配置 確認(rèn)$tnsping shenzhen 是通的 改數(shù)據(jù)庫全局名稱 建公共的數(shù)據(jù)庫鏈接 ① 用system身份登錄shenzhen數(shù)據(jù)庫 SQLalter database rename global_name to cn; 用system身份登錄beijing數(shù)據(jù)庫 SQLalter database rename global_name to ; ② 用system身份登錄shenzhen數(shù)據(jù)庫 SQLcreate public database link using beijing ; 測(cè)試數(shù)據(jù)庫全局名稱和公共的數(shù)據(jù)庫鏈接 SQLselect * from global_n cn; 返回結(jié)果為就對(duì)了 用system身份登錄beijing數(shù)據(jù)庫 SQLcreate public database link cn using shenzhen ; 測(cè)試數(shù)據(jù)庫全局名稱和公共的數(shù)據(jù)庫鏈接 SQLselect * from global_na cn; 返回結(jié)果為 cn就對(duì)了 建立管理數(shù)據(jù)庫復(fù)制的用戶repadmin 并賦權(quán) ① 用system身份登錄shenzhen數(shù)據(jù)庫 SQLcreate user repadmin identified by repadmin default tablespace users temporary tablespace temp; SQLexecute dbms_defer_sys register_propagator( repadmin ); SQLgrant execute any procedure to repadmin; SQLexecute dbms_repcat_admin grant_admin_any_repgroup( repadmin ); SQLgrant ment any table to repadmin; SQLgrant lock any table to repadmin; ② 同樣用system身份登錄beijing數(shù)據(jù)庫 運(yùn)行以上的命令 管理數(shù)據(jù)庫復(fù)制的用戶repadmin 并賦權(quán) 說明 repadmin用戶名和密碼可以根據(jù)用戶的需求自由命名 在數(shù)據(jù)庫復(fù)制的用戶repadmin下創(chuàng)建私有的數(shù)據(jù)庫鏈接 ① 用repadmin身份登錄shenzhen數(shù)據(jù)庫 SQLcreate database link connect to repadmin identified by repadmin; 測(cè)試這個(gè)私有的數(shù)據(jù)庫鏈接 SQLselect * from global_n cn; 返回結(jié)果為就對(duì)了 ② 用repadmin身份登錄beijing數(shù)據(jù)庫 SQLcreate database link cn connect to repadmin identified by repadmin; 測(cè)試這個(gè)私有的數(shù)據(jù)庫鏈接 SQLselect * from global_na cn; 返回結(jié)果為 cn就對(duì)了 創(chuàng)建或選擇實(shí)現(xiàn)數(shù)據(jù)庫復(fù)制的用戶和對(duì)象 給用戶賦權(quán) 數(shù)據(jù)庫對(duì)象必須有主關(guān)鍵字 假設(shè)我們用ORACLE里舉例用的scott用戶 dept表 ① 用internal身份登錄shenzhen數(shù)據(jù)庫 創(chuàng)建scott用戶并賦權(quán) SQLcreate user scott identified by tiger default tablespace users temporary tablespace temp; SQLgrant connect resource to scott; SQLgrant execute on sys dbms_defer to scott; ② 用scott身份登錄shenzhen數(shù)據(jù)庫 創(chuàng)建表dept SQLcreate table dept (deptno number( ) primary key dname varchar ( ) loc varchar ( ) ); ③ 如果數(shù)據(jù)庫對(duì)象沒有主關(guān)鍵字 可以運(yùn)行以下SQL命令添加 SQLalter table dept add (constraint dept_deptno_pk primary key (deptno)); ④ 在shenzhen數(shù)據(jù)庫scott用戶下創(chuàng)建主關(guān)鍵字的序列號(hào) 范圍避免和beijing的沖突 SQL create sequence dept_no increment by start with maxvalue cycle nocache; (說明 maxvalue 可以根據(jù)應(yīng)用程序及表結(jié)構(gòu)主關(guān)鍵字定義的位數(shù)需要而定) ⑤ 在shenzhen數(shù)據(jù)庫scott用戶下插入初始化數(shù)據(jù) SQLinsert into dept values (dept_no nextval accounting new york ); SQLinsert into dept values (dept_no nextval research dallas ); SQLmit; ⑥ 在beijing數(shù)據(jù)庫那邊同樣運(yùn)行以上① ② ③ ⑦ 在beijing數(shù)據(jù)庫scott用戶下創(chuàng)建主關(guān)鍵字的序列號(hào) 范圍避免和shenzhen的沖突 SQL create sequence dept_no increment by start with maxvalue cycle nocache; ⑧ 在beijing數(shù)據(jù)庫scott用戶下插入初始化數(shù)據(jù) SQLinsert into dept values (dept_no nextval sales chicago ); SQLinsert into dept values (dept_no nextval operations boston ); SQLmit; 創(chuàng)建要復(fù)制的組scott_mg 加入數(shù)據(jù)庫對(duì)象 產(chǎn)生對(duì)象的復(fù)制支持 ① 用repadmin身份登錄shenzhen數(shù)據(jù)庫 創(chuàng)建主復(fù)制組scott_mg SQL execute dbms_repcat create_master_repgroup( scott_mg ); 說明 scott_mg組名可以根據(jù)用戶的需求自由命名 ② 在復(fù)制組scott_mg里加入數(shù)據(jù)庫對(duì)象 SQLexecute dbms_repcat create_master_repobject(sname= scott oname= dept type= table use_existing_object=true gname= scott_mg ); 參數(shù)說明 sname 實(shí)現(xiàn)數(shù)據(jù)庫復(fù)制的用戶名稱 oname 實(shí)現(xiàn)數(shù)據(jù)庫復(fù)制的數(shù)據(jù)庫對(duì)象名稱 (表名長(zhǎng)度在 個(gè)字節(jié)內(nèi) 程序包名長(zhǎng)度在 個(gè)字節(jié)內(nèi)) type 實(shí)現(xiàn)數(shù)據(jù)庫復(fù)制的數(shù)據(jù)庫對(duì)象類別 (支持的類別 表 索引 同義詞 觸發(fā)器 視圖 過程 函數(shù) 程序包 程序包體) use_existing_object true表示用主復(fù)制節(jié)點(diǎn)已經(jīng)存在的數(shù)據(jù)庫對(duì)象 gname 主復(fù)制組名 ③ 對(duì)數(shù)據(jù)庫對(duì)象產(chǎn)生復(fù)制支持 SQLexecute dbms_repcat generate_replication_support( scott dept table ); (說明 產(chǎn)生支持scott用戶下dept表復(fù)制的數(shù)據(jù)庫觸發(fā)器和程序包) ④ 確認(rèn)復(fù)制的組和對(duì)象已經(jīng)加入數(shù)據(jù)庫的數(shù)據(jù)字典 SQLselect gname master status from dba_repgroup; SQLselect * from dba_repobject; 創(chuàng)建主復(fù)制節(jié)點(diǎn) ① 用repadmin身份登錄shenzhen數(shù)據(jù)庫 創(chuàng)建主復(fù)制節(jié)點(diǎn) SQLexecute dbms_repcat add_master_database (gname= scott_mg master= use_existing_objects=true copy_rows=false propagation_mode = asynchronous ); 參數(shù)說明 gname 主復(fù)制組名 master 加入主復(fù)制節(jié)點(diǎn)的另一個(gè)數(shù)據(jù)庫 use_existing_object true表示用主復(fù)制節(jié)點(diǎn)已經(jīng)存在的數(shù)據(jù)庫對(duì)象 copy_rows false表示第一次開始復(fù)制時(shí)不用和主復(fù)制節(jié)點(diǎn)保持一致 propagation_mode 異步地執(zhí)行 ② 確認(rèn)復(fù)制的任務(wù)隊(duì)列已經(jīng)加入數(shù)據(jù)庫的數(shù)據(jù)字典 SQLselect * from user_jobs; 使同步組的狀態(tài)由停頓(quiesced )改為正常(normal) ① 用repadmin身份登錄shenzhen數(shù)據(jù)庫 運(yùn)行以下命令 SQL execute dbms_repcat resume_master_activity( scott_mg false); ② 確認(rèn)同步組的狀態(tài)為正常(normal) SQL select gname master status from dba_repgroup; ③ 如果這個(gè)①命令不能使同步組的狀態(tài)為正常(normal) 可能有一些停頓的復(fù)制 運(yùn)行以下 lishixinzhi/Article/program/Oracle/201311/16816

網(wǎng)頁題目:oracle如何復(fù)制數(shù)據(jù) oracle 拷貝數(shù)據(jù)表
網(wǎng)頁URL:http://www.muchs.cn/article24/hggece.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、微信小程序、網(wǎng)站排名、外貿(mào)網(wǎng)站建設(shè)網(wǎng)站改版

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)