How to fix the field set to unused

Source: Internet
Author: User

To restore the unused field, follow these steps ).
1. Create an experiment table ttta
SQL> Create Table ttta (a integer, B integer, C varchar2 (10), d integer );
The table has been created.
SQL> insert into ttta values (1, 2, '3', 4 );
One row has been created.
SQL> insert into ttta values (2, 3, '4', 5 );
One row has been created.
SQL> commit;
Submitted.
Alter table ttta set unused column C; set the c field in the ttta table to unavailable
2. perform the following restoration:
Log on as an administrator. Oracle is the password set when Oracle10g is installed.
SQL> conn sys/Oracle AS sysdba

Find the ID allocated by 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
2 2 B
0 3 sys_c1_3_08031720: 09: 55 $ unused Field
3 4 d
SQL> select Cols from tab $ where OBJ #= 32067;
Cols
----------
3 ------ the number of fields has changed to 3

SQL> Update Col $ set Col #= intcol # Where OBJ #= 32067;
Four rows have been updated.
SQL> Update Tab $ set Cols = Cols + 1 where OBJ #= 32067;
1 row updated.
Update Col $ set name = 'C' where OBJ #= 32067 and Col # = 3;
Update Col $ set property = 0 where OBJ # = 32067;
SQL> commit; -- submit the transaction to make the previous operations take effect.
3. Restart the database
SQL> select * from Scott. ttta;
A B c d
----------------------------------------
1 2 3 4
2 3 4 5
Recovery completed

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.