oracle中的一個程序,在向一張表中插入資料前先洗掉表中所有資料,有什么作用。
uj5u.com熱心網友回復:
這種表,一般是臨時存放資料使用,寫入前洗掉,是為了防止資料重復。uj5u.com熱心網友回復:
我更喜歡先drop table再重新create
uj5u.com熱心網友回復:
動態使用ctas的也很多。
uj5u.com熱心網友回復:
如果上面關聯物件很多,不如truncate
uj5u.com熱心網友回復:
如果是臨時表臨時用,可以選擇事務級或會話級專用臨時表。uj5u.com熱心網友回復:
為了防止資料重復插入,所以使用delete 或者truncate;究竟要delete 還是truncate ,要根據你的insert ...from....where...,from后面的資料情況。
具體如下,你from的table除了按照where條件增加外,資料不發生其他變化,使用delete,有可能你from的資料是超大資料,這時候
truncate 后insert 時間太長;你from的table資料經常發生變化,有增刪改,為了一致性,要使用truncate。
比如:
insert into a from selet * from b where b.create_date='20170105';
b表是一個經常修改的表,那你要先truncate ,再insert into a from selet * from b where b.create_date='20170105' ;
b表除了每天增加資料外不做其他變化,那你就delete from a where a.create_date='20170105' ;然后insert into a from selet * from b where b.create_date='20170105' ;
上面的答復都太草率,希望你能看懂!
uj5u.com熱心網友回復:
最后那個多了半句,例子是從b把資料插入目標表a ,insert into a from selet * from b 。轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/107661.html
標籤:開發
