Running SQL

← Contents

TableSkim can run SQL on DuckDB, SQLite, Parquet and JSON files. A query result is shown as an extra sheet named SQL Result, which you can sort, filter, search, summarize and export like any other sheet.

The SQL window and its result sheet

What you can query

FileSQL dialectTables you can use
DuckDB databaseDuckDBEvery table and view of the database
SQLite databaseSQLiteEvery table and view of the database
Parquet fileDuckDBThe file, by its name without the extension (sales.parquet → sales)
JSON fileDuckDBThe file, by its name without the extensions (events.jsonl.gz → events)

Names that contain spaces, symbols or non-ASCII characters can be quoted with double quotes, for example SELECT * FROM "多言語サンプル".

Running a query

Type the SQL and press Run (Ctrl+Enter) in the GUI, or Enter in the terminal UI.

SELECT City, count(*) AS people, round(avg(Age), 1) AS avg_age
FROM normal
GROUP BY City
ORDER BY people DESC

Files are read-only

Files are opened read-only: SQL cannot change the database or the file. SQL allows queries and temporary table/view operations. You can create, update and drop temporary tables and views, which disappear when the window is closed:

CREATE TEMP TABLE adults AS SELECT * FROM normal WHERE Age >= 20;

Writing external files (COPY ... TO, EXPORT, VACUUM INTO), attaching other databases, loading extensions and changing engine settings through SQL are blocked. To save a query result, use Export View... (w in the terminal UI).

History

Every query you run is saved in a history that is shared by all windows and by later sessions.

The history is stored in a file named sql_history:

PlatformLocation
Linux$XDG_STATE_HOME/tableskim/ (usually ~/.local/state/tableskim/)
macOS~/Library/Application Support/TableSkim/
Windows%APPDATA%\TableSkim\

Completion

Press Tab to complete the word before the cursor: table and view names, column names, and SQL keywords. After name. it offers the columns of that table, and it knows aliases given in FROM and JOIN, so SELECT n. completes the columns of normal in SELECT n. FROM normal AS n.

Tips