Home /Modules/sleela-sql/05-sql-equivalents.md

05-sql-equivalents.md

lib/sleela-sql/examples/slsql/05-sql-equivalents.md · 24 line(s) · markdown

SLSQL and classic SQL: side-by-side

SLSQL is an alternative syntax for the supported subset; it does not create a separate execution engine.

IntentSLSQLClassic SQL
Createtable('games').create(id, title, year)CREATE TABLE games (id, title, year)
Insertinto('games').insert(1, 'Metroid', 1986)INSERT INTO games VALUES (1, 'Metroid', 1986)
Select allfrom('games').select(*)SELECT * FROM games
Select columnsfrom('games').select(title, year)SELECT title, year FROM games
Filterfrom('games').select(*).where(year == 1986)SELECT * FROM games WHERE year = 1986
Countfrom('games').select(count(*))SELECT COUNT(*) FROM games
List tablestables()SHOW TABLES
Dropfrom('games').drop()DROP TABLE games
Drop if presentfrom('games').drop(ifExists)DROP TABLE IF EXISTS games

One engine, two front ends

Both dialects lower to the same internal statement representation and executor. The parser can auto-detect SLSQL roots (table(, into(, from(, tables(), or callers can explicitly select the dialect with the API or CLI.

Scope warning

Do not assume all classic SQL operations have fluent SLSQL forms. In the current implementation, ALTER TABLE ADD COLUMN, UPDATE, and DELETE are classic-SQL-only. See ../../SPECIFICATION.md for limits and persistence behavior.