1. 程式人生 > >ORACLE資料庫調整表字段順序

ORACLE資料庫調整表字段順序

第一種方法:

刪除重建,但是這樣會刪除表中資料,可以建一個臨時備份表,先將資料儲存到臨時表中,再刪除重建目標表,然後再將臨時表中的資料按欄位順序INSERT到新的表中。

第二種方法:

1.首先,用DBA使用者登入。

2.select object_id fromm all_objects where owner = '使用者名稱' and object_name = '表名';

查出需要更改欄位順序表的ID號

3.select obj#,col#,name from sys.col$ where obj# = 'ID號' order by col#;

通過2查出的ID號查出該表所有欄位的順序

4.update sys.col$ set col# = 2 where obj# = 'ID號' and name = '欄位1';

update sys.col$ set col# = 3 where obj# = 'ID號' and name = '欄位2';

將欄位1調整到第二位,將欄位2調整為第3位