Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2840557
  • 博文数量: 599
  • 博客积分: 16398
  • 博客等级: 上将
  • 技术积分: 6875
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-30 12:04
个人简介

WINDOWS下的程序员出身,偶尔也写一些linux平台下小程序, 后转行数据库行业,专注于ORACLE和DB2的运维和优化。 同时也是ios移动开发者。欢迎志同道合的朋友一起研究技术。 数据库技术交流群:58308065,23618606

文章分类

全部博文(599)

文章存档

2014年(12)

2013年(56)

2012年(199)

2011年(105)

2010年(128)

2009年(99)

分类: Oracle

2012-08-03 15:06:26

 
对于DELETE操作,oracle在块级别只是做了个删除的标记,数据还在,因此可以用恢复工具恢复出来数据。
但是DROP COLUMN会从数据块级别清理掉数据,因此恢复工具也很难恢复了。
for example:

点击(此处)折叠或打开

  1. SQL> create table scott.test (id int,name varchar2(20));

  2. Table created.

  3. SQL> insert into scott.test values(1,'abc');

  4. 1 row created.

  5. SQL> insert into scott.test values(2,'htyansp');

  6. 1 row created.

  7. SQL> commit;

  8. Commit complete.

  9. SQL> alter system checkpoint;

  10. System altered.

  11. SQL> select dbms_rowid.rowid_relative_fno(rowid) file#,
  12.   2 dbms_rowid.rowid_block_number(rowid) block#
  13.   3 from scott.test;

  14.      FILE# BLOCK#
  15. ---------- ----------

  16.          5 681440
  17.          5 681440

  18. SQL> select name from v$dbfile where file#=5;

  19. NAME
  20. --------------------------------------------------------------------------------

  21. /oradata/testdb/users01.dbf




  22. BBED> set block 681440
  23.         BLOCK# 681440

  24. BBED> p rowdata
  25. ub1 rowdata[0] @8164 0x2c
  26. ub1 rowdata[1] @8165 0x01
  27. ub1 rowdata[2] @8166 0x02
  28. ub1 rowdata[3] @8167 0x02
  29. ub1 rowdata[4] @8168 0xc1
  30. ub1 rowdata[5] @8169 0x03
  31. ub1 rowdata[6] @8170 0x07
  32. ub1 rowdata[7] @8171 0x68
  33. ub1 rowdata[8] @8172 0x74
  34. ub1 rowdata[9] @8173 0x79
  35. ub1 rowdata[10] @8174 0x61
  36. ub1 rowdata[11] @8175 0x6e
  37. ub1 rowdata[12] @8176 0x73
  38. ub1 rowdata[13] @8177 0x70
  39. ub1 rowdata[14] @8178 0x2c
  40. ub1 rowdata[15] @8179 0x01
  41. ub1 rowdata[16] @8180 0x02
  42. ub1 rowdata[17] @8181 0x02
  43. ub1 rowdata[18] @8182 0xc1
  44. ub1 rowdata[19] @8183 0x02
  45. ub1 rowdata[20] @8184 0x03
  46. ub1 rowdata[21] @8185 0x61
  47. ub1 rowdata[22] @8186 0x62
  48. ub1 rowdata[23] @8187 0x63

  49. BBED> x /rnc 8164
  50. rowdata[0] @8164
  51. ----------

  52. flag@8164: 0x2c (KDRHFL, KDRHFF, KDRHFH)
  53. lock@8165: 0x01
  54. cols@8166: 2

  55. col 0[2] @8167: 2
  56. col 1[7] @8170: htyansp


  57. BBED> x /rnc 8178
  58. rowdata[14] @8178
  59. -----------

  60. flag@8178: 0x2c (KDRHFL, KDRHFF, KDRHFH)
  61. lock@8179: 0x01
  62. cols@8180: 2

  63. col 0[2] @8181: 1
  64. col 1[3] @8184: abc


  65. BBED>

上面是列还没有被删除的时候,数据在块中的形式。

删掉NAME列
 

点击(此处)折叠或打开

  1. SQL> alter table scott.test drop column name;

  2. Table altered.

  3. SQL> alter system checkpoint;

  4. System altered.

再次查询块中数据的情况:
 

点击(此处)折叠或打开

  1. BBED> x /rnc 8164
  2. rowdata[0] @8164
  3. ----------

  4. flag@8164: 0x2c (KDRHFL, KDRHFF, KDRHFH)
  5. lock@8165: 0x02
  6. cols@8166: 1

  7. col 0[2] @8167: 2


  8. BBED> x /rnc 8178
  9. rowdata[14] @8178
  10. -----------

  11. flag@8178: 0x2c (KDRHFL, KDRHFF, KDRHFH)
  12. lock@8179: 0x02
  13. cols@8180: 1

  14. col 0[2] @8181: 1


  15. BBED>

DROP COLUMN将会导致数据被清理掉,这种情况下数据时很难恢复了。
阅读(1486) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~