新聞中心
怎么把sql腳本本件導入到Oracle數(shù)據(jù)庫里
現(xiàn)在一般使用 sqldeveloper,打開后,連接上DB,再打開.sql文件、運行就是
十余年的津市網(wǎng)站建設經(jīng)驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。成都全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設備顯示端的尺寸不同,自動調(diào)整津市建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。成都創(chuàng)新互聯(lián)從事“津市網(wǎng)站設計”,“津市網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。
舊的sqlplus,就是
sqlplus user/pwd@db
sql@new.sql
怎樣將SQL腳本導入oracle數(shù)據(jù)庫中
將數(shù)據(jù)庫的SQL腳本文件導入到oracle中
#1. 首先以管理員的身份登錄到oracle系統(tǒng)中
cmd;
sqlplus sys/sys as sysdba;
#2.創(chuàng)建用戶test,密碼為test
create user test identified by test;
#3.創(chuàng)建表空間,在D盤下建立50m的表空間data_dbfcreate tablespace ts_tablespace datefile 'D:\data_dbf' size 50m;#4.為用戶分配表空間
alter user test default tablespace ts_tablespace to test;#5.給用戶授權
grant create session, create table, create view, unlimited tablespace to test;#6.以test/test登錄
conn test/test;
#7.導入SQL語句,導入創(chuàng)建好的表
@D:\test.sql
#8.查詢表結構
oracle導數(shù)據(jù)到mysql(腳本方式)
spool /home/oracle/XXX.sql 后面是你要的導出路徑和導出文件名,最好是 txt 結尾的,不是的話等導完需要改名。
之后是 select 語句,字段和表名根據(jù)實際更改,日期要用 to_char 進行轉(zhuǎn)換。
/data01/zhu/XXX.txt 是你 oracle 導出文件的位置,只支持 txt文件 , fields terminated by ',' 意思是你字段間的分隔符。一般沒有中文用 character set utf8 ,有中文用 character set gb2312 ,不然可能會報錯。
PS:180萬條數(shù)據(jù)導進去的時間大概是2分鐘。但是700萬數(shù)據(jù)目前超過四小時還沒導完,建議分割來提高效率。
oracle怎么導入sql文件
PL/SQL登錄到數(shù)據(jù)庫,使用tools工具進行導入。使用plsql登錄到需要導入數(shù)據(jù)的數(shù)據(jù)庫。點擊工具欄上【tools】--【Import tables】
請點擊輸入圖片描述
點擊工具【SQL Inserts】(第二個選項),點擊選擇需要導入的數(shù)據(jù)庫腳本。
請點擊輸入圖片描述
選擇sql腳本的,點擊打開,即可打開數(shù)據(jù)庫腳本文件,數(shù)據(jù)庫腳本就可以預加載到plsq工具中。
請點擊輸入圖片描述
開始導入數(shù)據(jù)庫數(shù)據(jù)。選擇完sql腳本之后,點擊【Import】按鈕開始將腳本中的數(shù)據(jù)導入到數(shù)據(jù)庫中,這個操作執(zhí)行一次即可,如果數(shù)據(jù)量比較大,會出現(xiàn)卡頓。
請點擊輸入圖片描述
執(zhí)行完之后,沒有任何報錯說明插入成功。【注意:一定記得點擊commit進行提交數(shù)據(jù),否則數(shù)據(jù)不會提交到數(shù)據(jù)庫進行存儲】
請點擊輸入圖片描述
查詢驗證插入的數(shù)據(jù)。插入完之后,可以編寫sql語句對插入的數(shù)據(jù)進行核對。執(zhí)行查詢sql看到剛才插入的數(shù)據(jù)。
請點擊輸入圖片描述
oracle怎么批量導入導
需要用exp和imp命令,具體用法如下:
1. 獲取幫助
imp help=y
2. 導入一個完整數(shù)據(jù)庫
imp system/manager file=bible_db log=dible_db full=y ignore=y
3. 導入一個或一組指定用戶所屬的全部表、索引和其他對象
imp system/manager file=seapark log=seapark fromuser=seapark
imp system/manager file=seapark log=seapark fromuser=(seapark,amy,amyc,harold)
4. 將一個用戶所屬的數(shù)據(jù)導入另一個用戶
imp system/manager file=tank log=tank fromuser=seapark touser=seapark_copy
imp system/manager file=tank log=tank fromuser=(seapark,amy)
touser=(seapark1, amy1)
5. 導入一個表
imp system/manager file=tank log=tank fromuser=seapark TABLES=(a,b)
6. 從多個文件導入
imp system/manager file=(paycheck_1,paycheck_2,paycheck_3,paycheck_4)
log=paycheck, filesize=1G full=y
7. 使用參數(shù)文件
imp system/manager parfile=bible_tables.par
bible_tables.par參數(shù)文件:
#Import the sample tables used for the Oracle8i Database Administrator's
Bible. fromuser=seapark touser=seapark_copy file=seapark log=seapark_import
8. 增量導入
imp system./manager inctype= RECTORE FULL=Y FILE=A
-------------------------------------------------------------------------------------------------------------------------------------------
1. 獲取幫助
exp help=y
2. 導出一個完整數(shù)據(jù)庫
exp system/manager file=bible_db log=dible_db full=y
3. 導出數(shù)據(jù)庫定義而不導出數(shù)據(jù)
exp system/manager file=bible_db log=dible_db full=y rows=n
4. 導出一個或一組指定用戶所屬的全部表、索引和其他對象
exp system/manager file=seapark log=seapark owner=seapark
exp system/manager file=seapark log=seapark owner=(seapark,amy,amyc,harold)
注意:在導出用戶時,盡管已經(jīng)得到了這個用戶的所有對象,但是還是不能得到這些對象引用的任何同義詞。解決方法是用以下的SQL*Plus命令創(chuàng)建一個腳本文件,運行這個腳本文件可以獲得一個重建seapark所屬對象的全部公共同義詞的可執(zhí)行腳本,然后在目標數(shù)據(jù)庫上運行該腳本就可重建同義詞了。
SET LINESIZE 132
SET PAGESIZE 0
SET TRIMSPOOL ON
SPOOL c:\seapark.syn
SELECT 'Create public synonym '||synonym_name
||' for '||table_owner||'.'||table_name||';'
FROM dba_synonyms
WHERE table_owner = 'SEAPARK' AND owner = 'PUBLIC';
SPOOL OFF
5. 導出一個或多個指定表
exp seapark/seapark file=tank log=tank tables=tank
exp system/manager file=tank log=tank tables=seapark.tank
exp system/manager file=tank log=tank tables=(seapark.tank,amy.artist)
6. 估計導出文件的大小
全部表總字節(jié)數(shù):
SELECT sum(bytes)
FROM dba_segments
WHERE segment_type = 'TABLE';
seapark用戶所屬表的總字節(jié)數(shù):
SELECT sum(bytes)
FROM dba_segments
WHERE owner = 'SEAPARK'
AND segment_type = 'TABLE';
seapark用戶下的aquatic_animal表的字節(jié)數(shù):
SELECT sum(bytes)
FROM dba_segments
WHERE owner = 'SEAPARK'
AND segment_type = 'TABLE'
AND segment_name = 'AQUATIC_ANIMAL';
7. 導出表數(shù)據(jù)的子集(oracle8i以上)
NT系統(tǒng):
exp system/manager query='Where salad_type='FRUIT'' tables=amy.salad_type
file=fruit log=fruit
UNIX系統(tǒng):
exp system/manager query=\"Where salad_type=\'FRUIT\'\" tables=amy.salad_type
file=fruit log=fruit
8. 用多個文件分割一個導出文件
exp system/manager
file=(paycheck_1,paycheck_2,paycheck_3,paycheck_4)
log=paycheck, filesize=1G tables=hr.paycheck
9. 使用參數(shù)文件
exp system/manager parfile=bible_tables.par
bible_tables.par參數(shù)文件:
#Export the sample tables used for the Oracle8i Database Administrator's Bible.
file=bible_tables
log=bible_tables
tables=(
amy.artist
amy.books
seapark.checkup
seapark.items
)
10. 增量導出
“完全”增量導出(complete),即備份整個數(shù)據(jù)庫
exp system/manager inctype=complete file=990702.dmp
“增量型”增量導出(incremental),即備份上一次備份后改變的數(shù)據(jù)
exp system/manager inctype=incremental file=990702.dmp
“累計型”增量導出(cumulative),即備份上一次“完全”導出之后改變的數(shù)據(jù)
exp system/manager inctype=cumulative file=990702.dmp
文章標題:oracle如何導入腳本,oracle導出建庫腳本
當前URL:http://www.ef60e0e.cn/article/dscodpd.html