在MySQL中显示VIEW的内容?
以下是语法-
select * from yourViewName;
让我们首先创建一个表-
create table DemoTable1388 -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(40) -> );
使用插入命令在表中插入一些记录-
insert into DemoTable1388(StudentName) values('Chris'); insert into DemoTable1388(StudentName) values('Bob'); insert into DemoTable1388(StudentName) values('David'); insert into DemoTable1388(StudentName) values('Mike');
使用select语句显示表中的所有记录-
select * from DemoTable1388;
这将产生以下输出-
+-----------+-------------+ | StudentId | StudentName | +-----------+-------------+ | 1 | Chris | | 2 | Bob | | 3 | David | | 4 | Mike | +-----------+-------------+ 4 rows in set (0.00 sec)
以下是在MySQL中创建视图的查询-
create view view1388 as select *from DemoTable1388 where StudentId=3;
现在,在MySQL中显示视图的内容-
select * from view1388;
这将产生以下输出-
+-----------+-------------+ | StudentId | StudentName | +-----------+-------------+ | 3 | David | +-----------+-------------+ 1 row in set (0.19 sec)