Someone gave me a file with extension sql, but I don't know what should I use to open it. I can open it with a text editor, but I would like to view it as a table. Is there any software that can do it without much effort? If not, do you know any quick recipe to do it?

6 Answers 6


.sql files are not tables per se. They're an exported database. Basically code for the database software to create the tables and such. CREATE TABLE, etc. The very same code you would use if you wanted to create a similar database/table(s).

This means the file is not a table, and the only thing that can make a table out of it is SQL software such as MySQL.

To compare, it's as if your friend sent you a macro/script that automatically creates a series of files, and you wanted to view the files without launching the macro and actually creating the files. Not really possible unless you have a very specific tool that emulates Windows creating files.

So I think your only solution is to install SQL and to import the database, effectively creating it anew on your own computer. To do this, I think the simplest way is to install and run WAMPserver ( http://www.wampserver.com/en/ ) , then to type "localhost" in your Web browser's address bar. Then you click phpMyAdmin, and click import to, well, import the file. Make sure the file encodings match.

Note that WAMP (and, therefore, MySQL) is probably only going to work if the file was exported in the MySQL format. That is, if the original database was in MySQL or if the other SQL engine (such as Microsoft SQL Server) has an option for exportation compatible with MySQL. And if the option was used, of course. If not, you'll need to find what database software's format the .sql file is in and install the appropriate software.

Oh, just before posting I did a quick search, and I think I might have found a tool that possibly allows you to simulate SQL and just view the table(s) without having to have the actual database. Maybe. Up to you to test it. Might not do what you want at all, but if it does, it might be simpler than WAMP. I'm sure installing the appropriate SQL software works, though.


  • 3
    Note that SQL syntaxes differ slightly between database engines. In the simplest cases the same script will work across a number of engines, but as soon as you do anything non-trivial, you are going to run into various implementation-specific things. Take name quoting for example; MySQL uses backticks, whereas MS SQL and Access use square brackets. Some field names can be treated as reserved keywords in one database engine but be valid in another. So to be certain, you need to run the script in the same database engine software that was used to create it. Otherwise it may or may not work.
    – user
    Jan 8, 2013 at 9:11
  • Yes uhm. Just that I figured that it would -probably- work this way, and/or that most people use MySQL anyway, to the best of my knowledge. And well, the OP doesn't seem to be so knowledgeable in this. I feel giving too much detail would've been, maybe, dizzying. :p
    – Ariane
    Jan 8, 2013 at 16:18
  • Good answer, just wanted to note that going by the name of the tool (Preview and Export) and its description ("First select the data provider from the dropdown menu. And provide the database connection string to connect to database."), it won't help in this case.
    – Karan
    Jan 8, 2013 at 17:05
  • The OP is hardly going to be helped when the database engine gives an error along the lines of invalid identifier or the likes. No need to go into every detail, but I do feel that it is important to note that different RDBMSs have different syntaxes.
    – user
    Jan 8, 2013 at 20:03
  • 1
    And depending on context, "most people" definitely do not use MySQL. For example, MySQL is reasonably common in Linux environments, but virtually unheard of in Windows hosting.
    – user
    Jan 8, 2013 at 20:06

One could use a simple SQLLite-browser with an IMPORT feature. This may be the easiest way if you're not into learning SQL.

  • 3
    This answer is underrated. It is a more easy solution than installing a full-fledged SQL Server application and connect to the server from the client.
    – yoyo_fun
    Dec 24, 2016 at 18:52

The .sql file contains the SQL statements required to rebuild the database. The person who sent it to you has dumped either a portion or the full database to the .sql file.

Because you're asking this question, I think it's better if you get that person to export the data you want to view in a CSV (comma separated values) file so you can view in in tables in Excel.

The .sql file is good if you are a database admin yourself. You go to your database server and import the .sql file, and the database server will recreate the database as described in the .sql file sent to you.

You don't need a WAMP server, you only need the database server to import the SQL script. However, you'll save yourself a LOT of trouble by just asking the person to send you a CSV file, not an SQL dump.


If your SQL file has schema definition i.e. create table blah and also insert statements to add data, you could use sqlfiddle: http://sqlfiddle.com/


I just want to say thanks, almost a year later, to Ariane who's answer quickly resolved the same issue on my end. I was in an environment without internet and needed to convert a client's MySQL database table to .xls for a third party so I pulled the .SQL file from the database.

Since I know nothing of MySQL it was quite a chore for me to learn how to

mysql -uroot -ppassword

> show databases;
> use thisdatabase;
> show tables; 

then use mysqldump

/usr/bin/mysqldump -uroot -ppassword thisdatabase -e "thistable" > thistable.sql

But after reading the post above that suggested "to install and run WAMPserver ( http://www.wampserver.com/en/ ) , then to type "localhost" in your Web browser's address bar. Then you click phpMyAdmin, and click import to, well, import the file." It really was that simple.

After importing it into the installation created 'test' database, I was easily able to export an .xls file for opening in Excel.

However it should be noted that using the option "CSV for Excel" did not product a CSV format that Excel could use without making a mess but choosing basic "CSV" with options "Remove carriage return/line feed characters within columns" and "Put columns names in the first row" produced the perfect file.

I realize this is a year old but perhaps someone like me will come along in the future and this will help!


Can't speak to opening it as a table, but if you are interested in reviewing the SQL code you can simply change the extension to .txt and open with a text editor.

  • 2
    This is not an answer to the question. Interact with the site enough and you'll get the reputation sufficient to comment. Dec 20, 2016 at 17:15
  • @John He already said that he can open it with a text editor so this is not his problem. he can alraedy vrei the contents of the file.
    – yoyo_fun
    Dec 24, 2016 at 18:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .