SQL Autocomplete
TablePro provides intelligent, context-aware SQL autocomplete that understands your database schema, SQL syntax, and query context. This helps you write queries faster and with fewer errors.
How Autocomplete Works
The autocomplete system analyzes:
- Your current position in the query
- SQL syntax context (SELECT, FROM, WHERE, etc.)
- Referenced tables and their aliases
- Your database schema (tables, columns, functions)
This allows it to suggest only relevant completions based on what makes sense at each point in your query.
Triggering Autocomplete
Automatic
Autocomplete appears automatically as you type:
- After typing 1-2 characters
- After typing
. (dot) for column access
- After certain keywords (SELECT, FROM, JOIN, etc.)
Manual
Force the autocomplete popup:
- Start typing and wait briefly
- The popup appears with relevant suggestions
Dismissing
- Press
Escape to dismiss the popup
- Continue typing to filter suggestions
- Click outside the popup
Completion Types
SQL Keywords
Keywords are suggested based on SQL syntax context:
SEL| -- Suggests: SELECT
FROM users WH| -- Suggests: WHERE
SELECT * FROM users WHERE name LIKE '%test%' ORD| -- Suggests: ORDER
Suggested keywords include:
| Category | Keywords |
|---|
| Statements | SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP |
| Clauses | FROM, WHERE, JOIN, ON, GROUP BY, ORDER BY, HAVING, LIMIT |
| Operators | AND, OR, NOT, IN, LIKE, BETWEEN, IS NULL, EXISTS |
| Joins | INNER JOIN, LEFT JOIN, RIGHT JOIN, CROSS JOIN |
Table Names
Tables are suggested after keywords that expect table references:
SELECT * FROM | -- Suggests all tables
SELECT * FROM us| -- Suggests tables starting with "us": users, user_roles
SELECT * FROM users JOIN | -- Suggests all tables
Column Names
Columns are suggested based on referenced tables:
SELECT | FROM users -- Suggests columns from users table
SELECT u.| FROM users u -- Suggests columns with "u." prefix
SELECT * FROM users WHERE | -- Suggests columns from users
After Table Alias
When you use a table alias, typing the alias followed by . shows that table’s columns:
SELECT
u.| -- Shows: id, name, email, created_at (from users)
FROM users u
JOIN orders o ON u.id = o.| -- Shows: id, user_id, total (from orders)
Functions
SQL functions are suggested in appropriate contexts:
SELECT | -- Suggests: COUNT, SUM, AVG, MAX, MIN, etc.
SELECT COUNT(| -- Suggests columns and *
WHERE date_column > | -- Suggests: NOW(), CURRENT_DATE, etc.
Common function suggestions:
| Category | Functions |
|---|
| Aggregate | COUNT, SUM, AVG, MAX, MIN |
| String | CONCAT, SUBSTRING, UPPER, LOWER, TRIM |
| Date | NOW, CURRENT_DATE, DATE_FORMAT, DATEADD |
| Math | ROUND, ABS, CEIL, FLOOR |
| Conditional | COALESCE, NULLIF, CASE, IF |
Schema Names
For databases with multiple schemas (PostgreSQL):
SELECT * FROM | -- Suggests: public, schema1, schema2
SELECT * FROM public.| -- Suggests tables in public schema
Context-Aware Suggestions
After SELECT
Immediately after SELECT:
- Column names from tables in FROM clause
* for all columns
DISTINCT modifier
- Aggregate functions
SELECT |
-- Suggests: *, DISTINCT, column names, functions
After FROM/JOIN
After FROM or JOIN keywords:
- All accessible table names
- Schema-qualified names (schema.table)
After WHERE
In WHERE clauses:
- Column names from selected tables
- Comparison operators
- Logical operators (AND, OR)
After ON (JOIN condition)
In JOIN ON clauses:
- Columns from both joined tables
- Commonly used for foreign key relationships
SELECT * FROM users u
JOIN orders o ON |
-- Suggests: u.id, o.user_id, etc.
After GROUP BY
- Columns that appear in SELECT clause
- Non-aggregated column names
After ORDER BY
- Column names
- Aliases defined in SELECT
- ASC/DESC keywords
Using Completions
Keyboard Navigation
| Key | Action |
|---|
↓ Down arrow | Select next suggestion |
↑ Up arrow | Select previous suggestion |
Enter | Accept selected suggestion |
Tab | Accept selected suggestion |
Escape | Dismiss popup |
Filtering
Continue typing to filter the suggestions:
SELECT * FROM user|
-- Shows: users, user_roles, user_preferences
-- Typing more narrows results
Accepting Suggestions
When you accept a suggestion:
- The suggestion text is inserted at cursor
- Any typed prefix is replaced
- Cursor moves to end of inserted text
Schema Caching
How Schema is Loaded
When you connect to a database, TablePro:
- Fetches all table names
- Loads column information for each table
- Caches this information for fast autocomplete
Refreshing Schema
If you make schema changes (add tables, alter columns):
- Right-click the connection in sidebar
- Select Refresh
Or disconnect and reconnect to the database.
Schema changes made in TablePro (via Structure tab) are automatically reflected in autocomplete.
Large Files
Autocomplete works on SQL files of any size, including multi-megabyte dumps. For files larger than 500 KB, the engine automatically extracts a local window around the cursor and analyzes only the nearby statement, so suggestions remain instant regardless of total file size.
Large Schemas
For databases with many tables (100+):
- Initial schema loading may take a moment
- Autocomplete remains responsive after caching
- Filter suggestions by typing more characters
- Type more characters: Typing more narrows suggestions faster
- Use table aliases: Reduces lookup scope
- Let caching work: Schema is cached after first load
Limitations
What’s Not Suggested
- Temporary tables (not in schema)
- Subquery aliases
- Dynamic column names
- Columns from other connections
Query Complexity
Very complex queries may have limited context awareness:
- Deeply nested subqueries
- Complex CTEs
- Dynamic SQL
In these cases, basic keyword and table suggestions still work.
Configuration
Autocomplete is enabled by default with no configuration needed.
Future settings may include:
- Enable/disable autocomplete
- Autocomplete trigger delay
- Case sensitivity options
Best Practices
Use Table Aliases
Aliases make autocomplete more precise:
-- Good: Clear which table each column comes from
SELECT u.name, o.total
FROM users u
JOIN orders o ON u.id = o.user_id
-- Less clear without aliases
SELECT users.name, orders.total
FROM users
JOIN orders ON users.id = orders.user_id
Start with FROM
Writing FROM first helps autocomplete know your tables:
-- This approach helps autocomplete
FROM users u
JOIN orders o ON u.id = o.user_id
SELECT u.| -- Now knows about u and o tables
Let Suggestions Guide You
If you’re not sure of the exact column name:
- Type the table alias and dot:
u.
- Browse the suggestions
- Select the correct column
Troubleshooting
Suggestions Not Appearing
- Check connection: Ensure you’re connected to a database
- Refresh schema: Right-click connection > Refresh
- Wait for cache: Large schemas may take time to load
Wrong Suggestions
- Check table aliases: Ensure aliases are correctly defined
- Check FROM clause: Tables must be referenced to suggest columns
- Refresh if schema changed: Schema changes need refresh
Slow Suggestions
- Type more characters: Narrows search space
- Use aliases: Limits scope of column search
- Check database connection: Network latency affects schema loading
Next Steps