因为DDL没有事务性,所以DDL不能回滚。

要实现自动回滚。(begin,commit,rollback),则SQL语句中只能包括DML。

这样,自动化发布就会受限规范格式。

故而,一刀切的办法是,假定所有SQL不支持事务,自已定义好ROLLBACK的SQL脚本,在出错时能用代码回滚,

而不是依赖于数据库本身的功能。

========================

DDL和DML

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 Yes No Yes No
Dropping an index Yes No Yes Yes
Adding a FULLTEXT index 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* Yes No
Dropping a primary key No Yes No No
Dropping a primary key and adding another Yes Yes Yes No

Table 14.10 Online DDL Support for Column Operations

Operation In Place Rebuilds Table Permits Concurrent DML Only Modifies Metadata
Adding a column Yes Yes Yes* No
Dropping a column Yes Yes Yes No
Renaming a column Yes No Yes* Yes
Reordering columns Yes Yes Yes No
Setting a column default value Yes No Yes Yes
Changing the column data type No Yes No No
Dropping the column default value Yes No Yes Yes
Changing the auto-increment value Yes No Yes No*
Making a column NULL Yes Yes* Yes No
Making a column NOT NULL Yes* Yes* Yes No
 

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* No Yes Yes
Dropping a foreign key constraint Yes No Yes Yes

Table 14.12 Online DDL Support for Table Operations

Operation In Place Rebuilds Table Permits Concurrent DML Only Modifies Metadata
Changing the ROW_FORMAT Yes Yes Yes No
Changing the KEY_BLOCK_SIZE Yes Yes Yes No
Setting persistent table statistics Yes No Yes Yes
Specifying a character set Yes* Yes* No No
Converting a character set No Yes No No
Optimizing a table Yes* Yes Yes No
Rebuilding with the FORCE option Yes* Yes Yes No
Performing a null rebuild Yes* Yes Yes No







因为DDL没有事务性,所以DDL不能回滚。

要实现自动回滚。(begin,commit,rollback),则SQL语句中只能包括DML。

这样,自动化发布就会受限规范格式。

故而,一刀切的办法是,假定所有SQL不支持事务,自已定义好ROLLBACK的SQL脚本,在出错时能用代码回滚,

而不是依赖于数据库本身的功能。

========================

DDL和DML

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 Yes No Yes No
Dropping an index Yes No Yes Yes
Adding a FULLTEXT index 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* Yes No
Dropping a primary key No Yes No No
Dropping a primary key and adding another Yes Yes Yes No

Table 14.10 Online DDL Support for Column Operations

Operation In Place Rebuilds Table Permits Concurrent DML Only Modifies Metadata
Adding a column Yes Yes Yes* No
Dropping a column Yes Yes Yes No
Renaming a column Yes No Yes* Yes
Reordering columns Yes Yes Yes No
Setting a column default value Yes No Yes Yes
Changing the column data type No Yes No No
Dropping the column default value Yes No Yes Yes
Changing the auto-increment value Yes No Yes No*
Making a column NULL Yes Yes* Yes No
Making a column NOT NULL Yes* Yes* Yes No
 

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* No Yes Yes
Dropping a foreign key constraint Yes No Yes Yes

Table 14.12 Online DDL Support for Table Operations

Operation In Place Rebuilds Table Permits Concurrent DML Only Modifies Metadata
Changing the ROW_FORMAT Yes Yes Yes No
Changing the KEY_BLOCK_SIZE Yes Yes Yes No
Setting persistent table statistics Yes No Yes Yes
Specifying a character set Yes* Yes* No No
Converting a character set No Yes No No
Optimizing a table Yes* Yes Yes No
Rebuilding with the FORCE option Yes* Yes Yes No
Performing a null rebuild Yes* Yes Yes No







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 Yes No Yes No
Dropping an index Yes No Yes Yes
Adding a FULLTEXT index 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* Yes No
Dropping a primary key No Yes No No
Dropping a primary key and adding another Yes Yes Yes No

Table 14.10 Online DDL Support for Column Operations

Operation In Place Rebuilds Table Permits Concurrent DML Only Modifies Metadata
Adding a column Yes Yes Yes* No
Dropping a column Yes Yes Yes No
Renaming a column Yes No Yes* Yes
Reordering columns Yes Yes Yes No
Setting a column default value Yes No Yes Yes
Changing the column data type No Yes No No
Dropping the column default value Yes No Yes Yes
Changing the auto-increment value Yes No Yes No*
Making a column NULL Yes Yes* Yes No
Making a column NOT NULL Yes* Yes* Yes No
 

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* No Yes Yes
Dropping a foreign key constraint Yes No Yes Yes

Table 14.12 Online DDL Support for Table Operations

Operation In Place Rebuilds Table Permits Concurrent DML Only Modifies Metadata
Changing the ROW_FORMAT Yes Yes Yes No
Changing the KEY_BLOCK_SIZE Yes Yes Yes No
Setting persistent table statistics Yes No Yes Yes
Specifying a character set Yes* Yes* No No
Converting a character set No Yes No No
Optimizing a table Yes* Yes Yes No
Rebuilding with the FORCE option Yes* Yes Yes No
Performing a null rebuild Yes* Yes Yes No







相关文章:

  • 2022-12-23
  • 2021-11-12
  • 2021-07-14
  • 2022-02-14
  • 2021-12-01
  • 2021-11-25
  • 2021-12-19
  • 2021-09-18
猜你喜欢
  • 2022-01-30
  • 2021-09-27
  • 2022-12-23
  • 2021-07-01
  • 2021-09-06
相关资源
相似解决方案