當前位置:首頁 » 編程語言 » oracle導入sql命令

oracle導入sql命令

發布時間: 2023-03-30 06:30:59

① 怎麼將sql文件導入oracle

我有兩個.sql文件在某個文件夾里,安裝文檔上說,將數據文件導入資料庫,在Oracle伺服器的命令行里sqlplus / as sysdba命令可以登陸到sqlplus命令行

② oracle怎樣導入*.sql文件

oracle導入*.sql文件只需要在Oracle伺服器的命令行里sqlplus / as sysdba命令可以登陸到sqlplus命令行里。
然後比如是C:/a.sql,那麼就執行@C:/a.sql,然後跑完後這個a.sql就被導入進來了。

③ Oracle-sqlplus導入sql文件

將一張表的數據插入到另一張表insert into table2 select * from table1;如果表不存在可以使用 create table table2 as select * from table1; 但是如果要插入的數據量比較大,用命令好使些。

使用PLSQL Developer導入insert語句,數據量過大會死掉,所以直接使用命令行的方式導入insert語句

 命令行進入sqlplus: sqlplus 用戶名/密碼@127.0.0.1:1521/tiger ( sqlplus test_name/[email protected]:1521/tiger )

 sql>@full_path/test.sql; 例:sql>@D:/test.sql;

test.sql 裡面最後加上一個commit;

--參考http://blog.csdn.net/yin_jw/article/details/38894905

④ 請問如何在oracle中導入.sql文件

向oracle中導入大sql文件:
在sql_plus裡面執行:
sql>@full_path/test.sql;
例:sql>@d:/test.sql;
不需要commit;
一般都是在test.sql
裡面最後加上一個commit;
但是需要注意的是:在test.sql文件裡面每條語句後必須加上「;」,代表一條語句的執行。

⑤ oracle怎樣導入資料庫

方法一:利用PL/SQL Developer工具導出:
菜單欄---->Tools---->Export Tables,如下圖,設置相關參數即可:
方法二:利用cmd的操作命令導出,詳情如下:
1:G:\Oracle\proct\10.1.0\Client_1\NETWORK\ADMIN目錄下有個tnsname.ora文件,內容如下:
復制代碼 代碼如下:
CMSTAR =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.13.200)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = cmstar)
)
)
其中:CMSTAR為資料庫名,HOST為IP地址,所以可以仿效上面的例子手動添加數據錄連接。
2:用cmd進入命令行
輸入:tnsping cmstar
就是測試172.18.13.200是否連接成功
3:導入與導出,如下:
數據導出:
1 將資料庫TEST完全導出,用戶名system 密碼manager 導出到D:\chu.dmp中
exp system/manager@TEST file=d:\chu.dmp full=y
2將資料庫中system用戶與sys用戶的表導出
expsystem/manager@TESTfile=d:\chu.dmpowner=(system,sys)
3將資料庫中的表table1、table2導出
expsystem/manager@TESTfile=d:\chu.dmptables=(table1,table2)
4將資料庫中的表table1中的欄位filed1以"00"打頭的數據導出
expsystem/manager@TESTfile=d:\chu.dmptables=(table1)query=\"wherefiled1like'00%'\"
上面是常用的導出,對於壓縮我不太在意,用winzip把dmp文件可以很好的壓縮。
不過在上面命令後面加上compress=y就可以了
數據的導入
1將D:\chu.dmp中的數據導入TEST資料庫中。
impsystem/manager@TESTfile=d:\chu.dmp
上面可能有點問題,因為有的表已經存在,然後它就報錯,對該表就不進行導入。
在後面加上ignore=y就可以了。
2將d:\chu.dmp中的表table1導入
impsystem/manager@TESTfile=d:\chu.dmptables=(table1)
注意事項:導出dmp數據時需要有導出表的許可權的用戶,否則不能導出。
PL/SQL Developer是Oracle資料庫中用於導入或導出資料庫的主要工具,本文主要介紹了利用PL/SQL Developer導入和導出資料庫的過程,並對導入或導出時的一些注意事項進行了說明,接下來我們就一一介紹。
導出步驟:
1 tools ->export user object 選擇選項,導出.sql文件。
2 tools ->export tables-> Oracle Export 選擇選項導出.dmp文件。
導入步驟:
註:導入之前最好把以前的表刪除,當然導入另外資料庫除外。
1 tools->import tables->SQL Inserts 導入.sql文件。
2 tools->import talbes->Oracle Import然後再導入dmp文件。
一些說明:
Tools->Export User Objects導出的是建表語句(包括存儲結構)。
Tools->Export Tables裡麵包含三種導出方式,三種方式都能導出表結構以及數據,如下:
Oracle Export
Sql Insert
pl/sql developer
第一種是導出為.dmp的文件格式,.dmp文件是二進制的,可以跨平台,還能包含許可權,效率也很不錯,用得最廣 。
第二種是導出為.sql文件的,可用文本編輯器查看,通用性比較好,但效率不如第一種,適合小數據量導入導出。尤其注意的是表中不能有大欄位(blob,clob,long),如果有,會提示不能導出(提示如下: table contains one or more LONG columns cannot export in sql format,user Pl/sql developer format instead)。
第三種是導出為.pde格式的,.pde為Pl/sql developer自有的文件格式,只能用Pl/sql developer自己導入導出,不能用編輯器查看。

