Create Table View using alises in column names

Viewed 26

I am trying to create a view in DB2 with specific column names so that I can compare them with another table with same column names. My question is why this doesn't work, how to make View with column names as alises? So, basically my idea is to have a table with different column names.

 CREATE VIEW testView (
    ADD_ID AS address_id,
    ADD_CODE AS address_code)
            AS SELECT * FROM SOP.CUST_ADDRESS;
1 Answers

You would code your view either like this

CREATE VIEW testView
AS SELECT  
        ADD_ID AS address_id
   ,    ADD_CODE AS address_code
   FROM SOP.CUST_ADDRESS;

or like this

CREATE VIEW testView (address_id, address_code )
   AS SELECT  
         ADD_ID
    ,    ADD_CODE
    FROM SOP.CUST_ADDRESS;
Related