ITPub博客

首页 > 数据库 > 数据库开发技术 > DB2 DDL不是一个自冶事务

DB2 DDL不是一个自冶事务

原创 数据库开发技术 作者:pingshx 时间:2009-09-18 14:48:15 0 删除 编辑

在Oracle里一个DDL操作是一个原子操作,当执行一个DDL命令时,之前的所有操作都会commit,永久生效,而DB2不是这样的,DB2的DDL不是一个自冶原子事务,下面的测试:
Linux 1: db2 connect to cmdb

Database Connection Information

Database server = DB2/LINUXX8664 9.5.2
SQL authorization ID = User001
Local database alias = testdb

Linux 2: db2 +c " create table test00(a int)"
DB20000I The SQL command completed successfully.
Linux 3: db2 +c "insert into test00 values(1),(2)"
DB20000I The SQL command completed successfully.
Linux 4: db2 +c "select * from test00"
A
-----------
1
2
2 record(s) selected.

Linux 5: db2 +c "describe table test00"
Data type Column
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
A SYSIBM INTEGER 4 0 Yes

1 record(s) selected.

Linux 6: db2 +c " rollback"
DB20000I The SQL command completed successfully.
Linux 7: db2 +c "select * from test00"
SQL0204N "E460222.TEST00" is an undefined name. SQLSTATE=42704
Linux 8: db2 +c "describe table test00"

Data type Column
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------

0 record(s) selected.

SQL0100W No row was found for FETCH, UPDATE or DELETE; or the result of a
query is an empty table. SQLSTATE=02000
Linux 9: db2 +c "select count(1) from syscat.tables where tabname='TEST00'"

1
-----------
0
1 record(s) selected.

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/45188/viewspace-1027108/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    44
  • 访问量
    156408