> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tablepro.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Autocomplete

> Schema-aware SQL autocomplete for keywords, tables, columns, and functions

An alias and a dot give you that table's columns, and that holds for a subquery or a `WITH` table that exists only in the statement you are writing. Everything the popup offers is decided by where the cursor sits.

It opens itself with nothing typed after FROM, JOIN, INTO, ON, SET, USING, RETURNING, a `::` cast, an INSERT or ALTER column list, and the first item after SELECT. Where a full list would be noise, such as in WHERE or inside a function call, type a character or press `Ctrl+Space`.

![Autocomplete](https://mintcdn.com/ngquct/tXWaltqW4Zqkau0T/images/autocomplete.png?fit=max\&auto=format\&n=tXWaltqW4Zqkau0T\&q=85\&s=cf76906faee6f64b9224ca7feeb33cc8)

Context-aware autocomplete

| Key | Action |
| - | - |
| `Ctrl+Space` | Open the popup anywhere, even with an empty prefix |
| `Up` `Down` | Move through suggestions |
| `Return` / `Tab` | Accept the selected suggestion |
| `Escape` | Dismiss and keep typing |

Autocomplete is always on and there is nothing to turn off. What the popup offers depends entirely on where the cursor sits. Two settings decide spelling: the case keywords come back in, and on some engines the case of table and column names.

## SQL keywords

```sql theme={null}
SEL|  -- SELECT
FROM users WH|  -- WHERE
```

## Keyword case

Keywords and built-in functions come back in the case you are typing:

```sql theme={null}
sel|  -- select
SEL|  -- SELECT
cou|  -- count()
COU|  -- COUNT()
```

The first letter decides, so `Sel` completes to `SELECT` and `sElE` to `select`. A phrase moves as one: `group b` completes to `group by`. Table, column and schema names follow [Identifier case](#identifier-case) instead. Aliases, saved [favorite keywords](#favorite-keywords) and the values of an enum column are never re-cased.

**Settings > Editor > Keyword case** holds four values:

| Value | Typing `sel` | Nothing typed |
| - | - | - |
| Match what I type, otherwise UPPERCASE | `select` | `SELECT` |
| Match what I type, otherwise lowercase | `select` | `select` |
| UPPERCASE | `SELECT` | `SELECT` |
| lowercase | `select` | `select` |

The two absolute values also rewrite keywords as you type them and set the case [Format SQL](https://docs.tablepro.app/features/sql-editor.md#formatting) produces.

## Identifier case

PostgreSQL and PGlite read an unquoted name as lowercase, Oracle and Snowflake as uppercase. On those engines a table or column stored in any other case, or named after a reserved word, completes quoted and exactly as stored, so the query finds it:

```sql theme={null}
SELECT * FROM mix|  -- "MixedCase"
```

Set how the other names are spelled with **Identifier Case**, under **Autocomplete** on the connection's [Advanced](https://docs.tablepro.app/connections/connection-form.md#advanced) pane:

| Value | Snowflake table `MY_TABLE`, typing `my_t` |
| - | - |
| As stored (the default) | `MY_TABLE` |
| lowercase | `my_table` |
| UPPERCASE | `MY_TABLE` |
| Match what I type | `my_table` |

A name changes case only when the engine reads the new spelling as the same name. **Match what I type** follows the first letter you type, and keeps the stored spelling when you have typed none. Inside quotes you typed yourself, the name goes in as stored.

**lowercase** and **UPPERCASE** also spell the names **Copy as INSERT Statements** and **Copy as UPDATE Statements** write, which otherwise quote every name.

## Table names

Tables appear after FROM, JOIN, INSERT INTO and similar keywords, and lead the list ahead of keywords there. The clause is read at the cursor, so a second or third JOIN still offers tables.

```sql theme={null}
SELECT * FROM |  -- All tables
SELECT * FROM us|  -- Tables starting with "us": users, user_roles
SELECT * FROM a JOIN b ON a.id = b.id JOIN |  -- All tables, even after an ON condition
```

## Column names

A FROM clause anywhere in the statement, even after the cursor, decides which tables columns come from. With no FROM clause yet every cached table contributes, and ambiguous names are qualified: `users.id`, `orders.id`.

```sql theme={null}
SELECT na|  -- Columns matching "na" from all cached tables
SELECT | FROM users  -- Columns from users
SELECT u.| FROM users u  -- Columns from users via alias
SELECT * FROM users WHERE |  -- Ctrl+Space for columns from users
```

ORDER BY offers the SELECT list's aliases ahead of the table columns:

```sql theme={null}
SELECT price * qty AS line_total FROM items ORDER BY li|  -- line_total
```

`SET` and an `INSERT` column list offer the columns of the table the statement writes, never those of a table its FROM or SELECT reads, also inside a `WITH` body.

## Join conditions

Right after the `ON` of a join, the foreign keys between the joined table and the tables before it come first, each as a whole condition:

```sql theme={null}
SELECT * FROM orders o JOIN customers c ON |  -- o.customer_id = c.id
```

* A key in either direction counts, and the earlier table's column comes first.
* A key over several columns is one condition, its pairs joined with `AND`.
* The nearest earlier table comes first. A table joined after the cursor, a derived table and a `WITH` table give none.
* The alias names a table when it has one, otherwise the table name as you wrote it.

The keys are read once per table, on engines that report foreign keys. After `o.`, or once the condition has begun, the list offers columns as before.

## Aliases, subqueries and CTEs

An alias followed by `.` gives that table's columns. A derived table or a `WITH` table gives the columns its own query produces:

```sql theme={null}
SELECT ahs.|  -- country, avg_score
FROM happiness_scores hs
LEFT JOIN (
    SELECT country, AVG(score) AS avg_score
    FROM happiness_scores
    GROUP BY country
) ahs ON hs.country = ahs.country

WITH totals AS (
    SELECT region, SUM(amount) AS total FROM sales GROUP BY region
)
SELECT t.| FROM totals t  -- region, total
```

`AS name`, an alias without `AS` such as `COUNT(*) total`, bare names and qualified `t.col` all resolve. A column list, `WITH totals (region, amount) AS` or `AS t(id, name)`, renames the columns in order. `*` and `t.*` give the table's columns from the schema. An unaliased `AVG(score)` has no name to offer, so it is skipped.

A `WITH` table may be `MATERIALIZED`, a `VALUES` list, or an `INSERT`, `UPDATE`, `DELETE` or `MERGE` that ends in `RETURNING`. It gives the columns it returns. `RETURNING *` gives the changed table's columns, plus those of a table joined through FROM or USING:

```sql theme={null}
WITH moved AS (
    DELETE FROM queue WHERE done RETURNING id, payload
)
SELECT m.| FROM moved m  -- id, payload
```

## Functions and operators

Functions appear in SELECT, WHERE and expression contexts, the connection's own dialect alongside the common SQL ones: `CONVERT_TIMEZONE` on Snowflake, `SAFE_CAST` on BigQuery.

```sql theme={null}
SELECT COUNT(|  -- Ctrl+Space for columns and *
WHERE date_column > |  -- Ctrl+Space for NOW(), CURRENT_DATE, …
```

Operators the dialect declares appear in WHERE, ON, HAVING and AND, each with what it does and the types it takes. On PostgreSQL that covers JSON, array and range containment, regex, full-text search and the network operators:

```sql theme={null}
WHERE data -|            -- ->  (field as json), ->>  (field as text)
WHERE payload @|         -- @>  contains, @?  JSON path returns any item
WHERE tags &|            -- &&  arrays overlap
WHERE email ~|           -- ~   POSIX regex, ~* case insensitive
```

An operator restricted to `jsonb` is held back on a `json` column rather than offered and rejected by the server.

## Casts and enum values

Typing `::` offers the dialect's type names in the spelling you write, not the internal catalog name. Comparing against a column whose type declares a fixed set of values, a PostgreSQL enum for instance, offers those values quoted:

```sql theme={null}
SELECT id::|             -- integer, bigint, text, timestamptz, jsonb, uuid, …
SELECT payload::js|      -- json, jsonb, jsonpath
WHERE status = |         -- Ctrl+Space for 'pending', 'active', 'archived'
WHERE mood <> 'ha|       -- 'happy'
```

## Schema names

On multi-schema engines, schemas complete in FROM and `public.users` resolves in FROM, JOIN, UPDATE, INSERT INTO and CREATE INDEX.

A bare table name completes with the tables the server finds without a schema: those in the tab's own schema, or on Spanner those in the default schema. For a table anywhere else, type its schema and a dot. That schema's tables follow, including a schema the sidebar has never opened:

```sql theme={null}
SELECT * FROM times|          -- tables in the tab's own schema
SELECT * FROM attendance.|    -- tables in attendance
```

Where the hierarchy is database, schema, table (Snowflake, BigQuery), every segment completes:

```sql theme={null}
SELECT * FROM ANALYTICS_|                      -- databases
SELECT * FROM ANALYTICS_PROD.|                 -- schemas
SELECT * FROM ANALYTICS_PROD.DBT_MARTS.|       -- tables in that schema
SELECT * FROM ANALYTICS_PROD.DBT_MARTS.ORDERS o WHERE o.|  -- columns
```

## Which database a tab completes against

Every query tab carries its own database and schema, named in the picker at the top of the editor. Suggestions come from there, not from whatever the object browser is pointing at, so selecting a different database in the sidebar leaves open tabs alone.

Two tabs on one connection can sit on different databases and complete against each. Change a tab's database in the picker and its suggestions follow on the next keystroke.

On engines with schemas under a database, the picker names both, as `analytics.public`.

## Favorite keywords

A favorite with a keyword, stored in the database or set by `@keyword` frontmatter in a linked file, appears as a top-priority match. Type the keyword, accept it, and the favorite's full SQL replaces it inline. Fields such as `${1:name}` in that SQL are visited with `Tab`, and a `;;` says where the cursor lands afterwards. See [Favorites](https://docs.tablepro.app/features/favorites.md#fields).

## MongoDB

MongoDB connections complete MQL, so the popup follows the shape of the query rather than SQL clauses:

```js theme={null}
db.|                                  // collections, plus getCollectionNames(), createCollection(), …
db.users.|                            // find(), aggregate(), updateOne(), insertMany(), …
db.users.find({ |                     // field names, then $eq, $gt, $in, $exists, $regex, …
db.users.find({}, { |                 // field names, then $slice, $elemMatch, $meta
db.users.updateOne({}, { |            // $set, $unset, $inc, $push, $addToSet, …
db.users.updateOne({}, [{ |           // the six stages an update pipeline allows
db.orders.aggregate([{ |              // $match, $group, $lookup, $unwind, $facet, …
db.orders.aggregate([{ $group: { |    // $sum, $avg, $first, $push, and the expression operators
```

`$set` and `$unset` mean different things as an update operator and as a pipeline stage; the description shown is whichever applies at the cursor.

Field names come from a sample of the collection's documents, nested paths included, so `address: { city, zip }` offers `address`, `address.city` and `address.zip`. Objects inside an array contribute paths too, and shallower fields sort first. The sample is cached per collection and cleared when you switch database or refresh the connection.

Comments suppress completion, and a brace or bracket inside a string literal does not open a document.

## On iPhone and iPad

The iOS query editor completes keywords, tables, views, columns, aliases, the engine's functions and operators, schema names and enum values by the same rules, in the bar above the keyboard: see [Querying](https://docs.tablepro.app/ios.md#querying). Favorite keywords are Mac only.

## My new table does not complete

Table names are cached when a connection opens, and column names the first time a query tab on that database is on screen. Moving between connections in the window keeps the cache. A change made from TablePro reloads it on its own: a statement run in the SQL editor, a save from the sidebar, an import, a restore, Copy Objects, Compare & Sync, and statements run through MCP or the AI assistant. A migration or a `CREATE TABLE` run from another client stays invisible until the cache reloads. Press `Cmd+R` (**Database > Refresh**), or right-click the sidebar's Tables header and choose **Refresh**. Switching databases reloads it too.

## Large files

Completion works on files of any size, multi-megabyte dumps included. Past 500 KB only a 10 KB window around the cursor is read, so suggestions follow the statements near you rather than the whole file.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.