Example using ALTER VIEW
PRICE_WITH_MARKUP
ALTER VIEW PRICE_WITH_MARKUP (
CODE_PRICE,
COST,
COST_WITH_MARKUP
) AS
SELECT
CODE_PRICE,
COST,
COST * 1.15
FROM PRICE;
ALTER VIEW
PRICE_WITH_MARKUP
ALTER VIEW PRICE_WITH_MARKUP (
CODE_PRICE,
COST,
COST_WITH_MARKUP
) AS
SELECT
CODE_PRICE,
COST,
COST * 1.15
FROM PRICE;
CREATE OR ALTER VIEW
Creates a view if it doesn’t exist, or alters a view
DSQL
CREATE OR ALTER VIEW viewname [<full_column_list>] AS <select_statement> [WITH CHECK OPTION] <full_column_list> ::= (colname [, colname ...])
Parameter | Description |
---|---|
viewname |
Name of a view which may or may not exist |
select_statement |
SELECT statement |
full_column_list |
The list of columns in the view |
colname |
View column name.Duplicate column names are not allowed. |
Use the CREATE OR ALTER VIEW
statement for changing the definition of an existing view or creating it if it does not exist.Privileges for an existing view remain intact and dependencies are not affected.
The syntax of the CREATE OR ALTER VIEW
statement corresponds with that of CREATE VIEW
.
CREATE OR ALTER VIEW
PRICE_WITH_MARKUP
view or altering it if it already existsCREATE OR ALTER VIEW PRICE_WITH_MARKUP (
CODE_PRICE,
COST,
COST_WITH_MARKUP
) AS
SELECT
CODE_PRICE,
COST,
COST * 1.15
FROM PRICE;
DROP VIEW
Drops a view
DSQL
DROP VIEW viewname
Parameter | Description |
---|---|
viewname |
View name |
The DROP VIEW
statement drops (deletes) an existing view.The statement will fail if the view has dependencies.
The DROP VIEW
statement can be executed by:
The owner of the view
Users with the DROP ANY VIEW
privilege
PRICE_WITH_MARKUP
viewDROP VIEW PRICE_WITH_MARKUP;
RECREATE VIEW
Drops a view if it exists, and creates a view
DSQL
RECREATE VIEW viewname [<full_column_list>] AS <select_statement> [WITH CHECK OPTION] <full_column_list> ::= (colname [, colname ...])
Parameter | Description |
---|---|
viewname |
View name.The maximum length is 63 characters |
select_statement |
SELECT statement |
full_column_list |
The list of columns in the view |
colname |
View column name.Duplicate column names are not allowed. |
Creates or recreates a view.If there is a view with this name already, the engine will try to drop it before creating the new instance.If the existing view cannot be dropped, because of dependencies or insufficient rights, for example, RECREATE VIEW
fails with an error.
RECREATE VIEW
PRICE_WITH_MARKUP
view or recreating it, if it already existsRECREATE VIEW PRICE_WITH_MARKUP (
CODE_PRICE,
COST,
COST_WITH_MARKUP
) AS
SELECT
CODE_PRICE,
COST,
COST * 1.15
FROM PRICE;