2013-05-16 7 views
9

अज्ञात से देखने स्तंभ के डेटा प्रकार को बदलने के रूप मेंpostgres पाठ में

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 

इस प्रकार जब मैं निष्पादित इस त्रुटि

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

दिखाई हालांकि मैं पहले से ही applicationid का मूल्य डाली मैं सिर्फ एक नया दृश्य बनाने पाठ के लिए कॉलम। यह अभी भी अनजान डेटाटाइप

'pointrewarding'::text 

पोस्टग्रेस रूपांतरण का वैकल्पिक तरीका भी काम नहीं करता है।

CAST('pointrewarding' AS TEXT) 

इस समस्या को हल करने के लिए कैसे करें।

+0

आपको इसे स्टैक एक्सचेंज डीबीए पर देखना चाहिए: http://dba.stackexchange.com/questions/586/cant-rename-columns-in-postgresql-views-with-create-or-replace – Red15

उत्तर

13

यदि आप डेटा के दृश्य प्रकार को कॉल करना चाहते हैं, तो आपको इसे छोड़ना होगा, फिर इसे बनाना होगा।

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.

जोर जोड़ा।