mysql创建视图
mysql视图是从一个或多个表中导出来的表:
创建视图的语句:
一。首先查询
select select_priv,create_view_priv from mysql.user where user ='root';
二。创建视图
create view depart_view as select * from depart;
查询试图结构:desc depart_view;
第二钟创建视图:
create view depart_view2(id,name) as select id,name from
depart;
以上是单表上创建视图;
多表的视图创建:
create algorithm=merge view student_view1(id,name,sex) as select worker.id,name,sex from worker,student where worker.id = student.w_id with local check option;
查看视图的方法:
1。describe student_view1;
2.show create view student_view1;
3.show table status like '视图名' ;
所有视图定义都存在information_schema数据库下的views表中。查询views表,可以查看到数据库中所有视图的详细信息。查询的语句如下:
select * from information_schema.views;
赞 (0)