資料庫導表和鎖表問題
一些基本的資料庫操作,好長時間不用了,好像有點忘了。在這裡還是要記一下啊
清空資料表: truncate table +表名
建立索引: create index +索引名(idx_) on 表名(列名);
建立唯一索引:create unique clustered +索引名(idx_) on 表名(列名);
刪除索引: drop index 表名.索引名;
資料庫在伺服器的匯入匯出
匯出
首先要進入oracle使用者下
還要建立使用者名稱
將使用者user使用者表匯入到/tmp下
exp user/[email protected] file=/tmp/20180115.dmp owner=user
將使用者user使用者的表table1,table2匯入到
/tmp下
exp user/[email protected] file=/tmp/20180115.dmp tables=(table1,table2)
將使用者user使用者的表table1中的欄位filed1以"a"開頭的資料匯出
exp user/[email protected] filed=/tmp/20180115.dmp tables=(table1) query=/" where filed1 like 'a%'/"
匯入
將/temp/20180115.dmp檔案匯入到user下
imp user/[email protected]
先將資料庫檔案匯出到tmp下,然後再匯入到另一個使用者下。
-exp npstest/npstest owner=npstest file=/tmp/ nps.dmp
Imp qxnxy/[email protected] fromuser=qxnxy touser=qxnxy ignore=y file=/tmp/nps.dmp
鎖表問題怎樣解決
首先你要知道表鎖住了是不是正常鎖?因為任何DML語句都會對錶加鎖。你要先查一下是那個會話那個sql鎖住了表,有可能這是正常業務需求,不建議隨便KILL session,如果這個鎖表是正常業務你把session kill掉了會影響業務的。