Fujii Masao <masao.fu...@gmail.com> writes: > Currently CREATE OR REPLACE VIEW command fails if the column names > are changed.
That is, I believe, intentional. It's an effective aid to catching mistakes in view redefinitions, such as misaligning the new set of columns relative to the old. That's particularly important given that we allow you to add columns during CREATE OR REPLACE VIEW. Consider the oversimplified case where you start with CREATE VIEW v AS SELECT 1 AS x, 2 AS y; and you want to add a column z, and you get sloppy and write CREATE OR REPLACE VIEW v AS SELECT 1 AS x, 3 AS z, 2 AS y; If we did not throw an error on this, references that formerly pointed to column y would now point to z (as that's still attnum 2), which is highly unlikely to be what you wanted. The right way to handle a column rename in a view is to do a separate ALTER VIEW RENAME COLUMN, making it totally clear what you intend to happen. (Right now, we make you spell that "ALTER TABLE RENAME COLUMN", but it'd be reasonable to add that syntax to ALTER VIEW too.) I don't think this functionality should be folded into redefinition of the content of the view. It'd add more opportunity for mistakes than anything else. regards, tom lane