查询语句中创建表并加载数据(As Select)

这里有一种非常快的建表方式,用As

我们根据查询结果创建表(查询的结果会添加到新创建的表中)
例如:

create table if not exists student3
as select id, name from student;

然后一个名为student3的表就被建立,并且有两个parameters: id 和 name。其数据类型和student表一样,且student表中每一行的数据也被拷贝到student3中。可以用 show tables 和 select * from student3查看数据。

猜你喜欢

转载自blog.csdn.net/CharlesCFA/article/details/113873194