ReadonlynameThe name of the dialect
ReadonlylibraryThe database library or driver being used
Connect to the database
Disconnect from the database
Get the current connection
Check if connected
Stream query results by paging through sql via repeated
dialect-appropriate LIMIT/OFFSET queries (see
createPaginatedQueryStream() in src/dialects/query-stream-helper.ts)
instead of loading the whole result set into memory at once.
The SELECT statement to stream
Optionaloptions: StreamOptions
Streaming options (batch size, backpressure watermark, model mapping)
Execute a raw query
The SQL query string
Optional_options: QueryOptionsEscape a value for use in a query
The value to escape
Escape an identifier (table name, column name, etc.)
The identifier to escape
Quote an identifier (column name, table name)
The identifier to quote
Quote a table name
The table name to quote
Optionalschema: string
Optional schema to prefix the table with
Get database version
Create a new table
Name of the table
Column definitions
Optionaloptions: MSSQLTableOptions
Additional options
Disable system-versioning on a temporal table. Required before the
table (or its schema) can be dropped or structurally altered in ways
incompatible with an active PERIOD FOR SYSTEM_TIME.
Optionalschema: stringDrop a system-versioned temporal table: disables SYSTEM_VERSIONING on
the current table, then drops the table itself. Pass
dropHistoryTable/historyTableName to also drop the associated
history table.
Optionaloptions: DropTableOptions & {Drop a table
Name of the table
Optionaloptions: DropTableOptions
Additional options
Create a partitioned table (PostgreSQL 10+)
Optional_options: TableOptions & {Create a partition for an existing partitioned table (PostgreSQL 10+)
Attach a partition to a partitioned table (PostgreSQL 11+)
Detach a partition from a partitioned table (PostgreSQL 11+)
Add a partition to an existing partitioned table (MSSQL)
Create a database view
Name of the view to create
The SELECT query for the view
Optionaloptions: ViewOptions
View options (e.g., replace if exists)
Drop a database view
Name of the view to drop
Optionaloptions: DropViewOptions
Drop options
Optional_options: RefreshOptionsOptionaloptions: DropMaterializedViewOptionsOptionaloptions: DropStoredProcedureOptionsDrop a stored procedure (alias for dropStoredProcedure)
Optionaloptions: DropStoredProcedureOptionsCreate a stored procedure (alias for createStoredProcedure)
Optionalschema: stringOptionaloptions: DropTriggerOptionsOptionaloptions: DropSequenceOptionsList all sequences in the database (MSSQL)
Array of sequence names
Create a security policy with predicate function (MSSQL RLS)
Drop a security policy (MSSQL RLS)
Optionaloptions: DropPolicyOptionsEnable row-level security on a table (MSSQL) Note: In SQL Server, RLS is automatically enabled when a security policy is created. This method can be used to explicitly enable RLS if needed.
Optionalschema: stringDisable row-level security on a table (MSSQL) This drops all security policies associated with the table
Optionalschema: stringCheck if a security policy exists (MSSQL RLS)
Optionaloptions: IndexOptionsOptionaloptions: IndexOptions & { computedColumnName?: string; persisted?: boolean }Optionaloptions: {Add a column to a table
Name of the table
Name of the new column
Column definition
Remove a column from a table
Name of the table
Name of the column to remove
Change a column definition
Name of the table
Name of the column to change
New column definition
Show all tables in the database
Get table status (MSSQL implementation)
OptionaltableName: stringGet table create statement (MSSQL implementation)
Check if a table has partitions (MSSQL implementation)
Show constraints for a table
Show indexes for a table
Show all views in the database
Describe a table (get column information)
Name of the table
Rename a table
Current table name
New table name
Add an index to a table
Name of the table
Name of the index
Fields to index
Optionaloptions: IndexOptions
Index options
Remove an index from a table
Name of the table
Name of the index
Create an index on a table with full options support
Name of the table
Index definition
Drop an index from a table
Name of the table
Name of the index
Optional_options: { ifExists?: boolean; cascade?: boolean }Create a SQL Server columnstore index — the storage format used for analytic/warehouse workloads.
A clustered columnstore index (clustered: true, the default) converts
the entire table to columnar storage and therefore takes NO column list —
emitting one is a T-SQL syntax error, which is why the generic
addIndex() (which always appends (cols)) cannot express it. A
nonclustered columnstore index is layered on top of a rowstore table and
DOES take an explicit column list.
Table to build the columnstore index on
Name for the index
Optionaloptions: {Optionalclustered?: booleanClustered (whole-table columnar) when true/omitted; nonclustered when false
Optionalcolumns?: string[]Columns for a nonclustered columnstore index (required when clustered is false; ignored when clustered)
Optionalwhere?: stringFiltered-index predicate (nonclustered columnstore only, SQL Server 2016+)
OptionalcompressionDelay?: numberCOMPRESSION_DELAY = <n> MINUTES WITH option
Create a constraint on a table
Name of the table
Constraint definition
Drop a constraint from a table
Name of the table
Name of the constraint
Optional_options: DropConstraintOptionsBegin a new transaction
Optional_options: TransactionOptionsCreate a schema
The schema name to create
Drop a schema
The schema name to drop
Optionaloptions: DropSchemaOptions
Drop options (e.g., cascade)
Show all schemas in the database
List all schemas
Build a WHERE clause from a WhereOptions object
The where options
Optional_options: BuildOptionsBuild an ORDER BY clause
The order options
Optional_options: BuildOptionsBuild a LIMIT/OFFSET clause
Optionallimit: string | number
Limit value
Optionaloffset: string | number
Offset value
Build an INSERT query
Table name
Values to insert
Optionaloptions: InsertOptions
Query options
Execute a single-row INSERT, optionally toggling IDENTITY_INSERT for
tables where an explicit value is being supplied for an IDENTITY column
(see MSSQLInsertOptions.identityInsert). Unlike buildInsertQuery
(which only builds SQL text), this method actually runs the query, which
is required to bracket it with SET IDENTITY_INSERT ... ON/OFF.
Optionaloptions: MSSQLInsertOptionsBuild an UPDATE query
Table name
Values to update
Where clause
Optionaloptions: UpdateOptions
Query options
Build a DELETE query
Table name
Where clause
Optionaloptions: DeleteOptions
Query options
Build a SELECT query
Select options
Build an UPSERT query (insert or update on conflict)
Table name
Values to insert/update
Optionaloptions: UpsertQueryOptions
Upsert options
Build an increment query
Table name
Fields to increment (field name or array of field names, or object with values)
Where clause
Optionaloptions: { by?: number }
Query options (by: number)
Optional_opts: { ifExists?: boolean; cascade?: boolean }Optional_opts: FdwImportForeignSchemaOptionsCreate a foreign data wrapper (PostgreSQL)
Optional_options: { handler?: string }Drop a foreign data wrapper (PostgreSQL)
Optional_options: { ifExists?: boolean }Create a foreign server (PostgreSQL)
Optional_options: { options?: Record<string, string>; ifNotExists?: boolean }Create a foreign table (PostgreSQL)
Optional_options: { serverName?: string; ifNotExists?: boolean }Create a user mapping for a foreign server
Optional_options: { username?: string; password?: string }Change the owner (authorization principal) of a table. SQL Server has no
ALTER TABLE ... OWNER TO — object ownership is changed with
ALTER AUTHORIZATION ON OBJECT::<table> TO <principal>, which is the
T-SQL equivalent (pass SCHEMA OWNER as the principal to revert to the
containing schema's owner).
Add a table constraint via ALTER TABLE ... ADD CONSTRAINT. Delegates to
createConstraint/buildConstraintSql, mapping the references.fields
array shape onto the references.field shape those helpers expect.
Drop a named table constraint via ALTER TABLE ... DROP CONSTRAINT.
Create a security policy (MSSQL Row-Level Security)
Optionaloptions: { predicate?: string; schema?: string }Drop a security policy (MSSQL Row-Level Security)
Bulk insert records into a table.
T-SQL caps a single INSERT ... VALUES (...), (...), ... statement at
1,000 rows (table-value constructor limit) and 2,100 parameters per
batch. For batches that would exceed either limit, this splits the
records into multiple INSERT statements, executed inside a single
BEGIN TRANSACTION / COMMIT TRANSACTION so the whole call stays
atomic (SQL Server nests transactions via @@TRANCOUNT, so this is safe
even if the caller already has an outer transaction open — only the
outermost COMMIT actually commits, and a ROLLBACK at any nesting level
rolls back the entire transaction, mirroring the BEGIN/COMMIT/ROLLBACK
TRANSACTION pattern already used by startTransaction/commitTransaction
/rollbackTransaction on this dialect).
Optionaloptions: MSSQLBulkInsertOptionsAdd a foreign key to a table
Optionaloptions: {Rename a column
Create a fulltext index (MSSQL supports fulltext search).
SQL Server fulltext indexes are always keyed off a pre-existing UNIQUE
(usually the primary key) index on the table — keyIndexName must name
that existing index, not the fulltext index itself (fulltext indexes
don't have their own name in T-SQL). Fulltext indexes also always belong
to a fulltext catalog; this method creates the catalog if it doesn't
already exist before issuing CREATE FULLTEXT INDEX.
Real syntax produced:
CREATE FULLTEXT INDEX ON table (col1, col2) KEY INDEX
Optionaloptions: {Optionalparser?: stringOptionalcomment?: stringOptionalcatalogName?: stringFulltext catalog to use/create. Defaults to 'default_fulltext_catalog'.
OptionalcreateCatalog?: booleanSet to false to skip catalog creation (e.g. it's already guaranteed to exist).
Create a spatial index (MSSQL supports spatial indexes)
Optionaloptions: { storage?: string; srid?: number }Build CREATE LOGIN and CREATE USER statements for MSSQL. MSSQL uses LOGIN for server-level authentication and USER for database-level access.
Build ALTER LOGIN and ALTER USER statements for MSSQL.
Build DROP USER and DROP LOGIN statements for MSSQL. Must drop USER first, then LOGIN (due to dependencies).
Optionaloptions: { ifExists?: boolean }Get list of users from MSSQL.
Build SHOW GRANTS query for MSSQL. Queries sys.database_permissions for database-level permissions.
Optional_host: stringBuild CREATE ROLE statement for MSSQL.
Build DROP ROLE statement for MSSQL.
Optionaloptions: { ifExists?: boolean; cascade?: boolean }Get roles query for MSSQL.
Generate SQL for creating a database
Database creation options
Generate SQL for dropping a database
Database name to drop
Generate SQL for creating a savepoint
Optionalname: string
Savepoint name (optional, will be generated if not provided)
Generate SQL for releasing a savepoint
Generate SQL for rolling back to a savepoint
Savepoint name to rollback to
Create a PostgreSQL extension
Optional_options: unknownDrop a PostgreSQL extension
Optional_options: unknownGet all installed PostgreSQL extensions
Array of extension information
Check if a PostgreSQL extension is installed
True if the extension is installed
Replace placeholders in SQL with actual values Supports both named (:param) and positional (?) placeholders
SQL string with placeholders
Optional_replacements: unknown[] | Record<string, unknown>SQL with placeholders replaced with escaped values
ProtectedformatST_Distance - calculate distance between two geometries (MSSQL)
Optionalsrid: numberST_Within - check if geometry A is within geometry B (MSSQL)
Optionalsrid: numberST_Contains - check if geometry A contains geometry B (MSSQL)
Optionalsrid: numberST_Intersects - check if geometries intersect (MSSQL)
Optionalsrid: numberST_DWithin - check if geometries are within a given distance (MSSQL)
Optionalsrid: numberST_AsText - convert geometry to text representation (MSSQL)
ST_GeomFromText - create geometry from text (MSSQL)
Optionalsrid: numberBuild an OPENJSON expression to shred a JSON document/array into relational rows.
MSSQL has no JSON_TABLE function; OPENJSON(expr, path) WITH (...) is the real
equivalent, using explicit JSON-path-per-column instead of Oracle/MySQL's COLUMNS(...)
clause. Note: unlike JSON_TABLE, OPENJSON has no FOR ORDINALITY column concept, so
columns flagged forOrdinality are not supported here.
MSSQL: OPENJSON(expr, '$.path') WITH (name type '$.path', ...) AS alias
MSSQL dialect class that implements the Dialect interface