TableName
Represents a table reference, optionally schema-qualified and aliased, with optional
dialect-specific optimizer hints. .from(), Insert/Update/Delete's tableName argument, and
join constructors all build TableName instances internally when you pass a plain string.
Constructor
TableName(tableName: string): TableName
TableName(args: TableName.Args): TableName
new TableName(...): TableName
Dual-callable. A string must match [schema.]table[ [as] alias], otherwise throws a TypeError
("does not match table name format").
import { TableName } from '@sqb/builder';
TableName('customers');
TableName('sales.customers c'); // schema "sales", table "customers", alias "c"
TableName({ schema: 'sales', table: 'customers', alias: 'c' });
TableName.Args
interface Args {
schema?: string;
table: string;
alias?: string;
optimizerHint?: string | string[] | OptimizerHint | OptimizerHint[];
}
interface OptimizerHint {
hint: string;
dialect?: string[];
}
optimizerHint lets you attach dialect-specific query hints (e.g. Oracle's /*+ ... */ hints);
rendering them is left to a SerializerExtension — TableName itself only stores them.
Properties
| Key | Type | Readonly | Description |
|---|---|---|---|
_type | SerializationType.TABLE_NAME | Yes | Discriminates this node during serialization. |
schema | string | undefined | No | Schema qualifier. |
table | string | undefined | No | Table name. |
alias | string | undefined | No | Table alias. |
optimizerHint | TableName.OptimizerHint[] | undefined | No | Optimizer hints attached via the object constructor form. |
Methods
TableName has no chainable methods — it exposes only its serialization logic (default rendering:
[schema.]table[ alias]).
import { Select } from '@sqb/builder';
Select().from('sales.customers c').generate().sql;
// select * from sales.customers c