选择显示字体大小

如何创建mysql5的视图

基本语法:
create [or replace] [algorithm = {undefined  merge  temptable}]    view view_name [(column_list)]    as select_statement    [with [cascaded  local] check option]

this statement creates a new view, or replaces an existing one if the or replace clause is given. the select_statement is a select statement that provides the definition of the view. the statement can select from base tables or other views.

this statement requires the create view privilege for the view, and some privilege for each column selected by the select statement. for columns used elsewhere in the select statement you must have the select privilege. if the or replace clause is present, you must also have the delete privilege for the view.

a view belongs to a database. by default, a new view is created in the current database. to create the view explicitly in a given database, specify the name as db_name.view_name when you create it.

mysql> create view test.v as select * from t;

tables and views share the same namespace within a database, so a database cannot contain a table and a view that have the same name.

views must have unique column names with no duplicates, just like base tables. by default, the names of the columns retrieved by the select statement are used for the view column names. to define explicit names for the view columns, the optional column_list clause can be given as a list of comma-separated identifiers. the number of names in column_list must be the same as the number of columns retrieved by the select statement.

columns retrieved by the select statement can be simple references to table columns. they can also be expressions that use functions, constant values, operators, and so forth.

unqualified table or view names in the select statement are interpreted with respect to the default database. a view can refer to tables or views in other databases by qualifying the table or view name with the proper database name.

a view can be created from many kinds of select statements. it can refer to base tables or other views. it can use joins, union, and subqueries. the select need not even refer to any tables. the following example defines a view that selects two columns from another table, as well as an expression calculated from those columns:

mysql> create table t (qty int, price int);mysql> insert into t values(3, 50);mysql> create view v as select qty, price, qty*price as value from t;mysql> select * from v;+------+-------+-------+ qty   price  value +------+-------+-------+    3     50    150 +------+-------+-------+

a view definition is subject to the following restrictions:


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范