浜嬪姟鍏锋湁鍥涘ぇ鐗规€э紙ACID锛夛細
- 鍘熷瓙鎬?Atomic)锛氫竴涓簨鍔′腑鐨勬墍鏈夋搷浣滐紝瑕佷箞鍏ㄩ儴瀹屾垚锛岃涔堝叏閮ㄤ笉瀹屾垚锛屼笉浼氱粨鏉熷湪涓棿鏌愪釜鐜妭銆備簨鍔″湪鎵ц杩囩▼涓彂鐢熼敊璇紝浼氳鍥炴粴鍒颁簨鍔″紑濮嬪墠鐨勭姸鎬侊紝灏卞儚杩欎釜浜嬪姟浠庢潵娌℃湁鎵ц杩囦竴鏍?/li>
- 涓€鑷存€?Consistency)锛氬湪浜嬪姟寮€濮嬩箣鍓嶅拰浜嬪姟缁撴潫浠ュ悗锛?鏁版嵁搴撶殑瀹屾暣鎬ф病鏈夎鐮村潖
- 闅旂鎬?Isolation)锛氭暟鎹簱鍏佽澶氫釜骞跺彂浜嬪姟鍚屾椂瀵瑰叾鏁版嵁杩涜璇诲啓鍜屼慨鏀圭殑鑳藉姏锛岄殧绂绘€у彲浠ラ槻姝㈠涓簨鍔″苟鍙戞墽琛屾椂鐢变簬浜ゅ弶鎵ц鑰屽鑷存暟鎹殑涓嶄竴鑷淬€備簨鍔¢殧绂诲垎涓轰笉鍚岀骇鍒紝鍖呮嫭璇绘湭鎻愪氦锛圧ead uncommitted锛夈€佽鎻愪氦锛坮ead committed锛夈€佸彲閲嶅璇伙紙repeatable read锛夊拰涓茶鍖栵紙Serializable锛?/li>
- 鎸佷箙鎬?Durability)锛氫簨鍔″鐞嗙粨鏉熷悗锛屽鏁版嵁鐨勪慨鏀瑰氨鏄案涔呯殑锛屽嵆渚跨郴缁熸晠闅滀篃涓嶄細涓㈠け
浜嬪姟鎺у埗锛?/strong>
- BEGIN 鎴?START TRANSACTION 鏄惧紡鍦板紑鍚竴涓簨鍔?/li>
- COMMIT 浼氭彁浜や簨鍔★紝浣垮凡瀵规暟鎹簱杩涜鐨勬墍鏈変慨鏀规垚涓烘案涔呮€х殑
- ROLLBACK 鍥炴粴锛屼細缁撴潫鐢ㄦ埛鐨勪簨鍔★紝骞舵挙閿€姝e湪杩涜鐨勬墍鏈夋湭鎻愪氦鐨勪慨鏀?/li>
- SAVEPOINT identifier锛孲AVEPOINT 鍏佽鍦ㄤ簨鍔′腑鍒涘缓涓€涓繚瀛樼偣锛屼竴涓簨鍔′腑鍙互鏈夊涓?SAVEPOINT
- RELEASE SAVEPOINT identifier 鍒犻櫎涓€涓簨鍔$殑淇濆瓨鐐癸紝娌℃湁鎸囧畾鐨勪繚瀛樼偣鎵ц璇ヨ鍙ヤ細鎶涘嚭涓€涓紓甯?/li>
- ROLLBACK TO identifier 鎶婁簨鍔″洖婊氬埌鏍囪鐐?/li>
- SET TRANSACTION 鐢ㄦ潵璁剧疆浜嬪姟鐨勯殧绂荤骇鍒?/li>
MYSQL 浜嬪姟澶勭悊鐨勬柟娉曪細
1銆佺敤 BEGIN, ROLLBACK, COMMIT鏉ュ疄鐜?/p>
- BEGIN 寮€濮嬩簨鍔?/li>
- ROLLBACK 浜嬪姟鍥炴粴
- COMMIT 浜嬪姟纭
2銆佺洿鎺ョ敤 SET 鏉ユ敼鍙樻彁浜ゆā寮?
- SET AUTOCOMMIT=0 绂佹鑷姩鎻愪氦
- SET AUTOCOMMIT=1 寮€鍚嚜鍔ㄦ彁浜?/li>
娉ㄦ剰锛?/strong>
- MySQL 鐨勪簨鍔℃帶鍒舵槸琛ㄥ紩鎿庝笂澶勭悊锛屾湁浜涘紩鎿庢槸涓嶆敮鎸佷簨鍔$殑
- 涓嶆敮鎸佷簨鍔$殑琛ㄤ笂鎵ц浜嬪姟鎿嶄綔锛孧ySQL涓嶄細鍙戝嚭鎻愰啋锛屼篃涓嶄細鎶ラ敊