Re: BUG #3597: CREATE OR REPLACE VIEW

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: BUG #3597: CREATE OR REPLACE VIEW
Дата
Msg-id 46DD15AF.5000809@enterprisedb.com
обсуждение исходный текст
Ответ на Re: BUG #3597: CREATE OR REPLACE VIEW  ("Luiz K. Matsumura" <luiz@planit.com.br>)
Ответы Re: BUG #3597: CREATE OR REPLACE VIEW  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Luiz K. Matsumura wrote:
> Heikki Linnakangas wrote:
>> Luiz K. Matsumura wrote:
>>
>>> When we do a command Create or Replace View that change columns of
>>> previous
>>> view we got a error.
>>
>> Right. You can't change the data types of an existing view. You'll have
>> to drop and recreate it.
>>
> But, with  the 'replace' command, this isn't implicit ?
> If they found a view, replace the existing view with the new one (on the
> other words, drop and create again?)

Replacing is not exactly the same thing as dropping and recreating it.
If the view has dependencies, you can't drop it without dropping the
dependent objects first, and likewise you can't change its datatypes
because it would affect the dependent objects as well (hence the
limitation on CREATE OR REPLACE VIEW). But you can replace the
definition CREATE OR REPLACE VIEW, even when there's dependencies. For
example:

CREATE VIEW foo AS SELECT 10::integer;
CREATE VIEW bar AS SELECT * FROM foo;

CREATE OR REPLACE VIEW foo AS SELECT 'foobar'::text; -- Fails, can't
change data type of an existing view
DROP VIEW foo; -- Fails because 'bar' depends on foo
CREATE OR REPLACE VIEW foo AS SELECT 20::integer; -- Succeeds.

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Luiz K. Matsumura"
Дата:
Сообщение: Re: BUG #3597: CREATE OR REPLACE VIEW
Следующее
От: "Heikki Linnakangas"
Дата:
Сообщение: Re: BUG #3598: Strange behaviour of character columns in select with views