How to open sql file as a table?

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?


Solution 1:

.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.

http://www.digitalcoding.com/free-software/database/SQL-Preview-and-Export-Tool.html

Solution 2:

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