How to fix a field that is set to unused

Source: Internet
Author: User
How to fix a field that is set to unused, the following methods can be recovered (the following steps should be backed up before execution).
1, create the experimental table Ttta
Sql> CREATE TABLE Ttta (A integer,b integer,c VARCHAR2 (A), D INTEGER);
Table has been created.
Sql> INSERT into Ttta VALUES (1, 2, ' 3 ', 4);
1 lines have been created.
Sql> INSERT into Ttta VALUES (2,3, ' 4 ', 5);
1 lines have been created.
Sql> COMMIT;
Submit completed.
ALTER TABLE Ttta SET unused COLUMN C; Set the C field in the Ttta table to be unavailable
2, the following recovery
Logged in as an administrator, where Oracle was the password that was set when oracle10g was installed
Sql> Conn Sys/oracle as Sysdba

Find the number assigned to Ttta in the database
Sql> SELECT obj# from obj$ WHERE name= ' Ttta ';
obj#
----------
32067
SELECT col#,intcol#,name from col$ WHERE obj#=32067;
col# intcol# NAME
---------- ---------- ------------------------------
1 1 A
2 2 B
0 3 sys_c00003_08031720:09:55$ fields to be unused
3 4 D
Sql> SELECT COLS from tab$ WHERE obj#=32067;
COLS
----------
3------The number of fields becomes 3.

sql> UPDATE col$ SET col#=intcol# WHERE obj#=32067;
4 rows have been updated.
sql> UPDATE tab$ SET cols=cols+1 WHERE obj#=32067;
1 rows have been updated.
UPDATE col$ SET name= ' C ' WHERE obj#=32067 and col#=3;
UPDATE col$ SET property=0 WHERE obj#=32067;
Sql> COMMIT; --commits the transaction so that previous actions have been taken into effect
3, restart the database
Sql> SELECT * from SCOTT. Ttta;
A B C D
---------- ---------- ---------- ----------
1 2 3 4
2 3 4 5
Recovery complete

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.