看看jdbc:oracle:thin:@192.168.88.205:1521:test能不能訪問,可以 telnet 192.168.88.205 1521試試
1 建立使用者語句,賦許可權
create user 使用者名稱 identified by 密碼;grant connect,resource,dba to 使用者名稱;
2 匯入匯出資料庫
exp system_V1/12345@196.168.1.10:1521/iwms file=d:/wenjian.dmp owner=(system_V1) imp system_V2/88075998@196.168.1.10:1521/orcl full=y file=d:/wenjian.dmp ignore=y
3 如何清空一個資料庫
先匯入一個資料庫,然後使用這條語句,擷取到所有刪除表記錄的語句,批量執行即可,用plsql匯出功能,匯出這些批量sql
select 'delete table '||table_name||';' from user_tables
4 “||”在oracle或SQL中的作用
連接字串或者查詢結果中的欄位,比如 select column1||column2 from table; select '123'||'456'||'789' from dual;
資料匯出:
1 將資料庫TEST完全匯出,使用者名稱system 密碼manager 匯出到D:\daochu.dmp中
exp system/manager@196.168.1.10:1521 file=d:\daochu.dmp full=y
2 將資料庫中system使用者與sys使用者的表匯出
exp system/manager@196.168.1.10:1521 file=d:\daochu.dmp owner=(system,sys)
3 將資料庫中的表table1 、table2匯出
exp system/manager@196.168.1.10:1521 file=d:\daochu.dmp tables=(table1,table2)
4 將資料庫中的表table1中的欄位filed1以"00"打頭的資料匯出
exp system/manager@196.168.1.10:1521 file=d:\daochu.dmp tables=(table1) query=\" where filed1 like '00%'\"
上面是常用的匯出,對於壓縮我不太在意,用winzip把dmp檔案可以很好的壓縮。
不過在上面命令後面 加上 compress=y 就可以了
資料的匯入
1 將D:\daochu.dmp 中的資料匯入 TEST資料庫中。
imp system/manager@TEST file=d:\daochu.dmp
上面可能有點問題,因為有的表已經存在,然後它就報錯,對該表就不進行匯入。
在後面加上 ignore=y 就可以了。
2 將d:\daochu.dmp中的表table1 匯入
imp system/manager@TEST file=d:\daochu.dmp tables=(table1)
基本上上面的匯入匯出夠用了。不少情況我是將表徹底刪除,然後匯入。
注意:
你要有足夠的許可權,許可權不夠它會提示你。
資料庫時可以連上的。可以用tnsping TEST 來獲得資料庫TEST能否連上。
資料匯出:
exp hkb/hkb@@196.168.1.10:1521 full=y file=c:\orabackup\hkbfull.dmp log=c:\orabackup\hkbfull.log;
匯出注意事項:匯出的是目前使用者的的資料,目前使用者如果有DBA的許可權,則匯出所有資料。
同名使用者之間的資料匯入:
imp hkb/hkb@@196.168.1.10:1521 file=c:\orabackup\hkbfull.dmp log=c:\orabackup\hkbimp.log full=y
不同名之間的資料匯入:
imp system/test@@196.168.1.10:1521 fromuser=hkb touser=hkb_new file=c:\orabackup\hkbfull.dmp
log=c:\orabackup\hkbimp.log; ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1. 複製表結構及其資料: create table table_name_new as select * from table_name_old
2. 只複製表結構: create table table_name_new as select * from table_name_old where 1=2; 或者: create table table_name_new like table_name_old
3. 只複製表資料:如果兩個表結構一樣:insert into table_name_new select * from table_name_old
如果兩個表結構不一樣:insert into table_name_new(column1,column2...) select column1,column2... from table_name_old