SQL runs against a database engine, so "setting up SQL" means installing a database and a client. This guide gets you querying from VS Code.

Pick and install a database

  • SQLite: the simplest start — a single file, no server. Install the sqlite3 CLI (preinstalled on macOS/most Linux; on Windows download from sqlite.org).
  • PostgreSQL: brew install postgresql / official installer — a full-featured server.
  • MySQL: download MySQL Community Server, or brew install mysql.

Verify (SQLite): sqlite3 --version

VS Code

Install the SQLTools extension plus the driver for your database (SQLTools SQLite / PostgreSQL / MySQL). It lets you connect, browse tables and run queries with results shown in a panel.

Run your first query

With SQLite you can start instantly:

sqlite3 demo.db

Then create a table and query it:

CREATE TABLE customers (id INTEGER PRIMARY KEY, name TEXT);
INSERT INTO customers (name) VALUES ('Ada'), ('Grace');
SELECT * FROM customers;

In VS Code, open a .sql file, connect via SQLTools, highlight a statement and press the "Run" action.

Run a script

Keep statements in a file and run them all at once:

sqlite3 demo.db < schema.sql

PostgreSQL uses psql -f schema.sql and MySQL uses mysql < schema.sql.

"Build": version your schema

SQL has no compile step, but you should treat schema changes like code. Keep numbered migration files (001_create_customers.sql, 002_add_orders.sql) in version control and apply them in order. Tools like Flyway, Liquibase or your framework's migration system automate this so every environment matches.