2013-05-16 11 views
9

po prostu utworzyć nowy widok następującopostgres zmienić typ danych widzenia kolumny od unkown tekstu

CREATE OR REPLACE VIEW gettreelistvw AS 
SELECT "CRM".groupid, 'pointrewarding'::text AS applicationid, "CM".menuid, "CM".menuname, "CM".levelstructure, "CM".moduleid, "CM".haschild, "CM".installed 
    FROM core_capabilitymap "CRM" 
    JOIN core_menus "CM" ON "CRM".menuid::text = "CM".menuid::text; 

ALTER TABLE gettreelistvw 

kiedy wykonać ten błąd pojawia się

ERROR: cannot change data type of view column "applicationid" from unknown to text

chociaż ja już rzucać wartość applicationid kolumna do tekstu. nadal jest rozpoznawany jako nieznany typ danych:

'pointrewarding'::text 

Również alternatywna metoda konwersji postgresów nie zadziałała.

CAST('pointrewarding' AS TEXT) 

Jak rozwiązać ten problem.

+0

Powinieneś to sprawdzić na stronie StackExchange DBA: http://dba.stackexchange.com/questions/586/cant-rename-columns-in-postgresql-views- with-create-or-replace – Red15

Odpowiedz

13

Jeśli chcesz zmienić typ danych kolumn widoku, musisz go upuścić, a następnie go utworzyć.

Version 9.2 docs

CREATE OR REPLACE VIEW .... The new query must generate the same columns that were generated by the existing view query (that is, the same column names in the same order and with the same data types), but it may add additional columns to the end of the list.

Podkreślenie.

Powiązane problemy