Problem to be solved for MySQL create view

  1. The select statement cannot contain a subquery in the from clause
    Then what if I need a list of contents from a subquery?
    Create a view or table

I cannot really understand the following three statements

  1. The select statement cannot refer to system variables or user-defined variables
  2. Within a stored program, the select statement cannot refer to program parameters or local variables.
  3. The select statement cannot refer to prepared statement parameters

The confusion ends

  1. You cannot refer to a temporary table or view
  2. You cannot associate a trigger with a view

Definer about view

CURRENT_USER OPTION

View Algorithm

MySQL provides the MERGE, TEMPTABLE and UNDEFINED algorithms to create a view.

MERGEmeans the input query will be combined with the SELECT statement of the view definition.
Pro: more efficient than TEMPTABLE
Con: only allowed when the rows in the view represent a one-to-one relationship with the rows in the underlying table.
TEMPTABLE means MySQL first creates a temporary table based on the SELECT statement of the view definition.
Pro: taken when MERGE cannot be applied.
Con: less efficient; view is not updatable
UNDEFINED default; choose automatically by database engine

When MERGE cannot be used:
if the query contains any of the following constructs:
1. aggregate functions(sum, min, max, count, avg, etc)
2. DISTINCT
3. HAVING
4. LIMIT
5. UNION or UNION ALL
6. Subquery in the select list
7. Refers only to literal values

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值