Import and Export Concepts
Export Rows
Shape a Text Result
An export query can project table rows into a stable text shape without writing a file.
Program
Play the script to choose a minimum order total and format matching rows as CSV-style lines.
format_export_rows.sql
Replay: real traced execution (multi-file project)
CREATE TABLE orders (id INTEGER, total INTEGER, status TEXT);
INSERT INTO orders VALUES (101, 40, 'paid'), (102, 15, 'open'), (103, 75, 'paid');
WITH params(min_total) AS (VALUES (30)) SELECT id || ',' || total || ',' || status AS csv_line FROM orders WHERE total >= (SELECT min_total FROM params) ORDER BY id;
CREATE TABLE orders (id INTEGER, total INTEGER, status TEXT);
INSERT INTO orders VALUES (101, 40, 'paid'), (102, 15, 'open'), (103, 75, 'paid');
WITH params(min_total) AS (VALUES (10)) SELECT id || ',' || total || ',' || status AS csv_line FROM orders WHERE total >= (SELECT min_total FROM params) ORDER BY id;
CREATE TABLE orders (id INTEGER, total INTEGER, status TEXT);
INSERT INTO orders VALUES (101, 40, 'paid'), (102, 15, 'open'), (103, 75, 'paid');
WITH params(min_total) AS (VALUES (60)) SELECT id || ',' || total || ',' || status AS csv_line FROM orders WHERE total >= (SELECT min_total FROM params) ORDER BY id;
tables ← 1 row
1CREATE TABLE orders (id INTEGER, total INTEGER, status TEXT);2INSERT INTO orders VALUES (101, 40, 'paid'), (102, 15, 'open'), (103, 75, 'paid');values this step1 rowtablesorders ← 3 rows
1CREATE TABLE orders (id INTEGER, total INTEGER, status TEXT);2INSERT INTO orders VALUES (101, 40, 'paid'), (102, 15, 'open'), (103, 75, 'paid');3WITH params(min_total) AS (VALUES (30)) SELECT id || ',' || total || ',' || status AS csv_line FROM orders WHERE total >= (SELECT min_total FROM params) ORDER BY id;values this step3 rowsordersresult ← 2 rows
2INSERT INTO orders VALUES (101, 40, 'paid'), (102, 15, 'open'), (103, 75, 'paid');3WITH params(min_total) AS (VALUES (30)) SELECT id || ',' || total || ',' || status AS csv_line FROM orders WHERE total >= (SELECT min_total FROM params) ORDER BY id;values this step2 rowsresult
tables ← 1 row
1CREATE TABLE orders (id INTEGER, total INTEGER, status TEXT);2INSERT INTO orders VALUES (101, 40, 'paid'), (102, 15, 'open'), (103, 75, 'paid');values this step1 rowtablesorders ← 3 rows
1CREATE TABLE orders (id INTEGER, total INTEGER, status TEXT);2INSERT INTO orders VALUES (101, 40, 'paid'), (102, 15, 'open'), (103, 75, 'paid');3WITH params(min_total) AS (VALUES (10)) SELECT id || ',' || total || ',' || status AS csv_line FROM orders WHERE total >= (SELECT min_total FROM params) ORDER BY id;values this step3 rowsordersresult ← 3 rows
2INSERT INTO orders VALUES (101, 40, 'paid'), (102, 15, 'open'), (103, 75, 'paid');3WITH params(min_total) AS (VALUES (10)) SELECT id || ',' || total || ',' || status AS csv_line FROM orders WHERE total >= (SELECT min_total FROM params) ORDER BY id;values this step3 rowsresult
tables ← 1 row
1CREATE TABLE orders (id INTEGER, total INTEGER, status TEXT);2INSERT INTO orders VALUES (101, 40, 'paid'), (102, 15, 'open'), (103, 75, 'paid');values this step1 rowtablesorders ← 3 rows
1CREATE TABLE orders (id INTEGER, total INTEGER, status TEXT);2INSERT INTO orders VALUES (101, 40, 'paid'), (102, 15, 'open'), (103, 75, 'paid');3WITH params(min_total) AS (VALUES (60)) SELECT id || ',' || total || ',' || status AS csv_line FROM orders WHERE total >= (SELECT min_total FROM params) ORDER BY id;values this step3 rowsordersresult ← 1 row
2INSERT INTO orders VALUES (101, 40, 'paid'), (102, 15, 'open'), (103, 75, 'paid');3WITH params(min_total) AS (VALUES (60)) SELECT id || ',' || total || ',' || status AS csv_line FROM orders WHERE total >= (SELECT min_total FROM params) ORDER BY id;values this step1 rowresult
projection
The query returns only the columns needed by the export shape.
concatenation
`||` joins values into a CSV-style text line.
deterministic export
The replay shows export-shaped rows as query output, keeping the example static and repeatable.