Detailed explanation of views in MySQL

Detailed explanation of views in MySQL

view:

Views in MySQL have many similarities with tables. Views are also composed of several fields and several records. Views can also be used as data sources for select statements.

What is saved in the view is just a select statement, which saves the view definition but not the actual data. The source data in the view all comes from the database table. The database table is called the basic table or base table, and the view is called the virtual table.

1. Create a view

The syntax for creating a view is as follows.

create view view name [(view field list)]
as select statement

example:

create view t (id,name,age,sex) as
select id,name,age,sex from teacher;

View the view structure (view the view information, similar to viewing the table information)

desc t;

2. Delete the view

If a view is no longer used, you can use the drop view statement to delete the view. The syntax format is as follows.

drop view view name

3. The role of view

· Make operations simple · Avoid data redundancy · Enhance data security · Improve the logical independence of data

The above is the introduction of views in Mysql by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Detailed explanation of the use of views in MySQL notes
  • Sharing tips on using views in MySQL and multi-table INNER JOIN
  • Detailed explanation of the usage and differences between indexes and views in MySQL
  • Example code for implementing Oracle materialized view using mysql trigger
  • Application analysis based on mysql transactions, views, stored procedures, and triggers
  • Summary of MySQL view principles and usage examples
  • Mysql matters, views, functions, trigger commands (detailed explanation)
  • MySQL view principles and basic operation examples
  • MySQL view introduction and basic operation tutorial
  • Analysis of mysql view functions and usage examples

<<:  Ajax jquery realizes the refresh effect of a div on the page

>>:  Several common ways to deploy Tomcat projects [tested]

Recommend

Search engine free collection of website entrances

1: Baidu website login entrance Website: http://ww...

Sample code for installing ElasticSearch and Kibana under Docker

1. Introduction Elasticsearch is very popular now...

Collapsed table row element bug

Let's take an example: The code is very simple...

Detailed explanation of the specific use of the ENV instruction in Dockerfile

1. The ENV instruction in the Dockerfile is used ...

Kill a bunch of MySQL databases with just a shell script like this (recommended)

I was woken up by a phone call early in the morni...

An article to give you a deep understanding of Mysql triggers

Table of contents 1. When inserting or modifying ...

Node and Python two-way communication implementation code

Table of contents Process Communication Bidirecti...

Full process record of Nginx reverse proxy configuration

1. Preparation Install Tomcat on Linux system, us...

XHTML introductory tutorial: Application of table tags

<br />Table is an awkward tag in XHTML, so y...

Summary of common problems and application skills in MySQL

Preface In the daily development or maintenance o...

Web page creation question: Image file path

This article is original by 123WORDPRESS.COM Ligh...

Detailed explanation of screen command usage in Linux

GUN Screen: Official website: http://www.gnu.org/...

Implementation of CSS loading effect Pac-Man

emmm the name is just a random guess 2333 Preface...

A comprehensive analysis of what Nginx can do

Preface This article only focuses on what Nginx c...