Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2008
    Posts
    135

    Unanswered: Alter Column Used In View

    is it possible to alter a column in a table which is used in the view

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    The column's data type in the view is determined by the underlying table's column.

    What exactly are you trying to do?

    Please post the DDL to create the table and the view, otherwise this will just be wild guesses

  3. #3
    Join Date
    Dec 2008
    Posts
    135
    Actually I had a column code character varying(2)
    and values stored in the code column as 'in','uk','us','it'............

    and the in the view i am checking the where condition as site::text = 'uk'::text

    and i tried by changing where condition as site::character varying(3)= 'uk'::character varying(3) also.........

    but now i want to alter the code column as character varying(3)

    but giving me error as
    ERROR: cannot alter type of a column used by a view or rule
    DETAIL: rule _RETURN on view vw_test depends on column "code"

    is it possible to alter a column which is used in the view or not? if yes how?

  4. #4
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    As you refuse to show any DDL for the table and the view this is really hard (if not impossible) to tell.

    Why do you need to cast anyway? Why not simply write site = 'uk'

  5. #5
    Join Date
    Aug 2009
    Location
    Olympia, WA
    Posts
    337
    You'll have to drop the view, change the table and recreate the view. And casting varchar <-> text is pointless.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •