当前位置:网站首页>MySQL view concept, create view, view, modify view, delete view
MySQL view concept, create view, view, modify view, delete view
2022-07-02 01:46:00 【No development, no work】
List of articles
1 Concept of view
- View is a virtual table , There is no data in itself , Takes up very little memory space , It is SQL An important concept in .
- Views are built on existing tables , The tables on which the view is built are called Base watch .

- The creation and deletion of views only affect the view itself , It does not affect the corresponding base table . But when the data in the view is added 、 When deleting and modifying operations , The data in the data table will change accordingly , vice versa .
- The statement that provides data content to the view is SELECT sentence , A view can be understood as Stored up SELECT sentence .
- In the database , The view does not save data , The data is really saved in the data table . When adding data to the view 、 When deleting and modifying operations , The data in the data table will change accordingly ; vice versa .
- View , Is another form of providing users with base table data . Usually , Databases for small projects may not use views , But on big projects , And when the data table is complex , The value of view is highlighted , It can help us put the result set of frequent queries into the virtual table , Improve efficiency . It is very convenient to understand and use .
2 Create view
2.1 grammar
- stay CREATE VIEW Insert subquery in statement
CREATE [OR REPLACE]
[ALGORITHM = {
UNDEFINED | MERGE | TEMPTABLE}]
VIEW View name [{ Field list }]
AS Query statement
[WITH [CASCADED|LOCAL] CHECK OPTION]
- Lite version
CREATE VIEW View name [( Field list )]
AS Query statement
2.2 Name the field
-- Mode one
CREATE VIEW emp_view AS SELECT
employee_id emp_id,-- The column name of the view is consistent with the alias
last_name lname,
salary
FROM
employees;
-- Mode two
-- The name should correspond to the query field one by one
CREATE VIEW emp_view2 ( emp_id, lname, money ) AS SELECT
employee_id,
last_name,
salary
FROM
employees;
3 View view
-- View tables and views
SHOW TABLES;
-- View view structure
DESC emp_view2;
-- View the attribute information of the view
SHOW TABLE STATUS LIKE 'emp_view2';
-- View the detailed definition information of the view
SHOW CREATE VIEW emp_view2;
4 Modify the view
-- Create a view to modify
CREATE VIEW emp_view AS SELECT
employee_id emp_id,
last_name lname,
salary
FROM
employees;
-- Modification method 1
CREATE OR REPLACE VIEW emp_view AS SELECT
employee_id,
last_name,
salary,
email
FROM
employees
WHERE
salary > 7000;
-- Modification method 2
ALTER VIEW emp_view AS SELECT
employee_id emp_id,
last_name lname,
salary
FROM
employees;
5 Delete view
-- Delete view
DROP VIEW IF EXISTS emp_view;
DROP VIEW IF EXISTS emp_view,emp_view2;
边栏推荐
- Learn about servlets
- Edge computing accelerates live video scenes: clearer, smoother, and more real-time
- [IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production
- Study note 2 -- definition and value of high-precision map
- 遷移雲計算工作負載的四個基本策略
- np. Where and torch Where usage
- [image enhancement] vascular image enhancement based on frangi filter with matlab code
- Fastadmin controls the length of fields in the table
- Niuke - Huawei question bank (51~60)
- This is the form of the K-line diagram (pithy formula)
猜你喜欢
![[IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production](/img/dc/e9adb1b41c2175c6f18d8027e0530a.jpg)
[IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production
![[Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility](/img/8b/e51867cfe9d200ac385e1d1f01e4b3.jpg)
[Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility
![[Floyd] post disaster reconstruction](/img/7a/f72c7781ef148212c870a56fb9a607.jpg)
[Floyd] post disaster reconstruction

Réseau neuronal convolutif (y compris le Code et l'illustration correspondante)

TSINGSEE青犀平台如何实现同一节点同时播放多个视频?

开发工具创新升级,鲲鹏推进计算产业“竹林”式生长

现货黄金分析的技巧有什么呢?

开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?

6-3 vulnerability exploitation SSH environment construction

JMeter (II) - install the custom thread groups plug-in
随机推荐
Based on configured schedule, the given trigger will never fire
Niuke - Huawei question bank (51~60)
10 minutes to get started quickly composition API (setup syntax sugar writing method)
Implementation principle of city selector component
What are the skills of spot gold analysis?
[IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production
With the innovation and upgrading of development tools, Kunpeng promotes the "bamboo forest" growth of the computing industry
Have you stepped on the nine common pits in the e-commerce system?
Android high frequency network interview topic must know and be able to compare Android development environment
[IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games
人工智能在网络安全中的作用
Volume compression, decompression
[IVX junior engineer training course 10 papers to get certificates] 09 chat room production
Data visualization in medical and healthcare applications
[image enhancement] vascular image enhancement based on frangi filter with matlab code
[Video] visual interpretation of Markov chain principle and Mrs example of R language region conversion | data sharing
Matlab uses audioread and sound to read and play WAV files
Implementation of Weibo system based on SSM
Penser au jeu 15: penser au service complet et au sous - service
Develop those things: how to use go singleton mode to ensure the security of high concurrency of streaming media?