with tbl as
(
select
id,name
from
a
)
select id from tbl;
create table tbl
as
select
id,name
from
a;
select id from tbl;
with tbl as
(
select
id,name
from
a
)
select id from tbl;
select name from tbl;
There's no obvious performance gap.
with tbl as
is a common table expression, aka CTE, which is only accessible within a single query. So we CAN NOT use CTE across multiple SQL queries separated by ;
.
Favor create temporary table
table over create table
. The former is visible within a single session, and will be gone when the session ends.