Space and Time
Reference Documentation

Proof of SQL Syntax

Proof of SQL requires cryptographic proofs for query results. This reference covers what SQL features are provable—not just what parses successfully.

Quick Reference

At-a-glance view of what's provable in Proof of SQL

FeatureStatus
SELECT & FROM
SELECT columnsSupported
SELECT *Supported
LIMIT / OFFSETSupported
WHERE Clause
=, !=, <, >, <=, >=Supported
AND, OR, NOTSupported
BETWEENNot Supported
IN (...)Not Supported
LIKE / ILIKENot Supported
IS NULLNot Supported
Aggregation
GROUP BYSupported
SUM()Supported
COUNT(*)Supported
AVG(), MIN(), MAX()Not Supported
HAVINGNot Supported
Joins & Unions
INNER JOINSupported
LEFT / RIGHT / FULL JOINNot Supported
UNION ALLSupported
UNION (distinct)Not Supported
Advanced
Query parameters ($1, $2)Supported
ORDER BYNot Supported
SubqueriesNot Supported
CTEs (WITH clause)Not Supported
Window functionsNot Supported

Detailed Reference

The SELECT clause supports column selection, aliases, wildcards, and arithmetic expressions.

Supported

  • • Column selection: SELECT col1, col2
  • • Wildcard: SELECT *
  • • Aliases: SELECT col AS alias
  • • Arithmetic: col1 + col2, col1 * col2
  • • Type casting: CAST(col AS BIGINT)

Not Supported

  • • Division (/)
  • • String functions (CONCAT, UPPER)
  • • CASE expressions
  • • COALESCE / NULLIF
sql
-- ✅ Basic column selection
SELECT NAME, AREA, LONGITUDE FROM NAMESPACE.LOCATIONS
-- ✅ Arithmetic expressions
SELECT PRICE, QUANTITY, PRICE * QUANTITY AS TOTAL FROM NAMESPACE.ORDERS
-- ✅ Column aliases
SELECT ID AS USER_ID, NAME AS USER_NAME FROM NAMESPACE.USERS

Test Your Query

Always verify your query via the RPC endpoint before deploying. If you receive an error, the query is not provable.

bash
curl -X POST https://rpc.mainnet.sxt.network \
-H "Content-Type: application/json" -d '{
"jsonrpc": "2.0",
"id": 1,
"method": "commitments_v1_evmProofPlan",
"params": { "query": "SELECT NAME FROM NAMESPACE.TABLE WHERE ID = 1" }
}'

Response Interpretation

Success

Response contains "proofPlan": "0x..."

Failure

Response contains "error" with details

Complete Examples

Copy-paste ready queries demonstrating provable patterns

Provable Query Examples

sql
-- Simple SELECT with WHERE
SELECT NAME, AREA FROM NAMESPACE.LOCATIONS
WHERE LONGITUDE = 60
-- Multiple conditions (replacing BETWEEN)
SELECT ID, PRICE FROM NAMESPACE.PRODUCTS
WHERE PRICE >= 10 AND PRICE <= 100 AND STATUS = 'active'
-- Multiple conditions (replacing IN)
SELECT * FROM NAMESPACE.ORDERS
WHERE STATUS = 'pending' OR STATUS = 'processing' OR STATUS = 'shipped'
-- Aggregation (correct order: SUMs then COUNT)
SELECT CATEGORY, SUM(REVENUE), SUM(QUANTITY), COUNT(*)
FROM NAMESPACE.SALES
GROUP BY CATEGORY
-- Simple INNER JOIN
SELECT u.NAME, o.TOTAL
FROM NAMESPACE.USERS u
INNER JOIN NAMESPACE.ORDERS o ON u.ID = o.ID
WHERE o.TOTAL > 100
-- UNION ALL
SELECT ID, NAME, 'SOURCE_A' AS SOURCE FROM NAMESPACE.TABLE_A
UNION ALL
SELECT ID, NAME, 'SOURCE_B' AS SOURCE FROM NAMESPACE.TABLE_B
-- Arithmetic expressions
SELECT
ID,
PRICE,
QUANTITY,
PRICE * QUANTITY AS LINE_TOTAL
FROM NAMESPACE.ORDER_ITEMS
WHERE QUANTITY > 0