快捷搜索:

瀵规瘮Oracle涓存椂琛ㄥ拰SQL Server涓存椂琛ㄧ殑涓

Oracle鏁版嵁搴撳垱寤轰复鏃惰〃鐨勮繃绋嬩互鍙婂拰SQL Server涓存椂琛ㄧ殑涓嶅悓鐐圭殑瀵规瘮鐨勭浉鍏崇煡璇嗘槸鏈枃鎴戜滑涓昏瑕佷粙缁嶇殑鍐呭锛屾帴涓嬫潵灏辫鎴戜滑涓€璧锋潵浜嗚В涓€涓嬭繖閮ㄥ垎鍐呭鍚э紝甯屾湜鑳藉瀵规偍鏈夋墍甯姪銆?/p>

1.绠€浠?/strong>

Oracle鏁版嵁搴撻櫎浜嗗彲浠ヤ繚瀛樻案涔呰〃澶栵紝杩樺彲浠ュ缓绔嬩复鏃惰〃temporary tables銆傝繖浜涗复鏃惰〃鐢ㄦ潵淇濆瓨涓€涓細璇漇ESSION鐨勬暟鎹紝鎴栬€呬繚瀛樺湪涓€涓簨鍔′腑闇€瑕佺殑鏁版嵁銆傚綋浼氳瘽閫€鍑烘垨鑰呯敤鎴锋彁浜ommit鍜屽洖婊歳ollback浜嬪姟鐨勬椂鍊欙紝涓存椂琛ㄧ殑鏁版嵁鑷姩娓呯┖锛屼絾鏄复鏃惰〃鐨勭粨鏋勪互鍙婂厓鏁版嵁杩樺瓨鍌ㄥ湪鐢ㄦ埛鐨勬暟鎹瓧鍏镐腑銆?/p>

2.璇︾粏浠嬬粛

Oracle涓存椂琛?/strong>鍒嗕负浼氳瘽绾т复鏃惰〃鍜屼簨鍔$骇涓存椂琛ㄣ€?/p>

浼氳瘽绾т复鏃惰〃鏄寚涓存椂琛ㄤ腑鐨勬暟鎹彧鍦ㄤ細璇濈敓鍛藉懆鏈熶箣涓瓨鍦紝褰撶敤鎴烽€€鍑轰細璇濈粨鏉熺殑鏃跺€欙紝Oracle鑷姩娓呴櫎涓存椂琛ㄤ腑鏁版嵁銆?/p>

浜嬪姟绾т复鏃惰〃鏄寚涓存椂琛ㄤ腑鐨勬暟鎹彧鍦ㄤ簨鍔$敓鍛藉懆鏈熶腑瀛樺湪銆傚綋涓€涓簨鍔$粨鏉燂紙commit or rollback锛夛紝Oracle鑷姩娓呴櫎涓存椂琛ㄤ腑鏁版嵁銆?/p>

涓存椂琛ㄤ腑鐨勬暟鎹彧瀵瑰綋鍓峉ession鏈夋晥锛屾瘡涓猄ession閮芥湁鑷繁鐨勪复鏃舵暟鎹紝骞朵笖涓嶈兘璁块棶鍏跺畠Session鐨勪复鏃惰〃涓殑鏁版嵁銆傚洜姝わ紝涓存椂琛ㄤ笉闇€瑕丏ML閿併€?/p>

褰撲竴涓細璇濈粨鏉?鐢ㄦ埛姝e父閫€鍑?鐢ㄦ埛涓嶆甯搁€€鍑?ORACLE瀹炰緥宕╂簝)鎴栬€呬竴涓簨鍔$粨鏉熺殑鏃跺€欙紝Oracle瀵硅繖涓細璇濈殑琛ㄦ墽琛?TRUNCATE 璇彞娓呯┖涓存椂琛ㄦ暟鎹?浣嗕笉浼氭竻绌哄叾瀹冧細璇濅复鏃惰〃涓殑鏁版嵁.

浣犲彲浠ョ储寮曚复鏃惰〃鍜屽湪涓存椂琛ㄥ熀纭€涓婂缓绔嬭鍥?鍚屾牱,寤虹珛鍦ㄤ复鏃惰〃涓婄殑绱㈠紩涔熸槸涓存椂鐨?涔熸槸鍙褰撳墠浼氳瘽鎴栬€呬簨鍔℃湁鏁? 涓存椂琛ㄥ彲浠ユ嫢鏈夎Е鍙戝櫒.

3.寤虹珛涓存椂琛?/strong>

涓存椂琛ㄧ殑瀹氫箟瀵规墍鏈変細璇漇ESSION閮芥槸鍙鐨?浣嗘槸琛ㄤ腑鐨勬暟鎹彧瀵瑰綋鍓嶇殑浼氳瘽鎴栬€呬簨鍔℃湁鏁?

寤虹珛鏂规硶锛?/p>

1) ON COMMIT DELETE ROWS 瀹氫箟浜嗗缓绔嬩簨鍔$骇涓存椂琛ㄧ殑鏂规硶. 
CREATE GLOBAL TEMPORARY TABLE admin_work_area 
(startdate DATE, 
enddate DATE, 
class CHAR(20)) 
ON COMMIT DELETE ROWS; 
EXAMPLE: 
SQL> CREATE GLOBAL TEMPORARY TABLE admin_work_area 
2 (startdate DATE, 
3 enddate DATE, 
4 class CHAR(20)) 
5 ON COMMIT DELETE ROWS; 
SQL> create table permernate( a number); 
SQL> insert into admin_work_area values(sysdate,sysdate,'temperary table'); 
SQL> insert into permernate values(1); 
SQL> commit; 
SQL> select * from admin_work_area; 
SQL> select * from permernate; 
A 
1 
2)ON COMMIT PRESERVE ROWS 瀹氫箟浜嗗垱寤轰細璇濈骇涓存椂琛ㄧ殑鏂规硶. 
CREATE GLOBAL TEMPORARY TABLE admin_work_area 
(startdate DATE, 
enddate DATE, 
class CHAR(20)) 
ON COMMIT PRESERVE ROWS; 
EXAMPLE: 
        

您可能还会对下面的文章感兴趣: