When you start using MySQL, you use a command prompt to enter the SQL statement. The statements can be quite lengthy, and a pain to modify. The simplest way of using MySQL is to use files containing the SQL statements to perform. For example, if you want to create a table called, search, you could create a file called called, createSearchTable.sql and load this file from the command prompt rather than type in a lengthy SQL statement to create the table.
Loading SQL Statements from a File
The SOURCE
command is used to load the file from the command prompt.
mysql> SOURCE createSearchTable.sql
The sequence \. is a shorcut name for
the SOURCE
statement. The following does exactly the same thing as the above
SOURCE
statement.
mysql> \. createSearchTable.sql
Logging Output
The TEE
statement may be used to log output from your SQL statements to a
text file. The following command copies all output to the file log.txt
so you
can examine the results of running your queries.
mysql> TEE log.txt
You can turn off loging using the NOTEE statement.
mysql> NOTEE
Comments