If you want to reprint Oracle, please specify the source!
As anyone who has ever used Oracle knows, to change the column names and order of tables in Oracle is a trivial matter, here's a simple way to do it.
Sql> Select object_id from all_objects where owner= ' SCOTT ' and object_name= ' T1 ';
object_id
----------
6067
Sql> Select Obj#,col#,name from sys.col$ where obj#=6067;
obj# col#
---------- ----------
NAME
------------------------------------------------------------
6067 1
Id
6067 2
NAME
sql> Update sys.col$ set name= ' new_id ', col#=3 where obj#=6067 and name= ' IDs ';
1 row updated.
sql> Update sys.col$ set name= ' My_name ', col#=1 where obj#=6067 and name= ' name ';
1 row updated.
sql> Update sys.col$ set col#=2 where obj#=6067 and col#=3;
1 row updated.
Sql> commit;
Commit complete.
Sql> select * from Scott.t1;
ID NAME
---------- --------------------
3 Cheng
2 Yong
1 Xin
2 Gototop
1 Topcio
2 Yongxin
1 cyx
So far we've given the column names and orders in the Scott.t1 table, and if you just want to change the order and not change the name of the column, just update it and you can't do it all at once because sys.col$ Col#,name are unique.
Although this method has a certain risk, but for particularly large table effect is very obvious, and the general method will require more storage space, rollback segment and time overhead.
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.