Home > Back-end >  HANA: I created a view from a single table. After creating the view i want to modify the column of a
HANA: I created a view from a single table. After creating the view i want to modify the column of a

Time:01-12

SAP HANA: I created a view from a single table. After creating the view i want to modify the column of a view from VARCHAR[10] to INTEGER[10].

I performed the following SQL queries. But to no avail.

The SQL Queries are as follows:

ALTER VIEW ECLINIC_KNG.VIEW_USER_SETUP MODIFY COLUMN EMPLOYEE_ID INTEGER;

ALTER VIEW ECLINIC_KNG.VIEW_USER_SETUP MODIFY EMPLOYEE_ID INTEGER;

ALTER VIEW ECLINIC_KNG.VIEW_USER_SETUP ALTER COLUMN EMPLOYEE_ID INTEGER;

ALTER VIEW ECLINIC_KNG.VIEW_USER_SETUP ALTER EMPLOYEE_ID INTEGER;

Require help in this. How to alter the column of a view IN SAP HANA

CodePudding user response:

The datatype of columns in SQL views in inherited from the defining select statement. As an example this view will return one column with type NVARCHAR(1):

CREATE OR REPLACE VIEW TEST AS 
SELECT '1' AS COL1 
FROM DUMMY

You need to change the datatype in the underlying select statement to change the output of the view to make COL1 integer:

CREATE OR REPLACE VIEW TEST AS 
SELECT CAST('1' AS INTEGER) AS COL1 
FROM DUMMY

CodePudding user response:

Did you try by dropping the data? If that did not work, then you need drop the table and recreate it.

  • Related