MySQL视图学习整理_MySQL
第一部分:初级概念及应用
一,视图简介
MySQL的视图和Oracle视图是一个概念,就是一张虚拟表,没有任何数据的,数据还是存放在基表里面的;
二,添加视图1:语法
CREATE
[OR REPLACE]
[ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
[DEFINER = { user | CURRENT_USER }]
[SQL SECURITY { DEFINER | INVOKER }]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
2:举例(创建视图 )
mysql> use ehrt;
Database changed
mysql> create algorithm = MERGE view t1 as select * from user;
三,修改视图
1:语法
ALTER
[ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
[DEFINER = { user | CURRENT_USER }]
[SQL SECURITY { DEFINER | INVOKER }]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
2:举例
mysql> alter view t1 as select * from user where name='Jacson';
四,查看视图
1.查看视图数据
mysql> use ehrt;mysql> select * from t1;
+----+------+-----+
| id | name | sex |
+----+------+-----+
| 1 | Jacson | 0 |
| 2 | Bai | 0 |
+----+------+-----+
2 rows in set (0.00 sec)
2.查看视图结构
mysql> show create view t1G;五,删除视图
mysql> drop view t1;
Query OK, 0 rows affected (0.00 sec)
第二部分:高级概念整理
一,视图的类型
mysql的视图有三种类型:MERGE、TEMPTABLE、UNDEFINED。如果不指定ALGORITHM子句,默认算法为UNDEFINED。这个方式决定了影响MySQL处理视图的速度。
1,MERGE,会将引用视图的语句的文本与视图定义合并起来,使得视图定义的某一部分取代语句的对应部分。
2,TEMPTABLE,视图的结果将被置于临时表中,然后使用它执行语句。
3,UNDEFINED,让自己MySQL选择所要使用的算法。
建议一般开发者,在物理主机内存不大或者考虑程序可移植的情况下一般选择MERGE
--未完待续
第三部分:高级应用
1.能否监控视图是否失效?
--未完待续

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In iOS 17 Apple is introducing Standby Mode, a new display experience designed for charging iPhones in a horizontal orientation. In this position, the iPhone is able to display a series of full-screen widgets, turning it into a useful home hub. Standby mode automatically activates on an iPhone running iOS 17 placed horizontally on the charger. You can view time, weather, calendar, music controls, photos, and more. You can swipe left or right through the available standby options and then long press or swipe up/down to customize. For example, you can choose from analog view, digital view, bubble font, and daylight view, where the background color changes based on time as time passes. There are some options

Tables are an essential component in many web applications. Tables usually have large amounts of data, so tables require some specific features to improve user experience. One of the important features is editability. In this article, we will explore how to implement editable tables using Vue.js and provide specific code examples. Step 1: Prepare the data First, we need to prepare the data for the table. We can use a JSON object to store the table's data and store it in the data property of the Vue instance. In this case

Compare SpringBoot and SpringMVC and understand their differences. With the continuous development of Java development, the Spring framework has become the first choice for many developers and enterprises. In the Spring ecosystem, SpringBoot and SpringMVC are two very important components. Although they are both based on the Spring framework, there are some differences in functions and usage. This article will focus on comparing SpringBoot and Spring

PHP is a very popular programming language, and CodeIgniter4 is a commonly used PHP framework. When developing web applications, using frameworks is very helpful. It can speed up the development process, improve code quality, and reduce maintenance costs. This article will introduce how to use the CodeIgniter4 framework. Installing the CodeIgniter4 framework The CodeIgniter4 framework can be downloaded from the official website (https://codeigniter.com/). Down

Laravel is one of the most popular PHP frameworks currently, and its powerful view generation capabilities are impressive. A view is a page or visual element displayed to the user in a web application, which contains code such as HTML, CSS, and JavaScript. LaravelView allows developers to use a structured template language to build web pages and generate corresponding views through controllers and routing. In this article, we will explore how to generate views using LaravelView. 1. What

I guess that many students want to learn the typesetting skills of Word, but the editor secretly tells you that before learning the typesetting skills, you need to understand the word views clearly. In Word2007, 5 views are provided for users to choose. These 5 views include pages. View, reading layout view, web layout view, outline view and normal view, let’s learn about these 5 word views with the editor today. 1. Page view Page view can display the appearance of the print result of the Word2007 document, which mainly includes headers, footers, graphic objects, column settings, page margins and other elements. It is the page view closest to the print result. 2. Reading layout view Reading layout view displays Word2007 documents and Office in the column style of a book

Django is a highly customizable web framework that provides many convenient tools and libraries to help developers quickly create high-performance, scalable web applications. Among them, views are one of the most important components of the Django framework. Views are responsible for processing requests from clients and returning corresponding responses. In this article, we'll take a deep dive into views in the Django framework and explain how to use it to create high-performance, customizable web applications. 1. The basic concept of views in Django

Microsoft recently launched Visual Studio Code 1.80. Although this update was released in July, the official still calls it the June update. After users install this update, the built-in terminal can directly display images, and auxiliary functions have also been optimized. In the previously released preview version of Visual Studio Code, support for images in the terminal has been supported, and it is enabled by default in the new 1.80 version. In order to be able to display the image in the terminal, the image pixel data is converted into text through a special escape sequence and finally written to the terminal. If you want to pipe typical PNG, GIF or JPEG files to the terminal, you need to install the imgcatpython package and then run imgc in the terminal