⑥ oracle導入sql文件

1. 獲取幫助

imp help=y
2. 導入一個完整資料庫

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. 將一個用戶所屬的數據導入另一個用戶

imp system/manager file=tank log=tank fromuser=seapark touser=seapark_
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. 使用參數文件

imp system/manager parfile=bible_tables.par
bible_tables.par參數文件:

#Import the sample tables used for the Oracle8i Database Administrator's
Bible. fromuser=seapark touser=seapark_ file=seapark log=seapark_import
8. 增量導入

imp system./manager inctype= RECTORE FULL=Y FILE=A
-------------------------------------------------------------------------------------------------------------------------------------------

1. 獲取幫助
exp help=y

2. 導出一個完整資料庫
exp system/manager file=bible_db log=dible_db full=y

3. 導出資料庫定義而不導出數據
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)
注意:在導出用戶時,盡管已經得到了這個用戶的所有對象,但是還是不能得到這些對象引用的任何同義詞。解決方法是用以下的SQL*Plus命令創建一個腳本文件,運行這個腳本文件可以獲得一個重建seapark所屬對象的全部公共同義詞的可執行腳本,然後在目標資料庫上運行該腳本就可重建同義詞了。

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. 估計導出文件的大小
全部表總位元組數:
SELECT sum(bytes)
FROM dba_segments
WHERE segment_type = 'TABLE';

seapark用戶所屬表的總位元組數:
SELECT sum(bytes)
FROM dba_segments
WHERE owner = 'SEAPARK'
AND segment_type = 'TABLE';

seapark用戶下的aquatic_animal表的位元組數:
SELECT sum(bytes)
FROM dba_segments
WHERE owner = 'SEAPARK'
AND segment_type = 'TABLE'
AND segment_name = 'AQUATIC_ANIMAL';

7. 導出表數據的子集(oracle8i以上)
NT系統:

exp system/manager query='Where salad_type='FRUIT'' tables=amy.salad_type
file=fruit log=fruit
UNIX系統:

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. 使用參數文件
exp system/manager parfile=bible_tables.par
bible_tables.par參數文件:

#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),即備份整個資料庫
exp system/manager inctype=complete file=990702.dmp
「增量型」增量導出(incremental),即備份上一次備份後改變的數據
exp system/manager inctype=incremental file=990702.dmp
「累計型」增量導出(cumulative),即備份上一次「完全」導出之後改變的數據
exp system/manager inctype=cumulative file=990702.dmp

imp boss/boss@scott file=jkluio.dmp log=jkluio.log fromuser=boss touser=boss commit=y;

exp boss/123qwe!@CBGLDB file=boss.dmp log=boss.log owner=boss;

⑦ 怎樣將sql文件導入Oracle資料庫

登錄plsql,x0dx0a文件----新建-----命令窗口x0dx0ax0dx0a然後輸入 @文件路徑,例如 @c:\a.sqlx0dx0ax0dx0a這樣就可以了。直接執行sql文件

⑧ oracle怎樣sql文件導入資料庫中

 導出
導出具體的分為:導出表,導出方案,導出資料庫三種方式。
導出使用exp命令來完成的,該命令常用的選項有:
userid: 用於指定執行導出操作的用戶名,口令,連接字元串
tables: 用於指定執行導出操作的表
owner: 用於指定執行導出操作的方案
full=y: 用於指定執行導出操作的資料庫
inctype: 用於指定執行導出操作的增量類型
rows: 用於指定執行導出操作是否要導出表中的數據
file: 用於指定導出文件名
Oracle 筆記
23

 導出表
