0

I'm trying to create a new view from an existing table which as 2 columns:

CREATE TABLE writers (
  movie_id integer NOT NULL REFERENCES movies,
  person_id integer NOT NULL REFERENCES people,
  PRIMARY KEY (movie_id,person_id)
) ;

I'm trying to make a view which adds a new column and a default character value so I want a the new to have the columns movie_id, person_id, position_name and I need position_name to be of type character so that I can union this view with another view.

Is this possible to do?

0

Yes it is possible:

create view ... as (
    select movie_id, person_id, cast(null as char(1)) as position_name
    from writers
);

I assumed that null (which is part of any type) is what is causing you the problem. Replace null with whatever if that is not the case

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.