Oracle move column to the first position

后端 未结 8 2031
借酒劲吻你
借酒劲吻你 2021-01-17 23:39

Is there any way to move an column in an Oracle table from last to first position? Someone has dropped the ID column, and recreated it. So now it is at the end, which is a p

8条回答
  •  失恋的感觉
    2021-01-18 00:28

    the simplest way to modify the logical order of the columns of a table is to rename your table and create a view with the "right" column positions:

    ALTER TABLE your_table RENAME TO your_table_t;
    
    CREATE VIEW your_table AS SELECT  FROM your_table_t;
    
    -- grants on the view (the same as the table)
    GRANT ** TO ** ON your_table;
    

    Your application will behave as if the columns were in the "right" position. You don't have to touch at the physical structure.

提交回复
热议问题