mysql
— The MySQL Command-Line Tool
275
You can enable this feature interactively with the
tee
command. Without a parameter, the previous
file is used. The
tee
file can be disabled with the
notee
command. Executing
tee
again re-enables
logging.
•
use db_name
,
\u db_name
Use
db_name
as the default database.
•
warnings
,
\W
Enable display of warnings after each statement (if there are any). This command was added in
MySQL 5.0.6.
Here are a few tips about the
pager
command:
• You can use it to write to a file and the results go only to the file:
mysql>
pager cat > /tmp/log.txt
You can also pass any options for the program that you want to use as your pager:
mysql>
pager less -n -i -S
• In the preceding example, note the
-S
option. You may find it very useful for browsing wide query
results. Sometimes a very wide result set is difficult to read on the screen. The
-S
option to
less
can make the result set much more readable because you can scroll it horizontally using the left-
arrow and right-arrow keys. You can also use
-S
interactively within
less
to switch the horizontal-
browse mode on and off. For more information, read the
less
manual page:
shell>
man less
• The
-F
and
-X
options may be used with
less
to cause it to exit if output fits on one screen, which
is convenient when no scrolling is necessary:
mysql>
pager less -n -i -S -F -X
• You can specify very complex pager commands for handling query output:
mysql>
pager cat | tee /dr1/tmp/res.txt \
| tee /dr2/tmp/res2.txt | less -n -i -S
In this example, the command would send query results to two files in two different directories on two
different file systems mounted on
/dr1
and
/dr2
, yet still display the results onscreen using
less
.
You can also combine the
tee
and
pager
functions. Have a
tee
file enabled and
pager
set to
less
,
and you are able to browse the results using the
less
program and still have everything appended
into a file the same time. The difference between the Unix
tee
used with the
pager
command and
the
mysql
built-in
tee
command is that the built-in
tee
works even if you do not have the Unix
tee
available. The built-in
tee
also logs everything that is printed on the screen, whereas the Unix
tee
used with
pager
does not log quite that much. Additionally,
tee
file logging can be turned on and
off interactively from within
mysql
. This is useful when you want to log some queries to a file, but not
others.
The
prompt
command reconfigures the default
mysql>
prompt. The string for defining the prompt can
contain the following special sequences.
Option
Description
\c
A counter that increments for each statement you issue
\D
The full current date
\d
The default database
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...