Skip to content

Code Completion

Code completion helps you write SQL faster and with fewer mistakes, by suggesting valid elements as you type and by expanding short abbreviations into full statements.

Completion suggestions

Press Ctrl+Space in the SQL editor to open a resizable hint window listing the elements you can insert at the cursor. Select one to add it to your code.

What is offered depends on where the cursor is — SQLite Expert reads the statement you are writing and suggests only what would be valid at that point:

  • table, view, index and trigger names, and the names of attached databases;
  • column names, taken from the tables the statement refers to;
  • SQL keywords and commands, data types, collation and savepoint names;
  • pragma names, after PRAGMA. The list comes from the SQLite library in use rather than from the application, so it stays right as SQLite changes and follows whichever library you have loaded. Pragmas SQLite has deprecated, and those it provides only for debugging, are left out.
  • function names, wherever an expression is allowed. Every function the current connection knows about is listed, which includes the SQLite built-ins and any function added by a loaded extension — load an extension and its functions start appearing immediately. Function names are not offered where a column is being declared rather than referred to, such as the column list of a CREATE TABLE.

The completion list The completion list

Automatic completion is on by default. You can adjust it under Tools → Options → Code Completion:

  • With Auto Invoke enabled, typing a dot (.) opens the completion window automatically. The Delay setting controls how long SQLite Expert waits before showing it (0–10000 milliseconds).
  • Ctrl+Space always opens completion, even when Auto Invoke is turned off.

Code templates

Templates expand a short abbreviation into a full SQL skeleton. Type the abbreviation in the SQL window and press Ctrl+J to expand it. For example, typing ssf and pressing Ctrl+J replaces it with the SELECT * FROM template:

SELECT * FROM

The following predefined templates are available:

  • atr = ALTER TABLE RENAME
  • ata = ALTER TABLE ADD COLUMN
  • an = ANALYZE
  • ad = ATTACH DATABASE
  • bt = BEGIN TRANSACTION
  • ct = COMMIT TRANSACTION
  • ci = CREATE INDEX
  • cui = CREATE UNIQUE INDEX
  • crt = CREATE TABLE
  • cta = CREATE TABLE AS
  • ctt = CREATE TEMPORARY TABLE
  • ctta = CREATE TEMPORARY TABLE AS
  • ctbd = CREATE TRIGGER BEFORE DELETE
  • ctbi = CREATE TRIGGER BEFORE INSERT
  • ctbu = CREATE TRIGGER BEFORE UPDATE OF
  • ctad = CREATE TRIGGER AFTER DELETE
  • ctai = CREATE TRIGGER AFTER INSERT
  • ctau = CREATE TRIGGER AFTER UPDATE OF
  • ctid = CREATE TRIGGER INSTEAD OF DELETE
  • ctii = CREATE TRIGGER INSTEAD OF INSERT
  • ctiu = CREATE TRIGGER INSTEAD OF UPDATE OF
  • fer = FOR EACH ROW
  • cv = CREATE VIEW
  • cvt = CREATE VIRTUAL TABLE
  • rt = ROLLBACK TRANSACTION
  • df = DELETE FROM
  • dd = DETACH DATABASE
  • dt = DROP TABLE
  • di = DROP INDEX
  • dtr = DROP TRIGGER
  • dv = DROP VIEW
  • et = END TRANSACTION
  • ex = EXPLAIN
  • ie = IF EXISTS
  • ine = IF NOT EXISTS
  • pg = PRAGMA
  • re = REINDEX
  • rs = RELEASE SAVEPOINT
  • rts = ROLLBACK TO SAVEPOINT
  • scf = SELECT COUNT FROM
  • ssf = SELECT * FROM
  • sv = SAVEPOINT
  • ut = UPDATE TABLE
  • vc = VACUUM

See also: Executing SQL scripts