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

GDB debugging MySQL actual combat source code compilation and installation

Download source code git clone https://github.com...

Database backup in docker environment (postgresql, mysql) example code

Table of contents posgresql backup/restore mysql ...

Nginx solves cross-domain issues and embeds third-party pages

Table of contents Preface difficulty Cross-domain...

The best solution for implementing digital plus and minus buttons with pure CSS

Preface: For the implementation of digital additi...

How to import txt into mysql in Linux

Preface When I was writing a small project yester...

vue+springboot realizes login verification code

This article example shares the specific code of ...

MySQL database advanced query and multi-table query

MySQL multi-table query Add a worksheet -- User t...

Implementation steps for building multi-page programs using Webpack

It is very common to use webpack to build single-...

How to change the host name in Linux

1. View the current host name [root@fangjian ~]# ...

Connector configuration in Tomcat

JBoss uses Tomcat as the Web container, so the co...

Vue implements dynamic query rule generation component

1. Dynamic query rules The dynamic query rules ar...

Several commonly used single-page application website sharing

CSS3Please Take a look at this website yourself, ...

Tomcat obtains the client domain name of Nginx reverse proxy

question After Nginx reverse proxy, the Tomcat ap...