資料庫回滾與DDL DML

2021-09-07 17:38:49 字數 3244 閱讀 9658

因為ddl沒有事務性,所以ddl不能回滾。

要實現自動回滾。(begin,commit,rollback),則sql語句中只能包括dml。

這樣,自動化發布就會受限規範格式。

故而,一刀切的辦法是,假定所有sql不支援事務,自已定義好rollback的sql指令碼,在出錯時能用**回滾,

而不是依賴於資料庫本身的功能。

ddl (data definition language 資料定義語言)
create table 建立表    

alter table 修改表

drop table 刪除表

truncate table 刪除表中所有行

create index 建立索引

drop index 刪除索引

當執行ddl語句時,在每一條語句前後,oracle都將提交當前的事務。如果使用者使用insert命令將記錄插入到資料庫後,執行了一條ddl語句(如create table),此時來自insert命令的資料將被提交到資料庫。當ddl語句執行完成時,ddl語句會被自動提交,不能回滾。

dml (data manipulation language 資料操作語言)

insert 將記錄插入到資料庫

update 修改資料庫的記錄

delete 刪除資料庫的記錄

當執行dml命令如果沒有提交,將不會被其他會話看到。除非在dml命令之後執行了ddl命令或dcl命令,或使用者退出會話,或終止例項,此時系統會自動發出commit命令,使未提交的dml命令提交。

table 14.8 online ddl support for index operations

operation

in place

rebuilds table

permits concurrent dml

only modifies metadata

creating or adding a secondary index

yesno

yesno

dropping an index

yesno

yesyes

yes*

no*no

no

table 14.9 online ddl support for primary key operations

operation

in place

rebuilds table

permits concurrent dml

only modifies metadata

adding a primary key

yes*

yes*

yesno

dropping a primary key

noyes

nono

dropping a primary key and adding another

yesyes

yesno

table 14.10 online ddl support for column operations

operation

in place

rebuilds table

permits concurrent dml

only modifies metadata

adding a column

yesyes

yes*

nodropping a column

yesyes

yesno

renaming a column

yesno

yes*

yesreordering columns

yesyes

yesno

setting a column default value

yesno

yesyes

changing the column data type

noyes

nono

dropping the column default value

yesno

yesyes

changing the auto-increment value

yesno

yesno*

yesyes*

yesno

yes*

yes*

yesno

table 14.11 online ddl support for foreign key operations

operation

in place

rebuilds table

permits concurrent dml

only modifies metadata

adding a foreign key constraint

yes*

noyes

yesdropping a foreign key constraint

yesno

yesyes

table 14.12 online ddl support for table operations

operation

in place

rebuilds table

permits concurrent dml

only modifies metadata

yesyes

yesno

yesyes

yesno

setting persistent table statistics

yesno

yesyes

specifying a character set

yes*

yes*

nono

converting a character set

noyes

nono

optimizing a table

yes*

yesyes

noyes*

yesyes

noperforming a null rebuild

yes*

yesyes

no

資料庫回滾

oracle恢復刪除表或表記錄 一 表的恢復 對誤刪的表,只要沒有使用purge永久刪除選項,那麼從flash back區恢復回來希望是挺大的。一般步驟有 1 從flash back裡查詢被刪除的表 select from recyclebin 2.執行表的恢復 flashback table tb...

資料庫回滾問題

今天遇到的小問題 override public result importexcel multipartfile file throws illegalacces ception,instantiationexception,ioexception,invalidformatexception e...

事務回滾與手動回滾

一般我們在開發時,在方法或者類上加了 transactional事務註解,然後會用 try catch 將可能會出問題的 塊包起來,在catch裡面處理捕獲的異常,但是,如果在catch裡面沒有把異常丟擲去,此時事務是不會自動回滾的 比如這種情況 這裡既沒有丟擲異常,也沒有手動回滾,在插入流水表之後...