.sql File Extension
.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 type | Structured Query Language script or database dump |
|---|---|
| MIME type | |
| Encoding | Text, commonly UTF-8; the character set is not fixed by the extension |
| Operating systems | Windows, macOS, Linux |
| Opens with | Visual Studio Code, DBeaver, JetBrains DataGrip, Database command-line clients |
| Poly support | Yes. Poly recognizes .sql as readable source text. |
| Indexed by Poly | Yes. Poly indexes the full script for exact and semantic search. |
| Preview in Poly | Yes. .sql files open in Poly's code editor with SQL syntax highlighting. |
| Poly agent | Yes. 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.
.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.1How 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:
| File | Best for | Important limitation |
|---|---|---|
.sql | Reviewable scripts, migrations, and logical dumps | Dialects and client commands vary |
.db or .sqlite | A ready-to-query SQLite database | Binary and engine-specific |
.csv | Simple tabular data exchange | Does 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
- 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
- PostgreSQL Global Development Group. psql. The
-foption reads commands from a named file and reports errors with line numbers. ↩ - SQLite Project. Command-Line Shell for SQLite. The
.dumpdocumentation describes a UTF-8 SQL text export and reconstruction workflow. ↩ ↩2 - Chamberlin, Donald D., and Raymond F. Boyce. SEQUEL: A Structured English Query Language. IBM Research, May 1974. ↩
- International Organization for Standardization. ISO 9075:1987, Database Language SQL. ISO records publication of the first edition in June 1987. ↩