iLoveConverter
Categories 11 categories
Data SQL

The SQL (.sql) Script Format, Explained

iLoveConverter Team 1 min read

On this page

An .sql file is a plain-text script containing SQL statements, typically semicolon-separated. There is no single standard (each database has its own SQL dialect), but the purpose is consistent: create schema, insert seed data, define stored procedures, or export/import database content. Every database management tool supports .sql scripts as import and export format.

A sample .sql file

CREATE TABLE users (
    id INTEGER PRIMARY KEY,
    name TEXT NOT NULL,
    email TEXT UNIQUE
);
INSERT INTO users (name, email) VALUES ('Alice', '[email protected]');

Comments use -- or /* */. Statements end with ;.

SQL dialect differences

PostgreSQL uses SERIAL for auto-increment; MySQL AUTO_INCREMENT; SQLite AUTOINCREMENT; SQL Server IDENTITY. String concatenation: || in Postgres/SQLite, CONCAT() in MySQL, + in SQL Server. These matter when sharing .sql files across databases.

Common uses

  • Schema migrations — one .sql per version change, tracked in VCS.
  • Export/dump — mysqldump, pg_dump, sqlite3 .dump all produce .sql.
  • Import — feed .sql to the database CLI.
  • Initialisation — init.sql, schema.sql run on project start.

Running .sql scripts

# PostgreSQL
psql -d mydb -f init.sql
# MySQL
mysql -u root -p mydb < init.sql
# SQLite
sqlite3 my.db < schema.sql
# SQL Server
sqlcmd -d mydb -i init.sql

FAQ

Is .sql a standard format?

Not formally, but the .sql extension and semicolon convention are universal.

Can JSON replace .sql?

No — .sql defines schema; JSON only holds data. For data exchange use JSON/CSV; for database management use .sql.

Will a .sql script work on all databases?

Rarely. Each database has dialect differences; use Alembic or Prisma for cross-DB portability.

Try it yourself — free, right in your browser

Everything mentioned in this guide runs locally on this site: no upload, no watermark, no sign-up.

Format deep-dives: SQL (.sql) , JSON (.json) , CSV (.csv)