增加字段的語句很簡單,以用戶身份連接oracle服務:
alter table tablename add(colname coltype); # 填上表名、字段名、字段類型
修改字段順序前,查看表中各字段的順序:
首先,查看表對應的id:
select object_id from all_objects where owner = 'user' and object_name = 'tablename'; # 填上表的所有者、表名
然后,查看表中各字段的順序:
select obj#,col#,name from sys.col$ where obj#=objectid # 填上剛剛查到的表id
再以sysdba身份連接oracle服務,修改字段順序,否則可能會報權限不夠:
update sys.col$ set col#=new where name='colname' and obj#=objectid # 填上字段新的順序、字段名、表id
值得注意的一點是,更新完字段順序后,若直接插入數據,還是按舊的字段順序插入的,需要指定插入的字段或者重啟oracle。