Altering a View
From InterBase
Go Up to Altering Metadata
To change the information provided by a view, follow these steps:
- Drop the current view definition.
- Create a new view definition and give it the same name as the dropped view.
For example, the following view is defined to select employee salary information:
EXEC SQL CREATE VIEW EMPLOYEE_SALARY AS SELECT EMP_NO, LAST_NAME, CURRENCY, SALARY FROM EMPLOYEE, COUNTRY WHERE EMPLOYEE.COUNTRY_CODE = COUNTRY.CODE;
Suppose the full name of each employee should be displayed instead of the last name. First, drop the current view definition:
EXEC SQL DROP EMPLOYEE_SALARY; EXEC SQL COMMIT;
Then create a new view definition that displays each employee’s full name:
EXEC SQL CREATE VIEW EMPLOYEE_SALARY AS SELECT EMP_NO, FULL_NAME, CURRENCY, SALARY FROM EMPLOYEE, COUNTRY WHERE EMPLOYEE.COUNTRY_CODE = COUNTRY.CODE; EXEC SQL COMMIT;