作业帮 > 英语 > 作业

下面SQL 中的;with 为什么一定要加上':with'呢,起什么作用呢.

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:英语作业 时间:2024/06/06 11:21:22
下面SQL 中的;with 为什么一定要加上':with'呢,起什么作用呢.
;with
digits (i) as(--set up a set of numbers from 0-9
select i
from (VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) as digits (i))
--builds a table from 0 to 99999
,sequence (i) as (
SELECT D1.i + (10*D2.i) + (100*D3.i) + (1000*D4.i) + (10000*D5.i)
FROM digits AS D1 CROSS JOIN digits AS D2 CROSS JOIN digits AS D3
CROSS JOIN digits AS D4 CROSS JOIN digits AS D5)
select i,nchar(i) as character
from sequence
where i between 48 and 122 --vary to include any characters
--in the character set of choice
order by nchar(i) collate Latin1_General_bin --change to the collation you
--are trying
GO
下面SQL 中的;with 为什么一定要加上':with'呢,起什么作用呢.
SQL 语句里面的 with
是使用在 CTE 上面的
CTE(Common Table Expression) ,即公用表表达式,可以认为是在单个 SELECT、INSERT、UPDATE、DELETE 或 CREATE ⅥEW 语句的执行范围内定义的临时结果集.CTE 与派生表类似,具体表现在不存储为对象,并且只在查询期间有效.与派生表的不同之处在于,CTE 可自引用,还可在同一查询中引用多次.