Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

alter_view(7) [suse man page]

ALTER 
VIEW(7) SQL Commands ALTER VIEW(7) NAME
ALTER VIEW - change the definition of a view SYNOPSIS
ALTER VIEW name ALTER [ COLUMN ] column SET DEFAULT expression ALTER VIEW name ALTER [ COLUMN ] column DROP DEFAULT ALTER VIEW name OWNER TO new_owner ALTER VIEW name RENAME TO new_name ALTER VIEW name SET SCHEMA new_schema DESCRIPTION
ALTER VIEW changes various auxiliary properties of a view. (If you want to modify the view's defining query, use CREATE OR REPLACE VIEW.) You must own the view to use ALTER VIEW. To change a view's schema, you must also have CREATE privilege on the new schema. To alter the owner, you must also be a direct or indirect member of the new owning role, and that role must have CREATE privilege on the view's schema. (These restrictions enforce that altering the owner doesn't do anything you couldn't do by dropping and recreating the view. However, a superuser can alter ownership of any view anyway.) PARAMETERS
name The name (optionally schema-qualified) of an existing view. SET/DROP DEFAULT These forms set or remove the default value for a column. A default value associated with a view column is inserted into INSERT statements on the view before the view's ON INSERT rule is applied, if the INSERT does not specify a value for the column. new_owner The user name of the new owner of the view. new_name The new name for the view. new_schema The new schema for the view. NOTES
For historical reasons, ALTER TABLE can be used with views too; but the only variants of ALTER TABLE that are allowed with views are equiv- alent to the ones shown above. EXAMPLES
To rename the view foo to bar: ALTER VIEW foo RENAME TO bar; COMPATIBILITY
ALTER VIEW is a PostgreSQL extension of the SQL standard. SEE ALSO
CREATE VIEW [create_view(7)], DROP VIEW [drop_view(7)] SQL - Language Statements 2010-05-14 ALTER VIEW(7)

Check Out this Related Man Page

CREATE 
VIEW(7) SQL Commands CREATE VIEW(7) NAME
CREATE VIEW - define a new view SYNOPSIS
CREATE [ OR REPLACE ] VIEW view [ ( column name list ) ] AS SELECT query INPUTS view The name (optionally schema-qualified) of a view to be created. column name list An optional list of names to be used for columns of the view. If given, these names override the column names that would be deduced from the SQL query. query An SQL query (that is, a SELECT statement) which will provide the columns and rows of the view. Refer to SELECT [select(7)] for more information about valid arguments. OUTPUTS CREATE VIEW The message returned if the view is successfully created. ERROR: Relation 'view' already exists This error occurs if the view specified already exists in the database. WARNING: Attribute 'column' has an unknown type The view will be created having a column with an unknown type if you do not specify it. For example, the following command gives a warning: CREATE VIEW vista AS SELECT 'Hello World' whereas this command does not: CREATE VIEW vista AS SELECT text 'Hello World' DESCRIPTION
CREATE VIEW defines a view of a query. The view is not physically materialized. Instead, a query rewrite rule (an ON SELECT rule) is auto- matically generated to support SELECT operations on views. CREATE OR REPLACE VIEW is similar, but if a view of the same name already exists, it is replaced. You can only replace a view with a new query that generates the identical set of columns (i.e., same column names and data types). If a schema name is given (for example, CREATE VIEW myschema.myview ...) then the view is created in the specified schema. Otherwise it is created in the current schema (the one at the front of the search path; see CURRENT_SCHEMA()). The view name must be distinct from the name of any other view, table, sequence, or index in the same schema. NOTES Currently, views are read only: the system will not allow an insert, update, or delete on a view. You can get the effect of an updatable view by creating rules that rewrite inserts, etc. on the view into appropriate actions on other tables. For more information see CREATE RULE [create_rule(7)]. Use the DROP VIEW statement to drop views. USAGE
Create a view consisting of all Comedy films: CREATE VIEW kinds AS SELECT * FROM films WHERE kind = 'Comedy'; SELECT * FROM kinds; code | title | did | date_prod | kind | len -------+---------------------------+-----+------------+--------+------- UA502 | Bananas | 105 | 1971-07-13 | Comedy | 01:22 C_701 | There's a Girl in my Soup | 107 | 1970-06-11 | Comedy | 01:36 (2 rows) COMPATIBILITY
SQL92 SQL92 specifies some additional capabilities for the CREATE VIEW statement: CREATE VIEW view [ column [, ...] ] AS SELECT expression [ AS colname ] [, ...] FROM table [ WHERE condition ] [ WITH [ CASCADE | LOCAL ] CHECK OPTION ] The optional clauses for the full SQL92 command are: CHECK OPTION This option is to do with updatable views. All INSERT and UPDATE commands on the view will be checked to ensure data satisfy the view-defining condition. If they do not, the update will be rejected. LOCAL Check for integrity on this view. CASCADE Check for integrity on this view and on any dependent view. CASCADE is assumed if neither CASCADE nor LOCAL is specified. CREATE OR REPLACE VIEW is a PostgreSQL language extension. SQL - Language Statements 2002-11-22 CREATE VIEW(7)
Man Page