OracleFaq (how to change the column name and sequence of tables in ORACLE ). If you need to reprint it, please indicate the source! Anyone who has used ORACLE knows that it is very cumbersome to change the column name and sequence of tables in ORACLE. here is a simple method. If you need to reprint it, please indicate the source! Anyone who has used ORACLE knows that it is very cumbersome to change the column name and sequence of tables in ORACLE. here is a simple method. 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 = ID; 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 7 rows selected. SQL> shutdown immediate Database closed. database dismounted. ORACLE instance shut down. SQL> Startup ORACLE instance started. total System Global Area 128159368 bytes Fixed Size 732808 bytes Variable Size 117440512 bytes Database Buffers 8388608 bytes Redo Buffers 1597440 bytes Database mounted. database opened. SQL> select * from scott. t1; MY_NAME NEW_ID ------------------ ---------- cheng 3 yong 2 xin 1 gototop 2 topcio 1 yongxin 2 cyx 1 7 rows selected. so far, SCOTT. the column name and sequence in table T1 are given to this If you only want to change the order and do not want to change the column NAME, you only need to UPDATE the column NAME. the reason why the UPDATE cannot be completed at one time is because the COL # and NAME in SYS. COL $ are all UNIQUE. Although this method is risky, it has obvious effects on a particularly large table. However, the general method requires more storage space, rollback segments, and time overhead.
Success! Anyone who has used ORACLE knows that it is very cumbersome to change the column name and sequence of tables in ORACLE. here is a simple method ....