1.導出自己的表
exp userid=scott/tiger@myoral tables=(emp,dept) file=d:\e1.dmp
2.導出其它方案的表
如果用戶要導出其它方案的表,則需要dba的許可權或是exp_full_database的許可權,比如system就可以導出scott的表
E:\oracle\ora92\bin>exp userid=system/manager@myoral tables=(scott.emp) file=d:\e2.emp
特別說明:在導入和導出的時候,要到oracle目錄的bin目錄下。
3. 導出表的結構
exp userid=scott/tiger@accp tables=(emp) file=d:\e3.dmp rows=n
4. 使用直接導出方式
exp userid=scott/tiger@accp tables=(emp) file=d:\e4.dmp direct=y
這種方式比默認的常規方式速度要快,當數據量大時,可以考慮使用這樣的方法。
這時需要資料庫的字元集要與客戶端字元集完全一致,否則會報錯...
 導出方案
導出方案是指使用export工具導出一個方案或是多個方案中的所有對象(表,索引,約束...)和數據。並存放到文件中。
1. 導出自己的方案
exp userid=scott/tiger@myorcl owner=scott file=d:\scott.dmp
2. 導出其它方案
如果用戶要導出其它方案,則需要dba的許可權或是exp_full_database的許可權,比如system用戶就可以導出任何方案
exp userid=system/manager@myorcl owner=(system,scott) file=d:\system.dmp
 導出資料庫
導出資料庫是指利用export導出所有資料庫中的對象及數據,要求該用戶具有dba的許可權或者是exp_full_database許可權
增量備份(好處是第一次備份後,第二次備份就快很多了)
exp userid=system/manager@myorcl full=y inctype=complete file=d:\all.dmp
導入
 介紹
導入就是使用工具import將文件中的對象和數據導入到資料庫中,但是導入要使用的文件必須是export所導出的文件。與導
出相似,導入也分為導入表,導入方案,導入資料庫三種方式。
imp常用的選項有
userid: 用於指定執行導入操作的用戶名,口令,連接字元串
tables: 用於指定執行導入操作的表
formuser: 用於指定源用戶
touser: 用於指定目標用戶
file: 用於指定導入文件名
full=y: 用於指定執行導入整個文件
inctype: 用於指定執行導入操作的增量類型
rows: 指定是否要導入錶行(數據)
ignore: 如果表存在,則只導入數據
 導入表
1. 導入自己的表
imp userid=scott/tiger@myorcl tables=(emp) file=d:\xx.dmp
2. 導入表到其它用戶
要求該用戶具有dba的許可權,或是imp_full_database
imp userid=system/tiger@myorcl tables=(emp) file=d:\xx.dmp touser=scott
3. 導入表的結構
Oracle 筆記
24

只導入表的結構而不導入數據
imp userid=scott/tiger@myorcl tables=(emp) file=d:\xx.dmp rows=n
4. 導入數據
如果對象(如比表)已經存在可以只導入表的數據
imp userid=scott/tiger@myorcl tables=(emp) file=d:\xx.dmp ignore=y
 導入方案
導入方案是指使用import工具將文件中的對象和數據導入到一個或是多個方案中。如果要導入其它方案,要求該用戶具有dba
的許可權,或者imp_full_database
1. 導入自身的方案
imp userid=scott/tiger file=d:\xxx.dmp
2. 導入其它方案
要求該用戶具有dba的許可權
imp userid=system/manager file=d:\xxx.dmp fromuser=system touser=scott
 導入資料庫
在默認情況下,當導入資料庫時,會導入所有對象結構和數據,案例如下:
imp userid=system/manager full=y file=d:\xxx.dmp

熱點內容
phpmyadminlinux安裝 發布:2024-03-29 17:13:15 瀏覽:792
python中replace 發布:2024-03-29 17:08:17 瀏覽:652
mdb導入sql 發布:2024-03-29 17:07:36 瀏覽:128
java資料庫工具類 發布:2024-03-29 16:31:15 瀏覽:388
安卓機哪裡看型號 發布:2024-03-29 15:59:40 瀏覽:281
cad解壓錯誤 發布:2024-03-29 15:01:45 瀏覽:79
存儲指令集 發布:2024-03-29 14:39:27 瀏覽:649
資料庫表刪除數據 發布:2024-03-29 14:39:26 瀏覽:367
出c語言整除 發布:2024-03-29 14:28:22 瀏覽:572
芬尼壓縮機 發布:2024-03-29 14:24:11 瀏覽:464