The sql Namespace
Everything @sqb/builder exports is also available bundled under a single sql namespace
import, which is convenient when you'd rather not name every symbol individually or want to
avoid naming collisions with your own code:
import { sql } from '@sqb/builder';
const query = sql.Select('id', 'given_name')
.from('customers')
.where(sql.Eq('active', true));
import { Select, Eq } from '@sqb/builder' and sql.Select / sql.Eq above refer to the exact
same classes — sql is just an alternate, namespaced way to reach them. The tables below list
every symbol it carries, grouped the way the source itself groups them, each with a one-line
description and a link to its full API reference page.
Statements
| Symbol | Description |
|---|---|
sql.Select | Builds a SELECT query — columns, FROM, JOIN, WHERE, GROUP BY, ORDER BY, LIMIT/OFFSET. |
sql.Insert | Builds an INSERT statement from a plain object or another Select. |
sql.Update | Builds an UPDATE statement with a SET clause and conditions. |
sql.Delete | Builds a DELETE statement with conditions. |
sql.Union | Combines two Select queries with UNION/UNION ALL. |
sql.ReturningQuery | Base class for statements that support a RETURNING clause (Insert, Update, Delete). |
sql.Query | The base class every statement extends — .generate(), .values(), .comment(), and the 'serialize' event hook live here. |
See Select Statement, Insert Statement, Update Statement, and Delete Statement for full guides.
Elements
Building blocks used inside statements — columns, table references, joins, and SQL functions.
| Symbol | Description |
|---|---|
sql.Field | References a column, optionally qualified with a table and aliased with .as(). |
sql.BaseField | Abstract base every column-like element (Field, Count, Case, …) extends. |
sql.TableName | References a table, optionally schema-qualified and aliased. |
sql.Raw | Embeds a literal, unescaped SQL fragment. |
sql.Param | A named bind parameter (:name), with an optional data type and array flag. |
sql.Case | A CASE WHEN ... THEN ... ELSE ... END expression. |
sql.Coalesce | A COALESCE(...) expression. |
sql.Count | A COUNT(...) aggregate expression. |
sql.Max | A MAX(...) aggregate expression. |
sql.Min | A MIN(...) aggregate expression. |
sql.Upper | An UPPER(...) expression. |
sql.Lower | A LOWER(...) expression. |
sql.Sequence | References a database sequence's next/current value. |
sql.StringAgg | A STRING_AGG/GROUP_CONCAT-style aggregate expression. |
sql.GroupColumn | A column reference used inside GROUP BY. |
sql.OrderColumn | A column reference used inside ORDER BY, with direction/nulls placement. |
sql.ReturningColumn | A column reference used inside a RETURNING clause. |
sql.Join | Base JOIN element — configurable join type and condition. |
sql.InnerJoin | An INNER JOIN. |
sql.LeftJoin | A LEFT JOIN. |
sql.LeftOuterJoin | A LEFT OUTER JOIN. |
sql.RightJoin | A RIGHT JOIN. |
sql.RightOuterJoin | A RIGHT OUTER JOIN. |
sql.OuterJoin | A generic OUTER JOIN. |
sql.FullOuterJoin | A FULL OUTER JOIN. |
sql.CrossJoin | A CROSS JOIN. |
See Columns and Table References for Field/TableName/
GroupColumn/OrderColumn/ReturningColumn, Functions and Expressions
for Case/Coalesce/Count/Max/Min/Upper/Lower/StringAgg/Sequence, and
Joins for the join elements.
Operators
Used inside .where() and anywhere else a condition is expected.
| Symbol | Description |
|---|---|
sql.Operator | Abstract base every operator extends. |
sql.LogicalOperator | Abstract base for And/Or, combining a list of conditions. |
sql.CompOperator | Abstract base for comparison operators (Eq, Gt, Like, …). |
sql.And | Combines conditions with AND. .where() does this implicitly for multiple arguments. |
sql.Or | Combines conditions with OR. |
sql.Not | Negates a condition with NOT. |
sql.Eq | = equality. |
sql.Ne | != inequality. |
sql.Gt | > greater-than. |
sql.Gte | >= greater-or-equal. |
sql.Lt | < less-than. |
sql.Lte | <= less-or-equal. |
sql.Between | BETWEEN x AND y. |
sql.NotBetween | NOT BETWEEN x AND y. |
sql.In | IN (...). |
sql.NotIn | NOT IN (...). |
sql.Like | LIKE. |
sql.NotLike | NOT LIKE. |
sql.ILike | Case-insensitive LIKE (dialect-dependent). |
sql.NotILike | Case-insensitive NOT LIKE (dialect-dependent). |
sql.Is | IS (typically IS NULL/IS TRUE/IS FALSE). |
sql.IsNot | IS NOT. |
sql.Exists | EXISTS (subquery). |
sql.NotExists | NOT EXISTS (subquery). |
sql.Match | Full-text match condition (dialect-dependent). |
See Operators and Conditions for a full guide with examples and
each operator's string-shorthand key (e.g. '=', '!=', '!between').
Everything else
enums.ts, types.ts, and the string-keyed Operators map are exported directly from
@sqb/builder (not re-exported under sql) — see Enums and
Interfaces in the API reference.