📜  postgres 重新排序列 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:24.954000             🧑  作者: Mango

代码示例1
PostgreSQL currently defines column order based on the attnum column of the pg_attribute table. The only way to change column order is either by recreating the table, or by adding columns and rotating data until you reach the desired layout.
    
    ----
    
    CREATE VIEW original_tab_vw AS
    SELECT a.col1, a.col3, a.col4, a.col2
    FROM original_tab a
    WHERE a.col1 IS NOT NULL --or whatever