> ## 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 with alias resolution, 50ms debounce, and support for 500KB+ files

# SQL Autocomplete

Autocomplete suggests keywords, tables, columns, and functions based on where your cursor is and what tables are in scope.

<Frame caption="Context-aware autocomplete">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/autocomplete.png" alt="Autocomplete" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/autocomplete-dark.png" alt="Autocomplete" />
</Frame>

Suggestions appear after 2 characters, after `.`, or after keywords like SELECT/FROM/JOIN. 50ms debounce. Press `Escape` to dismiss.

## Completion Types

### SQL Keywords

Context-aware keyword suggestions:

```sql theme={null}
SEL|  -- SELECT
FROM users WH|  -- WHERE
SELECT * FROM users WHERE name LIKE '%test%' ORD|  -- ORDER BY
```

<Frame caption="SQL keyword suggestions">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/autocomplete-keywords.png" alt="Keyword suggestions" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/autocomplete-keywords-dark.png" alt="Keyword suggestions" />
</Frame>

### Table Names

Tables appear after FROM, JOIN, INSERT INTO, and similar keywords:

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

The clause is detected at the cursor, so a second or third JOIN suggests tables even when an ON condition comes before it. In a table position, tables lead the list ahead of keywords.

<Frame caption="Table name suggestions">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/autocomplete-tables.png" alt="Table suggestions" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/autocomplete-tables-dark.png" alt="Table suggestions" />
</Frame>

### Column Names

Columns are suggested in SELECT, WHERE, ORDER BY, GROUP BY, and other column contexts.

If a FROM clause exists anywhere in the statement (even after the cursor), columns come from those tables. If no FROM clause exists yet, columns from all cached tables appear as fallback.

```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 |  -- Columns from users
```

If the same column name exists in multiple tables, the fallback qualifies them: `users.id`, `orders.id`.

#### Alias Resolution

Type an alias followed by `.` to see that table's columns:

```sql theme={null}
SELECT
    u.|  -- id, name, email, created_at (from users)
FROM users u
JOIN orders o ON u.id = o.|  -- id, user_id, total (from orders)
```

#### Derived Tables and CTEs

An alias for a subquery (derived table) or a `WITH` table completes the columns that subquery's SELECT list produces, including `AS` renames:

```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
```

Explicit (`AS name`), bare (`country`), and qualified (`t.col`) columns resolve. A `SELECT *` subquery and unaliased expressions like `AVG(score)` have no name to suggest, so they are skipped.

<Frame caption="Column suggestions for aliased table">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/autocomplete-alias.png" alt="Alias suggestions" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/autocomplete-alias-dark.png" alt="Alias suggestions" />
</Frame>

### Functions

SQL functions appear in SELECT, WHERE, and expression contexts:

```sql theme={null}
SELECT |  -- COUNT, SUM, AVG, MAX, MIN, etc.
SELECT COUNT(|  -- Columns and *
WHERE date_column > |  -- NOW(), CURRENT_DATE, etc.
```

<Frame caption="SQL function suggestions">
  <img className="block dark:hidden" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/autocomplete-functions.png" alt="SQL function suggestions" />

  <img className="hidden dark:block" src="https://mintlify.s3.us-west-1.amazonaws.com/ngquct/images/autocomplete-functions-dark.png" alt="SQL function suggestions" />
</Frame>

### Favorite Keywords

Favorites you've assigned a keyword to (DB-stored or linked-file `@keyword` frontmatter) appear in the popup as a top-priority match. Type the keyword, accept the suggestion, and the favorite's full SQL replaces the keyword inline. See [Favorites](/features/favorites) for how to assign keywords.

### Schema Names

For databases with multiple schemas (PostgreSQL):

```sql theme={null}
SELECT * FROM |  -- public, schema1, schema2
SELECT * FROM public.|  -- Tables in public schema
```

Schema-qualified names like `public.users` resolve correctly in FROM, JOIN, UPDATE, INSERT INTO, and CREATE INDEX.

For databases organized as database → schema → table (Snowflake, BigQuery), every segment completes — including tables of schemas you haven't opened in the sidebar, which are fetched on demand:

```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
```

Functions from the connection's SQL dialect (e.g. `CONVERT_TIMEZONE` on Snowflake, `SAFE_CAST` on BigQuery) appear in the popup alongside the common SQL functions.

## Context-Aware Suggestions

What appears depends on where your cursor is:

| Context                   | Suggestions                       |
| ------------------------- | --------------------------------- |
| After SELECT              | Columns, `*`, aggregate functions |
| After FROM / JOIN         | Table names                       |
| After WHERE               | Columns, operators, AND/OR        |
| After ON (JOIN)           | Columns from both tables          |
| After GROUP BY / ORDER BY | Columns, ASC/DESC                 |

## Schema-Aware Completions

Suggestions use the actual tables and columns from the connected database, not heuristics or static keyword lists.

* Table names come from the live schema (per database, per schema for PostgreSQL)
* Column names come from each table's column metadata
* Schema-qualified table names resolve correctly: `public.users`, `app.orders`, `analytics.events`
* Aliases are resolved against the live schema (`u.` after `FROM users u` shows `users` columns)

### Pre-FROM Column Suggestions

You don't need a FROM clause to get column completions. If you start typing a column name before writing FROM, TablePro suggests columns from all cached tables. Once you add `FROM users`, suggestions narrow to that table's columns. If a name is ambiguous across tables (`id`, `name`), the fallback qualifies it: `users.id`, `orders.id`.

### Schema Cache

On connection, TablePro fetches table names and loads columns for up to 50 tables in the background. Cached metadata has a short TTL: stale entries are refreshed on next access, and a failed schema load has a 30 second retry cooldown to avoid hammering the server.

After external schema changes (migrations, CLI work), right-click the connection and select **Refresh** to force a reload.

## Performance

Works on files of any size, including multi-megabyte dumps. For files over 500 KB, only a \~10 KB window around the cursor is analyzed. The column cache holds up to 50 tables with LRU eviction.
