SQL

What is a SQL file?

A table rewritten as INSERT statements, ready to load straight into a database.

What SQL is

SQL is a plain-text format you can open in any editor. It is used for moving data between programs and archiving.

The extension is .sql, and the full name is SQL Insert Statements. Both matter less than what the file can hold, which is what the rest of this page is about.

Where SQL came from

It dates from 1986. The specification is ISO/IEC 9075.

A format that has been readable for that long is a format worth trusting with something you want back in ten years.

The specification is public

Anyone can implement it without asking permission or paying a licence, which is why it turns up in so many programs and why files written twenty years ago still open.

You can leave notes in it

SQL has a comment syntax, which is the difference between a file a person maintains and one a program writes. Comments are the first thing lost converting to a format without them, and nothing warns you.

What opens SQL

PostgreSQL, MySQL and DBeaver read it, and so do most programs of the same kind.

If a file will not open, the format is rarely the problem — it is more often that the program predates it. Converting to something older is the reliable way past that, and it is what the rest of this site is for.

Opening it in a browser

No browser reads it.

That is the single most common reason to convert it: not that the format is bad, but that the place you want to show the file cannot read it.

It is a working format

SQL is meant to be opened and changed. Keep the file in this format for as long as the work is going on, and export from it whenever a finished copy is needed.

The facts, in one place

Identifiers and provenance for the SQL format.
Extension.sql
Media typeapplication/sql
First published1986
SpecificationISO/IEC 9075

Converting something else to SQL

Formats worth considering instead of SQL