.sql File Extension

Learn what a .sql file contains, which tools open and run SQL scripts, how Poly supports them, and how they differ from database files.

File extension details for .sql

Full Support
File typeStructured Query Language script or database dump
MIME type
EncodingText, commonly UTF-8; the character set is not fixed by the extension
Operating systemsWindows, macOS, Linux
Opens withVisual Studio Code, DBeaver, JetBrains DataGrip, Database command-line clients
Poly supportYes. Poly recognizes .sql as readable source text.
Indexed by PolyYes. Poly indexes the full script for exact and semantic search.
Preview in PolyYes. .sql files open in Poly's code editor with SQL syntax highlighting.
Poly agentYes. The Poly agent can read and explain the SQL text without executing it.

What kind of file is a .sql?

A .sql file is a text file containing Structured Query Language statements. It may be a short query, a schema migration, or a database dump with many CREATE, INSERT, and other commands. The registered MIME type is application/sql. Its registration assigns the .sql extension but no magic number, so identification depends on the filename, media type, and readable contents.1

SQL has a standard core, but real scripts often use database-specific syntax, data types, procedural code, or client commands. A file written for PostgreSQL may not run unchanged in MySQL, Microsoft SQL Server, Oracle Database, or SQLite. Check the intended database and version before executing it.

Treat an unfamiliar .sql file as a program, not passive data. Review it for destructive statements, privilege changes, embedded code, and sensitive records. Run it only against the intended database with appropriate permissions and a current backup.1

How do I open a .sql on my computer?

For reading and editing, use a text or code editor such as Visual Studio Code, Notepad++, BBEdit, or Vim. Database tools including DBeaver and JetBrains DataGrip add dialect-aware completion and let you choose a connection before running selected statements.

To execute a script, use the client for its target database. PostgreSQL's psql accepts a file with -f, while SQLite can rebuild a database by reading SQL text produced by its .dump command.23 Opening the file in an editor is safe by itself. Running it can create, alter, or delete data.

Text encoding is not guaranteed by the suffix. UTF-8 is common, but RFC 6922 says software must not assume a default character set without inspecting the content. If characters look corrupted, determine the encoding before saving over the original.1

Poly support for .sql

Poly treats .sql as readable source text. It opens in the code editor with SQL syntax highlighting, and its complete text is available for exact and semantic search. The Poly agent can read, summarize, and explain the script.

Poly does not connect the script to a database or execute its statements. That makes preview useful for reviewing migrations and dumps, but database-specific validation still belongs in the matching database tool.

History of .sql

Donald Chamberlin and Raymond Boyce described SEQUEL, a structured English query language for relational data, in a May 1974 IBM paper.4 The language later became SQL. ISO published the first edition of its SQL database-language standard as ISO 9075:1987 in June 1987.5

The filename convention grew with tools that saved reusable scripts and portable text dumps. The Internet Engineering Task Force formally registered application/sql, including the sql file extension, in April 2013.1

Working with .sql and alternatives

Choose the representation that matches what you need:

FileBest forImportant limitation
.sqlReviewable scripts, migrations, and logical dumpsDialects and client commands vary
.db or .sqliteA ready-to-query SQLite databaseBinary and engine-specific
.csvSimple tabular data exchangeDoes not preserve schemas, indexes, or relationships

SQLite documents .dump as UTF-8 SQL text that can reconstruct a database.3 Such a dump is not the same as the original binary database, and changing data.sql to data.db does not convert it. For long-lived migrations, keep scripts in version control, state the target database and version, and test restoration against a disposable database.

Footnotes

  1. Internet Engineering Task Force. RFC 6922: The application/sql Media Type. The registration documents the extension, absent magic number, character-set handling, interoperability, and security considerations. 2 3 4
  2. PostgreSQL Global Development Group. psql. The -f option reads commands from a named file and reports errors with line numbers.
  3. SQLite Project. Command-Line Shell for SQLite. The .dump documentation describes a UTF-8 SQL text export and reconstruction workflow. 2
  4. Chamberlin, Donald D., and Raymond F. Boyce. SEQUEL: A Structured English Query Language. IBM Research, May 1974.
  5. International Organization for Standardization. ISO 9075:1987, Database Language SQL. ISO records publication of the first edition in June 1987.
© Poly Corp. 2026