- 论坛徽章:
- 3
|
本帖最后由 duolanshizhe 于 2010-07-15 15:50 编辑
设置unused列之后,并不是将该列数据立即删除,而是被隐藏起来,以下为恢复步骤:对数据字典不熟悉的同学测试前做好备份工作- SQL> conn hsy/hsy
- Connected.
- SQL> create table t (a number,b number,c varchar2(10),d number);
- Table created.
- SQL> insert into t values(1,2,'A',3);
- 1 row created.
- SQL> insert into t values(4,5,'B',6);
- 1 row created.
- SQL> commit;
- Commit complete.
- SQL> select * from t;
- A B C D
- ---------- ---------- ---------- ----------
- 1 2 A 3
- 4 5 B 6
-
- SQL> alter table t set unused column c;
- Table altered.
- SQL> select * from t;
- A B D
- ---------- ---------- ----------
- 1 2 3
- 4 5 6
-
- SQL> SET LINESIZE 200
- SQL> SELECT OBJECT_ID,OBJECT_NAME FROM USER_OBJECTS;
- OBJECT_ID OBJECT_NAME
- ---------- -----------------------------------------------
- 70322 XPLAN_NTT
- 70321 XPLAN_OT
- 70323 XPLAN
- 70324 XPLAN
- 71929 2???
- 71930 T
- 70775 TEST_VIEW
- 69706 TEST_PROC
- 8 rows selected.
- SQL> conn hsy/hsy as sysdba
- Connected.
- SQL> select col#,intcol#,name from col$ where obj#=71930;
- COL# INTCOL# NAME
- ---------- ---------- ------------------------------
- 1 1 A
- 2 2 B
- 0 3 SYS_C00003_10071515:33:59$ [color=Red] ---原来的列名为C,被系统修了[/color]
- 3 4 D
- SQL> select cols from tab$ where obj#=71930;
- COLS
- ----------
- 3 [color=Red] ----系统的字段数目也发生了变化 [/color]
- SQL> update col$ set col#=intcol# where obj#=71930;
- 4 rows updated.
- SQL> update tab$ set cols=cols+1 where obj#=71930;
- 1 row updated.
- SQL> update col$ set name='C' where obj#=71930 and col#=3;
- 1 row updated.
- SQL> update col$ set property=0 where obj#=71930;
- 4 rows updated.
- SQL> commit;
- Commit complete.
-
- SQL> startup force; [color=Red] 这一步是必不可少的[/color]
- ORACLE instance started.
- Total System Global Area 1107296256 bytes
- Fixed Size 2020160 bytes
- Variable Size 234884288 bytes
- Database Buffers 855638016 bytes
- Redo Buffers 14753792 bytes
- Database mounted.
- Database opened.
- SQL> select * from hsy.t;
- A B C D
- ---------- ---------- ---------- ----------
- 1 2 A 3
- 4 5 B 6
复制代码 |
|