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?
.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.
|show 1 more comment|
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.