A view is a virtual table exported from one or more tables. It is a virtual table; it can facilitate users to operate data. How to create a view on an existing database table and view the created view? Information, the specific operations are as follows:
##1 .In order not to affect other database tables, create a new database table t_worker_info with the following code:
create table t_worker_info( id int(8) primary key not null auto_increment, w_id int(10) not null, w_name varchar(20) not null, w_age int(3), w_sex varchar(10), w_birth varchar(20) );
As shown in the figure below:
2. After creating t_worker_info, check the data structure. The code is as follows:
desc t_worker_info;
3. Double-click the selected database, right-click "Create View..." in Views, open the editing window, and enter the code in the window, the code is as follows:
CREATE VIEW `view_worker_info` AS SELECT * FROM t_worker_info;
As shown in the figure below:
4. View the basic information of creating a view, use desc or describe statement , the code is as follows:
desc view_worker_info;
show table status like 'view_worker_info';
## 6. To view the details of the created view, you need to use the show create view view name. The code is as follows:
show create view view_worker_info;
Instructions
Note the difference between views and tables in MySQLLearn how to create viewsThe above is the detailed content of How to create a view from a database table in MySQL?. For more information, please follow other related articles on the PHP Chinese website!