当前位置:网站首页>MySQL view
MySQL view
2022-06-22 07:55:00 【yolo2016】
Mysql View of
What is a view
- A view is a virtual table , Its content is defined by query .
- Like a real watch , The view contains a series of named column and row data .
- The row and column data comes from the tables referenced by the query that defines the view , And dynamically generate... When referencing views .
- Simply put, the view is made up of select Table of results .
Features of the view
- A view is a reference to several tables , A virtual table , Query the result of statement execution .
- No specific data is stored ( The basic table data has changed , The view changes as well );
- It can be the same as the basic table , Add, delete, modify and check ( There are conditional restrictions on adding, deleting, and modifying queries )
The function of view
- Security : Create a view , Define the data operated by the view . Then bind the user permissions to the view . In this way, a feature is used ,grant Statement can grant permission to a view .
- Improved query performance
- Improved data independence .
View operation
// Create view
CREATE VIEW v1 AS (SELECT * from employees WHERE salary >10000)
select * from v1
// Delete view
drop view v2
// Modify the view
CREATE or REPLACE VIEW v1 AS (SELECT * from employees WHERE salary >10000)
// View view structure
select * from v1
desc v1
show CREATE view v1
// View Syntax CREATE [ALGORITHM]={UNDEFINED| MERGE| TEMPTABLE }] VIEW View name [( Attribute list )]
// AS SELECT sentence [WITH [CASCADED|LOCAL] CHECK OPTION];
// MERGE Treatment mode replacement , You can update the data in the real table
// TEMPTABLE Specific formula , Because the data is stored in temporary tables , Therefore, data updating is not allowed
// UNDEFINED No definition ALGORITHM Parameters ,mysql Prefer to choose the replacement method , Because it's more efficient
// WITH CHECK OPTION When updating data, you cannot insert or update records that do not meet the restrictions you are trying to limit
// CASCADED|LOCAL Is an optional parameter , Determines the scope of inspection and testing , The default is CASCADED
CREATE ALGORITHM=UNDEFINED
DEFINER=`root`@`%`
SQL SECURITY DEFINER VIEW `v1`
AS
(select `employees`.`employee_id` AS `employee_id`,
`employees`.`first_name` AS `first_name`,
`employees`.`last_name` AS `last_name`,`employees`.`email` AS `email`,
`employees`.`phone_number` AS `phone_number`,`employees`.`job_id` AS `job_id`,
`employees`.`salary` AS `salary`,
`employees`.`commission_pct` AS `commission_pct`,
`employees`.`manager_id` AS `manager_id`,
`employees`.`department_id` AS `department_id`,
`employees`.`hiredate` AS `hiredate`
from `employees`
where (`employees`.`salary` > 10000))
Try a non updatable part

As long as the data in the view is not from the base table , It cannot be directly modified .
边栏推荐
- Runloop detail summary
- Open version - account information synchronization and unification
- What is distributed transaction
- 4 solutions de court - circuit et 2 solutions d'arbre de génération minimum
- Toyota bz4x canceled the launch conference. Even if the low-temperature charging problem does not exist, how about the product strength?
- Impact of dead chain on websites
- enable_ irq_ Wake interrupt wakes up the kernel in low power mode
- Usage and understanding of async/await in JS
- KVO summary
- The applet uses the step bar vant steps in vant
猜你喜欢

Excellent cases of data visualization
![[普通物理]波的能量与干涉](/img/fe/066aa9e8ed776b8f069b59b7123367.png)
[普通物理]波的能量与干涉

Detailed explanation of subnet mask

What is distributed transaction

LR 2022 ultra detailed installation tutorial "latest"

phpcms手机门户网站配置

代码覆盖率测试对编程小白的意义及其使用方法

Orientdb batch execute SQL

Toyota bz4x canceled the launch conference. Even if the low-temperature charging problem does not exist, how about the product strength?

Open version - inventory description
随机推荐
Open version - inventory description
Itemtools permutation
由浅入深拿下OpenFeign
Baidu Post Bar crawler crawls to the middle of the building
代码覆盖率测试对编程小白的意义及其使用方法
Lookup encapsulation of unity monobehavior component
A glimpse of easy rule
[songhongkang MySQL database] [advanced chapter] [06] logical architecture of MySQL
Impact of dead chain on websites
Idea cannot connect to sqlsms
Orientdb batch execute SQL
《百度搜索引擎网页质量白皮书》指导网站建设及优化
Device tree failed to add SPI device node
AutoCAD 2020.3 Chinese Version (old version)
Blob format problems involved in image uploading
Remote Desktop Manager
(9)顺序队列与栈队列
Usage and understanding of async/await in JS
Wx applet vant UI call interface to realize two-level cascade
模电实验——实验二 JFET共源极放大电路