|
CREATE VIEW命令为预先包装好的SELECT语句分配了一个名字。一旦这个视图创建好,就可以在其他的SELECT语句的FROM字句中代替表名使用。
The CREATE VIEW command assigns a name to a pre-packaged
SELECT statement.
Once the view is created, it can be used in the FROM clause
of another SELECT in place of a table name.
如果在"CREATE" 和 "VIEW"之间加入了"TEMP" 或 "TEMPORARY"关键词,那么这个视图只会对当前打开数据库的进程可见,并且会在数据库关闭时自动删除。
If the "TEMP" or "TEMPORARY" keyword occurs in between "CREATE"
and "VIEW" then the view that is created is only visible to the
process that opened the database and is automatically deleted when
the database is closed.
如果指定了<database-name>,那么视图会创建在指定的数据库上。在一个VIEW上同时指定<database-name>和TEMP关键词会引发一个错误,除非<database-name>是"temp"。如果没有指定数据库名,也没有使用TEMP关键词,那么VIEW会创建在主数据库上。
If a <database-name> is specified, then the view is created in
the named database. It is an error to specify both a <database-name>
and the TEMP keyword on a VIEW, unless the <database-name> is "temp".
If no database name is specified, and the TEMP keyword is not present,
the VIEW is created in the main database.
你不能在一个视图上DELETE、 INSERT 或 UPDATE。在SQLite中视图是只读的。不过,多数情况下你可以通过在视图上使用INSTEAD OF 触发器 来达到相同的目的。视图使用DROP VIEW命令移除。
You cannot DELETE, INSERT, or UPDATE a view. Views are read-only
in SQLite. However, in many cases you can use an
INSTEAD OF trigger on the view to accomplish
the same thing. Views are removed
with the DROP VIEW command.