The SQL open standard for database query languages provides an interactive shell for typing queries to the database directly. It can also be used to load a text file with a set of queries to the database. The combination of the two methods allows for quick and dirty queries, with a little trial and error to get the right results, followed by saving useful queries for later operations.
Log into your database interface; on a Windows machine, this means authenticating your user account to the SQL server. On a UNIX SQL implementation, like MySQL, this means logging into the command line interface, and then typing "mysql database_name." In either case, you'll be logged into the interactive SQL parser tool.
Type in the following command to run a database query:
SELECT '<query_ operation>' AS ' ';
Replace <query_operation> with your desired query.
Type in the following command to have the SQL database run queries contained in a text file:
mysql database_name < file_name
where the database_name and file_name parameters are replaced with the name of the actual database and file name to be loaded.
Type in the following command to have the SQL database run queries from a text file and output the results to a different text file:
mysql database_name < file_name > output_file.txt
Tips & Warnings
- If you do not know what you are doing, you can actually do harm to your database with an SQL database query. If you are unsure, it is always a good idea to make a backup copy of the database before running your queries.
How to Create a SQL Query in Microsoft Access
SQL queries use Structured Query Language (SQL), a standard scripting language, to make requests from databases. You can use four types of...
How to Execute an SQL File From a Command Line
SQL is a computer language used with relational databases. When SQL commands are complex or when several need to be run in...
How to Run SQL Query in Access
In Microsoft Access, you can add, delete, search or extract information using the Structured Query Language (SQL). There are three main types...