With
implies recursive
With
query names are visible in accessed viewsWith
names even mask qualified table names (schema.table
)WITH name AS (SELECT…)
with
don’t hide schema objectsThe with
clause defines “statement-scoped views”:
WITH query_name (column_name, …) AS (
SELECT …
FROM …
) [, …]
SELECT …
FROM query_name
Tutorial: With
— Organize Complex Queries
Other forms: with recursive
, with
in subquery, with recursive
in subquery.
Product specific forms: with
before insert
, DML in with
.
The with
clause is defined in ISO/IEC 9075:2016-2 as optional feature T121, “WITH
(excluding RECURSIVE
) in query expression”.
You can’t catch up on 20 years of SQL evolution in one day. Subscribe the newsletter via E-Mail, Twitter or RSS to gradually catch up and to keep modern-sql.com on your radar.
The essence of SQL tuning in 200 pages
Buy now!
(paperback and/or PDF)
Paperback also available at Amazon.com.
Markus offers SQL training and consulting for developers working at companies of all sizes.
Learn more »