Name

CREATE-VIEW — Create a database view.Function

Syntax

      create-view name &key as column-list with-check-option database => 

Arguments and Values

name

The name of the view as a string, symbol or SQL expression.

database

A database object which defaults to *default-database*.

as

A symbolic SQL query expression.

column-list

A list.

with-check-option

A Boolean.

Description

Creates a view called name in database which defaults to *default-database*. The view is created using the query as and the columns of the view may be specified using the column-list parameter. The with-check-option is NIL by default but if it has a non-NIL value, then all insert/update commands on the view are checked to ensure that the new data satisfy the query as.

Examples

(create-view [lenins-group]
	     :as [select [first-name] [last-name] [email]
	                 :from [employee]
			 :where [= [managerid] 1]])
=> 

(select [*] :from [lenins-group])
=> (("Josef" "Stalin" "stalin@soviet.org") 
    ("Leon" "Trotsky" "trotsky@soviet.org")
    ("Nikita" "Kruschev" "kruschev@soviet.org")
    ("Leonid" "Brezhnev" "brezhnev@soviet.org")
    ("Yuri" "Andropov" "andropov@soviet.org")
    ("Konstantin" "Chernenko" "chernenko@soviet.org")
    ("Mikhail" "Gorbachev" "gorbachev@soviet.org")
    ("Boris" "Yeltsin" "yeltsin@soviet.org")
    ("Vladimir" "Putin" "putin@soviet.org")), 
   ("first_name" "last_name" "email")
      

Side Effects

A view is created in database.

Affected by

*default-database*

Exceptional Situations

An error is signalled if name is not a string, symbol or SQL expression. An error of type sql-database-data-error is signalled if a relation called name already exists.

See Also

drop-view
list-views
view-exists-p

Notes

None.