在oracle中改变字段在表中的顺序Oracle认证考试
文章作者 100test 发表时间 2009:11:20 16:54:17
来源 100Test.Com百考试题网
"mkhgigh">
用过ORACLE的人都知道,要想在ORACLE中更改表的列名和顺序可是一件很烦琐的事,下面给大家提供一种简单的方法。
SQL>. 0select object_id from all_objects where owner= SCOTT and object_name= T1 .
OBJECT_ID
----------
6067
SQL>. 0select obj#,col#,name from sys.col$ where obj#=6067.
OBJ# COL#
---------- ----------
NAME
------------------------------------------------------------
6067 1
ID
6067 2
NAME
SQL>. 0update sys.col$ set name= NEW_ID ,col#=3 where obj#=6067 and name= ID .
1 row 0updated.
SQL>. 0update sys.col$ set name= MY_NAME ,col#=1 where obj#=6067 and name= NAME .
1 row 0updated.
SQL>. 0update sys.col$ set col#=2 where obj#=6067 and col#=3.
1 row 0updated.
SQL>. commit.
Commit complete.
SQL>. 0select * from scott.t1.
ID NAME
---------- --------------------