LocalSQL Client Documentation
A high-performance, client-side SQL development workspace running 100% in your browser using SQLite compiled to WebAssembly (sql.js).
⚡ Zero-Latency WASM
Direct SQL engine execution in browser memory with sub-millisecond responsiveness.
💾 Persistent Storage
Database binary blobs are safely cached in IndexedDB and restored on reload.
🔄 Import & Export
Seamlessly import any .sqlite file, or export your active database to disk.
📊 Results & CSV/JSON
Paginated data grid with in-table search, click-to-copy, and instant data exports.
💾 Database Operations
Manage multiple SQLite databases with instant switching and file synchronization.
| Operation | How to Trigger | Description |
|---|---|---|
| Create Blank Database | Database Menu → Create New Database or Landing Page | Creates a clean database ready for custom CREATE TABLE statements. |
| Load E-Commerce Sample | Landing Page → E-Commerce Store | Preloads 5 relational tables: customers, categories, products, orders, order_items. |
| Load Company Sample | Landing Page → Company & Employees | Preloads 4 relational tables: departments, employees, projects, assignments. |
| Import .sqlite File | Navbar Import File | Loads any local .sqlite, .db, or .sqlite3 file directly into memory and IndexedDB. |
| Export Database | Navbar Export .sqlite | Downloads the entire active database as a valid SQLite binary file. |
| Switch Database | Navbar Active DB Pill | Opens the Saved Databases menu. Click outside or press Esc to close. |
⚡ SQL Query Editor
The code editor is designed specifically for efficient SQL query drafting and execution.
Core Editing Features:
- Execution Modes: Run the entire query canvas, or highlight specific text to execute Run Selection.
- Keyboard Shortcut: Press Ctrl + Enter (or Cmd + Enter on Mac) to execute instantly.
- Code Indentation: Pressing Tab inserts a clean 2-space tab indentation.
- Keyword Formatter: Click Format to uppercase all standard SQL keywords (
SELECT,FROM,JOIN,WHERE, etc.). - Context Sample Queries: When browsing sample databases, access pre-built sample queries from the dropdown.
📊 Results & Inspection
Interactive tabular presentation with execution metrics and export capabilities.
Result Grid Features:
- Execution Speed: High-precision query runtime displayed in milliseconds (e.g.
1.4 ms). - Live In-Table Search: Instant filter input searches across all visible columns without re-querying the database.
- Click-to-Copy: Click any table cell to immediately copy its value to the clipboard.
- Formatted Values: Distinct badges for
NULLvalues and right-aligned numeric data. - Pagination: Browse results with 10, 25, 50, or 100 rows per page.
- Data Export: One-click download of result sets to CSV or JSON.
🏛️ SQL Support Matrix: Triggers, Procedures & Functions
Understanding SQLite WebAssembly engine capabilities and alternatives:
| SQL Object | CREATE | UPDATE / Alter | DROP | SQLite Behavior & LocalSQL Support |
|---|---|---|---|---|
| Triggers | ✔ Yes | Drop & Recreate | ✔ Yes | Fully Supported. Native support for BEFORE, AFTER, and INSTEAD OF triggers on INSERT, UPDATE, and DELETE. |
| Stored Procedures | ✖ No | ✖ No | ✖ No | Not Supported by SQLite. SQLite is an embedded database engine without procedural language extensions. Use Multi-Statement Transactions or Triggers instead. |
| Functions (Custom SQL) | ✖ No | ✖ No | ✖ No | No SQL syntax. SQLite does not have a CREATE FUNCTION statement; custom UDFs are registered via the host JavaScript runtime API. |
| Functions (Built-in) | ✔ 80+ Functions Available | Fully Supported. Extensive built-in library for math, string manipulation, date/time arithmetic, and JSON processing. | ||
⚡ Multi-Statement Scripts & ACID Transactions
Because SQLite does not have stored procedures, you can achieve procedure-like transactional workflows by grouping multiple statements inside a single transaction script:
-- Multi-Statement Transaction
BEGIN TRANSACTION;
UPDATE accounts SET balance = balance - 100 WHERE id = 1 AND balance >= 100;
UPDATE accounts SET balance = balance + 100 WHERE id = 2;
INSERT INTO transfer_logs (from_id, to_id, amount) VALUES (1, 2, 100);
COMMIT;
- Atomicity: If any statement fails or produces a syntax error, no intermediate updates are persisted.
- High Performance: Multi-statement transactions execute up to 100x faster than single-statement autocommits.
- Explicit Rollback: You can explicitly execute
ROLLBACK;to discard changes if a condition check fails.
📚 Built-in Functions Reference
Standard SQLite functions you can call directly in queries:
📝 String & Text
UPPER(str)/LOWER(str): Case conversionSUBSTR(str, start, len): SubstringLENGTH(str): Character countTRIM(str)/REPLACE(str, from, to)a || b: String concatenation operator
🔢 Math & Numeric
ROUND(num, decimals): Round valueABS(num): Absolute valueMAX(a, b, ...)/MIN(...)RANDOM(): Random 64-bit integerTOTAL(col): Floating point sum
📅 Date & Time
DATE('now'): Current UTC dateTIME('now'): Current UTC timeDATETIME('now', '+7 days'): Date mathSTRFTIME(format, date): Custom formatCURRENT_TIMESTAMP: ISO datetime default
🔍 JSON Operations
JSON_EXTRACT(json, path): Read JSON valueJSON_OBJECT(k1, v1, ...): Create JSON objectJSON_ARRAY(v1, v2, ...): Create JSON arrayJSON_TYPE(json, path): Value typeJSON_VALID(str): Validate JSON syntax
⌨️ Keyboard Shortcuts Reference
| Shortcut | Where | Action |
|---|---|---|
| Ctrl + Enter / Cmd + Enter | Editor | Run full SQL query or run selected text |
| Tab | Editor | Indent code by 2 spaces |
| Esc | Navbar | Close Saved Databases dropdown |
| Double Click | Split Divider | Reset workspace split to default 45/55 ratio |
📋 Common SQL Recipes
Copy any of the following queries to paste and execute inside LocalSQL Client:
1. Create Table with Constraints
CREATE TABLE IF NOT EXISTS notes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
content TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
2. Aggregate Orders with Total Revenue
SELECT
c.first_name || ' ' || c.last_name AS customer_name,
c.city,
COUNT(o.id) AS total_orders,
ROUND(SUM(o.total_amount), 2) AS total_spent
FROM customers c
JOIN orders o ON c.id = o.customer_id
GROUP BY c.id
ORDER BY total_spent DESC;
3. Department Headcount & Salary Summary
SELECT
d.name AS department,
COUNT(e.id) AS employee_count,
ROUND(AVG(e.salary), 2) AS avg_salary,
ROUND(SUM(e.salary), 2) AS total_payroll
FROM departments d
LEFT JOIN employees e ON d.id = e.department_id
GROUP BY d.id
ORDER BY total_payroll DESC;