3
.\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
5
.\" Manual: Drizzle Database System
8
.TH "\fBDRIZZLE\fR" "1" "05/23/2009" "Drizzle" "Drizzle Database System"
9
.\" disable hyphenation
11
.\" disable justification (adjust text to left margin only)
14
drizzle \- the Drizzle command\-line tool
17
\fBdrizzle [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIdb_name\fR\fR
21
is a simple SQL shell (with GNU
23
capabilities). It supports interactive and non\-interactive use. When used interactively, query results are presented in an ASCII\-table format. When used non\-interactively (for example, as a filter), the result is presented in tab\-separated format. The output format can be changed using command options.
25
If you have problems due to insufficient memory for large result sets, use the
29
to retrieve results from the server a row at a time rather than retrieving the entire result set and buffering it in memory before displaying it.
33
is very easy. Invoke it from the prompt of your command interpreter as follows:
37
shell> \fBdrizzle \fR\fB\fIdb_name\fR\fR
45
shell> \fBdrizzle \-\-user=\fR\fB\fIuser_name\fR\fR\fB \-\-password=\fR\fB\fIyour_password\fR\fR\fB \fR\fB\fIdb_name\fR\fR
49
Then type an SQL statement, end it with
55
Typing Control\-C causes
57
to attempt to kill the current statement. If this cannot be done, or Control\-C is typed again before the statement is killed,
61
You can execute SQL statements in a script file (batch file) like this:
65
shell> \fBdrizzle \fR\fB\fIdb_name\fR\fR\fB < \fR\fB\fIscript.sql\fR\fR\fB > \fR\fB\fIoutput.tab\fR\fR
68
.SH "\fBDRIZZLE\fR OPTIONS"
71
supports the options in the following list.
77
Display a help message and exit.
80
\fB\-\-auto\-rehash\fR
82
Enable automatic rehashing. This option is on by default, which enables database, table, and column name completion. Use
83
\fB\-\-disable\-auto\-rehash\fR
84
to disable rehashing. That causes
86
to start faster, but you must issue the
88
command if you want to use name completion.
90
To complete a name, enter the first part and press Tab. If the name is unambiguous,
92
completes it. Otherwise, you can press Tab again to see the possible names that begin with what you have typed so far. Completion does not occur if there is no default database.
95
\fB\-\-auto\-vertical\-output\fR
97
Causes result sets to be displayed vertically if they are too wide for the current window, and using normal tabular format otherwise. (This applies to statements terminated by
100
\\G.) This option was added in Drizzle 6.0.4.
106
Print results using tab as the column separator, with each row on a new line. With this option,
108
does not use the history file.
110
Batch mode results in non\-tabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the
115
\fB\-\-character\-sets\-dir=\fR\fB\fIpath\fR\fR
117
The directory where character sets are installed. See
118
Section\ 9.2, \(lqThe Character Set Used for Data and Sorting\(rq.
121
\fB\-\-column\-names\fR
123
Write column names in results.
126
\fB\-\-column\-type\-info\fR,
129
Display result set metadata.
135
Whether to preserve comments in statements sent to the server. The default is \-\-skip\-comments (discard comments), enable with \-\-comments (preserve comments). This option was added in Drizzle 6.0.4.
141
Compress all information sent between the client and the server if both support compression.
144
\fB\-\-database=\fR\fB\fIdb_name\fR\fR,
145
\fB\-D \fR\fB\fIdb_name\fR\fR
147
The database to use. This is useful primarily in an option file.
150
\fB\-\-debug\-check\fR
152
Print some debugging information when the program exits.
155
\fB\-\-debug\-info\fR,
158
Print debugging information and memory and CPU usage statistics when the program exits.
161
\fB\-\-delimiter=\fR\fB\fIstr\fR\fR
163
Set the statement delimiter. The default is the semicolon character (\(lq;\(rq).
166
\fB\-\-disable\-named\-commands\fR
168
Disable named commands. Use the
170
form only, or use named commands only at the beginning of a line ending with a semicolon (\(lq;\(rq).
172
starts with this option
174
by default. However, even with this option, long\-format commands still work from the first line. See
175
the section called \(lq\fBMYSQL\fR COMMANDS\(rq.
178
\fB\-\-execute=\fR\fB\fIstatement\fR\fR,
179
\fB\-e \fR\fB\fIstatement\fR\fR
181
Execute the statement and quit. The default output format is like that produced with
183
Section\ 4.2.3.1, \(lqUsing Options on the Command Line\(rq, for some examples.
189
Continue even if an SQL error occurs.
192
\fB\-\-host=\fR\fB\fIhost_name\fR\fR,
193
\fB\-h \fR\fB\fIhost_name\fR\fR
195
Connect to the Drizzle server on the given host.
204
\fB\-\-ignore\-spaces\fR,
207
Ignore spaces after function names. The effect of this is described in the discussion for the
210
Section\ 5.1.7, \(lqServer SQL Modes\(rq).
213
\fB\-\-line\-numbers\fR
215
Write line numbers for errors. Disable this with
216
\fB\-\-skip\-line\-numbers\fR.
219
\fB\-\-local\-infile[={0|1}]\fR
224
LOAD DATA INFILE. With no value, the option enables
225
LOCAL. The option may be given as
226
\fB\-\-local\-infile=0\fR
228
\fB\-\-local\-infile=1\fR
229
to explicitly disable or enable
232
has no effect if the server does not also support it.
235
\fB\-\-named\-commands\fR,
240
commands. Long\-format commands are allowed, not just short\-format commands. For example,
244
both are recognized. Use
245
\fB\-\-skip\-named\-commands\fR
246
to disable named commands. See
247
the section called \(lq\fBMYSQL\fR COMMANDS\(rq.
250
\fB\-\-no\-auto\-rehash\fR,
254
\fB\-skip\-auto\-rehash\fR. Use
255
\fB\-\-disable\-auto\-rehash\fR
256
instead. See the description for
257
\fB\-\-auto\-rehash\fR.
263
Do not beep when errors occur.
266
\fB\-\-no\-named\-commands\fR,
270
\fB\-\-disable\-named\-commands\fR
277
\fB\-\-skip\-pager\fR. See the
284
Do not copy output to a file.
285
the section called \(lq\fBMYSQL\fR COMMANDS\(rq, discusses tee files further.
288
\fB\-\-one\-database\fR,
291
Ignore statements except those for the default database named on the command line. This is useful for skipping updates to other databases in the binary log.
294
\fB\-\-pager[=\fR\fB\fIcommand\fR\fR\fB]\fR
296
Use the given command for paging query output. If the command is omitted, the default pager is the value of your
298
environment variable. Valid pagers are
301
\fBcat [> filename]\fR, and so forth. This option works only on Unix. It does not work in batch mode. To disable paging, use
302
\fB\-\-skip\-pager\fR.
303
the section called \(lq\fBMYSQL\fR COMMANDS\(rq, discusses output paging further.
306
\fB\-\-password[=\fR\fB\fIpassword\fR\fR\fB]\fR,
307
\fB\-P[\fR\fB\fIpassword\fR\fR\fB]\fR
309
The password to use when connecting to the server. If you use the short option form (\fB\-p\fR), you
311
have a space between the option and the password. If you omit the
317
option on the command line, you are prompted for one.
319
Specifying a password on the command line should be considered insecure. See
320
Section\ 5.5.6.2, \(lqEnd\-User Guidelines for Password Security\(rq.
326
On Windows, connect to the server via a named pipe. This option applies only for connections to a local server, and only if the server supports named\-pipe connections.
329
\fB\-\-port=\fR\fB\fIport_num\fR\fR,
330
\fB\-p \fR\fB\fIport_num\fR\fR
332
The TCP/IP port number to use for the connection.
335
\fB\-\-prompt=\fR\fB\fIformat_str\fR\fR
337
Set the prompt to the specified format. The default is
338
drizzle>. The special sequences that the prompt can contain are described in
339
the section called \(lq\fBMYSQL\fR COMMANDS\(rq.
342
\fB\-\-protocol={TCP|SOCKET|PIPE|MEMORY}\fR
344
The connection protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want. For details on the allowable values, see
345
Section\ 4.2.2, \(lqConnecting to the Drizzle Server\(rq.
351
Do not cache each query result, print each row as it is received. This may slow down the server if the output is suspended. With this option,
353
does not use the history file.
359
For tabular output, the
361
around columns enables one column value to be distinguished from another. For non\-tabular output (such as is produced in batch mode or when the
365
option is given), special characters are escaped in the output so they can be identified easily. Newline, tab,
366
NUL, and backslash are written as
372
option disables this character escaping.
374
The following example demonstrates tabular versus non\-tabular output and the use of raw mode to disable escaping:
379
drizzle> SELECT CHAR(92);
380
+\-\-\-\-\-\-\-\-\-\-+
382
+\-\-\-\-\-\-\-\-\-\-+
384
+\-\-\-\-\-\-\-\-\-\-+
386
drizzle> SELECT CHAR(92);
389
% \fBdrizzle \-s \-r\fR
390
drizzle> SELECT CHAR(92);
399
If the connection to the server is lost, automatically try to reconnect. A single reconnect attempt is made each time the connection is lost. To suppress reconnection behavior, use
400
\fB\-\-skip\-reconnect\fR.
403
\fB\-\-safe\-updates\fR,
404
\fB\-\-i\-am\-a\-dummy\fR,
411
statements that specify which rows to modify by using key values. If you have set this option in an option file, you can override it by using
412
\fB\-\-safe\-updates\fR
413
on the command line. See
414
the section called \(lq\fBMYSQL\fR TIPS\(rq, for more information about this option.
417
\fB\-\-secure\-auth\fR
419
Do not send passwords to the server in old (pre\-4.1.1) format. This prevents connections except for servers that use the newer password format.
422
\fB\-\-show\-warnings\fR
424
Cause warnings to be shown after each statement if there are any. This option applies to interactive and batch mode.
427
\fB\-\-sigint\-ignore\fR
431
signals (typically the result of typing Control\-C).
437
Silent mode. Produce less output. This option can be given multiple times to produce less and less output.
439
This option results in non\-tabular output format and escaping of special characters. Escaping may be disabled by using raw mode; see the description for the
444
\fB\-\-skip\-column\-names\fR,
447
Do not write column names in results. The short format,
449
is deprecated, use the long format instead.
452
\fB\-\-skip\-line\-numbers\fR,
455
Do not write line numbers for errors. Useful when you want to compare result files that include error messages. The short format,
457
is deprecated, use the long format instead.
460
\fB\-\-socket=\fR\fB\fIpath\fR\fR,
461
\fB\-S \fR\fB\fIpath\fR\fR
464
localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.
469
Options that begin with
471
specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See
472
Section\ 5.5.7.3, \(lqSSL Command Options\(rq.
478
Display output in table format. This is the default for interactive use, but can be used to produce table output in batch mode.
481
\fB\-\-tee=\fR\fB\fIfile_name\fR\fR
483
Append a copy of output to the given file. This option does not work in batch mode.
484
the section called \(lq\fBMYSQL\fR COMMANDS\(rq, discusses tee files further.
487
\fB\-\-unbuffered\fR,
490
Flush the buffer after each query.
493
\fB\-\-user=\fR\fB\fIuser_name\fR\fR,
494
\fB\-u \fR\fB\fIuser_name\fR\fR
496
The Drizzle user name to use when connecting to the server.
502
Verbose mode. Produce more output about what the program does. This option can be given multiple times to produce more and more output. (For example,
504
produces table output format even in batch mode.)
510
Display version information and exit.
516
Print query output rows vertically (one line per column value). Without this option, you can specify vertical output for individual statements by terminating them with
523
If the connection cannot be established, wait and retry instead of aborting.
526
You can also set the following variables by using
527
\fB\-\-\fR\fB\fIvar_name\fR\fR\fB=\fR\fB\fIvalue\fR\fR. The
528
\fB\-\-set\-variable\fR
529
format is deprecated.
534
The number of seconds before connection timeout. (Default value is
540
The maximum packet length to send to or receive from the server. (Default value is 16MB.)
545
The automatic limit for rows in a join when using
546
\fB\-\-safe\-updates\fR. (Default value is 1,000,000.)
551
The buffer size for TCP/IP and socket communication. (Default value is 16KB.)
556
The automatic limit for
558
statements when using
559
\fB\-\-safe\-updates\fR. (Default value is 1,000.)
565
client writes a record of executed statements to a history file. By default, this file is named
567
and is created in your home directory. To specify a different file, set the value of the
569
environment variable.
573
should be protected with a restrictive access mode because sensitive information might be written to it, such as the text of SQL statements that contain passwords. See
574
Section\ 5.5.6.2, \(lqEnd\-User Guidelines for Password Security\(rq.
576
If you do not want to maintain a history file, first remove
578
if it exists, and then use either of the following techniques:
584
\fI/dev/null\fR. To cause this setting to take effect each time you log in, put the setting in one of your shell's startup files.
589
as a symbolic link to
594
shell> \fBln \-s /dev/null $HOME/.mysql_history\fR
597
You need do this only once.
598
.SH "\fBMYSQL\fR COMMANDS"
601
sends each SQL statement that you issue to the server to be executed. There is also a set of commands that
603
itself interprets. For a list of these commands, type
614
List of all Drizzle commands:
615
Note that all text commands must be first on line and end with ';'
616
? (\\?) Synonym for `help'.
617
clear (\\c) Clear command.
618
connect (\\r) Reconnect to the server. Optional arguments are db and host.
619
delimiter (\\d) Set statement delimiter.
620
edit (\\e) Edit command with $EDITOR.
621
ego (\\G) Send command to mysql server, display result vertically.
622
exit (\\q) Exit mysql. Same as quit.
623
go (\\g) Send command to mysql server.
624
help (\\h) Display this help.
625
nopager (\\n) Disable pager, print to stdout.
626
notee (\\t) Don't write into outfile.
627
pager (\\P) Set PAGER [to_pager]. Print the query results via PAGER.
628
print (\\p) Print current command.
629
prompt (\\R) Change your mysql prompt.
630
quit (\\q) Quit mysql.
631
rehash (\\#) Rebuild completion hash.
632
source (\\.) Execute an SQL script file. Takes a file name as an argument.
633
status (\\s) Get status information from the server.
634
system (\\!) Execute a system shell command.
635
tee (\\T) Set outfile [to_outfile]. Append everything into given
637
use (\\u) Use another database. Takes database name as argument.
638
charset (\\C) Switch to another charset. Might be needed for processing
639
binlog with multi\-byte charsets.
640
warnings (\\W) Show warnings after every statement.
641
nowarning (\\w) Don't show warnings after every statement.
642
For server side help, type 'help contents'
646
Each command has both a long and short form. The long form is not case sensitive; the short form is. The long form can be followed by an optional semicolon terminator, but the short form should not.
648
The use of short\-form commands within multi\-line
650
comments is not supported.
653
\fBhelp [\fR\fB\fIarg\fR\fR\fB]\fR,
654
\fB\\h [\fR\fB\fIarg\fR\fR\fB]\fR,
655
\fB\\? [\fR\fB\fIarg\fR\fR\fB]\fR,
656
\fB? [\fR\fB\fIarg\fR\fR\fB]\fR
658
Displays a help message listing the available
662
If you provide an argument to the
666
uses it as a search string to access server\-side help from the contents of the Drizzle Reference Manual. For more information, see
667
the section called \(lq\fBMYSQL\fR SERVER\-SIDE HELP\(rq.
670
\fBcharset \fR\fB\fIcharset_name\fR\fR,
671
\fB\\C \fR\fB\fIcharset_name\fR\fR
675
command changes the default character set and issues a
677
statement. This enables the character set to remain synchronized on the client and server if
679
is run with auto\-reconnect enabled (which is not recommended), because the specified character set is used for reconnects.
685
Clears the current input. Use this if you change your mind about executing the statement that you are entering.
688
\fBconnect [\fR\fB\fIdb_name\fR\fR\fB \fR\fB\fIhost_name\fR\fR\fB]]\fR,
689
\fB\\r [\fR\fB\fIdb_name\fR\fR\fB \fR\fB\fIhost_name\fR\fR\fB]]\fR
691
Reconnects to the server. The optional database name and host name arguments may be given to specify the default database or the host where the server is running. If omitted, the current values are used.
694
\fBdelimiter \fR\fB\fIstr\fR\fR,
695
\fB\\d \fR\fB\fIstr\fR\fR
699
command changes the string that
701
interprets as the separator between SQL statements. The default is the semicolon character (\(lq;\(rq).
703
The delimiter can be specified as an unquoted or quoted argument. Quoting can be done with either single quote (') or douple quote (") characters. To include a quote within a quoted string, either quote the string with the other quote character or escape the quote with a backslash (\(lq\\\(rq) character. Backslash should be avoided outside of quoted strings because it is the escape character for Drizzle. For an unquoted argument, the delmiter is read up to the first space or end of line. For a quoted argument, the delimiter is read up to the matching quote on the line.
705
When the delimiter recognized by
707
is set to something other than the default of
708
\(lq;\(rq, instances of that character are sent to the server without interpretation. However, the server itself still interprets
710
as a statement delimiter and processes statements accordingly. This behavior on the server side comes into play for multiple\-statement execution (see
711
Section\ 20.10.12, \(lqC API Support for Multiple Statement Execution\(rq), and for parsing the body of stored procedures and functions, triggers, and events (see
712
Section\ 18.1, \(lqDefining Stored Programs\(rq).
718
Edits the current input statement.
720
checks the values of the
724
environment variables to determine which editor to use. The default editor is
726
if neither variable is set.
730
command works only in Unix.
736
Sends the current statement to the server to be executed and displays the result using vertical format.
749
Sends the current statement to the server to be executed.
755
Disables output paging. See the description for
760
command works only in Unix.
766
Disables output copying to the tee file. See the description for
773
Enables display of warnings after each statement.
776
\fBpager [\fR\fB\fIcommand\fR\fR\fB]\fR,
777
\fB\\P [\fR\fB\fIcommand\fR\fR\fB]\fR
781
option when you invoke
782
\fBmysql\fR, it is possible to browse or search query results in interactive mode with Unix programs such as
784
\fBmore\fR, or any other similar program. If you specify no value for the option,
786
checks the value of the
788
environment variable and sets the pager to that.
790
Output paging can be enabled interactively with the
792
command and disabled with
793
\fBnopager\fR. The command takes an optional argument; if given, the paging program is set to that. With no argument, the pager is set to the pager that was set on the command line, or
795
if no pager was specified.
797
Output paging works only in Unix because it uses the
799
function, which does not exist on Windows. For Windows, the
801
option can be used instead to save query output, although it is not as convenient as
803
for browsing output in some situations.
809
Prints the current input statement without executing it.
812
\fBprompt [\fR\fB\fIstr\fR\fR\fB]\fR,
813
\fB\\R [\fR\fB\fIstr\fR\fR\fB]\fR
817
prompt to the given string. The special character sequences that can be used in the prompt are described later in this section.
821
command with no argument,
823
resets the prompt to the default of
837
Rebuilds the completion hash that enables database, table, and column name completion while you are entering statements. (See the description for the
838
\fB\-\-auto\-rehash\fR
842
\fBsource \fR\fB\fIfile_name\fR\fR,
843
\fB\\. \fR\fB\fIfile_name\fR\fR
845
Reads the named file and executes the statements contained therein. On Windows, you can specify path name separators as
856
command provides some information about the connection and the server you are using. If you are running in
857
\fB\-\-safe\-updates\fR
860
also prints the values for the
862
variables that affect your queries.
865
\fBsystem \fR\fB\fIcommand\fR\fR,
866
\fB\\! \fR\fB\fIcommand\fR\fR
868
Executes the given command using your default command interpreter.
872
command works only in Unix.
875
\fBtee [\fR\fB\fIfile_name\fR\fR\fB]\fR,
876
\fB\\T [\fR\fB\fIfile_name\fR\fR\fB]\fR
880
option when you invoke
881
\fBmysql\fR, you can log statements and their output. All the data displayed on the screen is appended into a given file. This can be very useful for debugging purposes also.
883
flushes results to the file after each statement, just before it prints its next prompt.
885
You can enable this feature interactively with the
887
command. Without a parameter, the previous file is used. The
889
file can be disabled with the
893
again re\-enables logging.
896
\fBuse \fR\fB\fIdb_name\fR\fR,
897
\fB\\u \fR\fB\fIdb_name\fR\fR
901
as the default database.
907
Enables display of warnings after each statement (if there are any).
911
Here are a few tips about the
916
You can use it to write to a file and the results go only to the file:
920
mysql> \fBpager cat > /tmp/log.txt\fR
923
You can also pass any options for the program that you want to use as your pager:
927
mysql> \fBpager less \-n \-i \-S\fR
932
In the preceding example, note the
934
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
938
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
942
to switch the horizontal\-browse mode on and off. For more information, read the
948
shell> \fBman less\fR
957
options may be used with
959
to cause it to exit if output fits on one screen, which is convenient when no scrolling is necessary:
963
mysql> \fBpager less \-n \-i \-S \-F \-X\fR
968
You can specify very complex pager commands for handling query output:
972
mysql> \fBpager cat | tee /dr1/tmp/res.txt \\\fR
973
\fB| tee /dr2/tmp/res2.txt | less \-n \-i \-S\fR
976
In this example, the command would send query results to two files in two different directories on two different file systems mounted on
979
\fI/dr2\fR, yet still display the results onscreen via
984
You can also combine the
993
\fBless\fR, and you are able to browse the results using the
995
program and still have everything appended into a file the same time. The difference between the Unix
1003
command is that the built\-in
1005
works even if you do not have the Unix
1007
available. The built\-in
1009
also logs everything that is printed on the screen, whereas the Unix
1013
does not log quite that much. Additionally,
1015
file logging can be turned on and off interactively from within
1016
\fBmysql\fR. This is useful when you want to log some queries to a file, but not others.
1020
command reconfigures the default
1022
prompt. The string for defining the prompt can contain the following special sequences.
1062
The current month in numeric format
1072
The current TCP/IP port or socket file
1077
The current time, in 24\-hour military time (0\-23)
1082
The current time, standard 12\-hour time (1\-12)
1092
Seconds of the current time
1103
\fIuser_name\fR@\fIhost_name\fR
1114
A counter that increments for each statement you issue
1124
The current day of the week in three\-letter format (Mon, Tue, \&...)
1129
The current year, four digits
1134
The current year, two digits
1144
A space (a space follows the backslash)
1159
A literal \(lq\\\(rq backslash character
1165
\(lq\fIx\fR\(rq not listed
1171
The full current date
1176
The default database
1186
The current delimiter
1191
Minutes of the current time
1201
The current month in three\-letter format (Jan, Feb, \&...)
1206
You can set the prompt in several ways:
1209
\fIUse an environment variable.\fR
1212
environment variable to a prompt string. For example:
1216
shell> \fBexport MYSQL_PS1="(\\u@\\h) [\\d]> "\fR
1221
\fIUse a command\-line option.\fR
1224
option on the command line to
1225
\fBmysql\fR. For example:
1229
shell> \fBmysql \-\-prompt="(\\u@\\h) [\\d]> "\fR
1230
(user@host) [database]>
1235
\fIUse an option file.\fR
1240
group of any Drizzle option file, such as
1244
file in your home directory. For example:
1249
prompt=(\\\\u@\\\\h) [\\\\d]>\\\\_
1252
In this example, note that the backslashes are doubled. If you set the prompt using the
1254
option in an option file, it is advisable to double the backslashes when using the special prompt options. There is some overlap in the set of allowable prompt options and the set of special escape sequences that are recognized in option files. (These sequences are listed in
1255
Section\ 4.2.3.2, \(lqUsing Option Files\(rq.) The overlap may cause you problems if you use single backslashes. For example,
1257
is interpreted as a space rather than as the current seconds value. The following example shows how to define a prompt within an option file to include the current time in
1264
prompt="\\\\r:\\\\m:\\\\s> "
1269
\fISet the prompt interactively.\fR
1270
You can change your prompt interactively by using the
1273
\\R) command. For example:
1277
mysql> \fBprompt (\\u@\\h) [\\d]>\\_\fR
1278
PROMPT set to '(\\u@\\h) [\\d]>\\_'
1279
(\fIuser\fR@\fIhost\fR) [\fIdatabase\fR]>
1280
(\fIuser\fR@\fIhost\fR) [\fIdatabase\fR]> prompt
1281
Returning to default PROMPT of mysql>
1285
.SH "\fBMYSQL\fR SERVER\-SIDE HELP"
1289
mysql> \fBhelp \fR\fB\fIsearch_string\fR\fR
1293
If you provide an argument to the
1297
uses it as a search string to access server\-side help from the contents of the Drizzle Reference Manual. The proper operation of this command requires that the help tables in the
1299
database be initialized with help topic information (see
1300
Section\ 5.1.8, \(lqServer\-Side Help\(rq).
1302
If there is no match for the search string, the search fails:
1306
mysql> \fBhelp me\fR
1308
Please try to run 'help contents' for a list of all accessible topics
1314
to see a list of the help categories:
1318
mysql> \fBhelp contents\fR
1319
You asked for help about help category: "Contents"
1320
For more information, type 'help <item>', where <item> is one of the
1321
following categories:
1328
Functions and Modifiers for Use with GROUP BY
1340
If the search string matches multiple items,
1342
shows a list of matching topics:
1346
mysql> \fBhelp logs\fR
1347
Many help items for your request exist.
1348
To make a more specific request, please type 'help <item>',
1349
where <item> is one of the following topics:
1357
Use a topic as the search string to see the help entry for that topic:
1361
mysql> \fBhelp show binary logs\fR
1362
Name: 'SHOW BINARY LOGS'
1367
Lists the binary log files on the server. This statement is used as
1368
part of the procedure described in [purge\-binary\-logs], that shows how
1369
to determine which logs can be purged.
1370
mysql> SHOW BINARY LOGS;
1371
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
1372
| Log_name | File_size |
1373
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
1374
| binlog.000015 | 724935 |
1375
| binlog.000016 | 733481 |
1376
+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-+
1379
.SH "EXECUTING SQL STATEMENTS FROM A TEXT FILE"
1383
client typically is used interactively, like this:
1387
shell> \fBmysql \fR\fB\fIdb_name\fR\fR
1391
However, it is also possible to put your SQL statements in a file and then tell
1393
to read its input from that file. To do so, create a text file
1395
that contains the statements you wish to execute. Then invoke
1401
shell> \fBmysql \fR\fB\fIdb_name\fR\fR\fB < \fR\fB\fItext_file\fR\fR
1407
statement as the first statement in the file, it is unnecessary to specify the database name on the command line:
1411
shell> \fBmysql < text_file\fR
1415
If you are already running
1416
\fBmysql\fR, you can execute an SQL script file using the
1424
mysql> \fBsource \fR\fB\fIfile_name\fR\fR
1425
mysql> \fB\\. \fR\fB\fIfile_name\fR\fR
1429
Sometimes you may want your script to display progress information to the user. For this you can insert statements like this:
1433
SELECT '<info_to_display>' AS ' ';
1437
The statement shown outputs
1440
As of Drizzle 6.0.4,
1442
ignores Unicode byte order mark (BOM) characters at the beginning of input files. Previously, it read them and sent them to the server, resulting in a syntax error. Presence of a BOM does not cause
1444
to change its default character set. To do that, invoke
1446
with an option such as
1447
\fB\-\-default\-character\-set=utf8\fR.
1449
For more information about batch mode, see
1450
Section\ 3.5, \(lqUsing \fBmysql\fR in Batch Mode\(rq.
1451
.SH "\fBMYSQL\fR TIPS"
1453
This section describes some techniques that can help you use
1456
.SS "Displaying Query Results Vertically"
1458
Some query results are much more readable when displayed vertically, instead of in the usual horizontal table format. Queries can be displayed vertically by terminating the query with \\G instead of a semicolon. For example, longer text values that include newlines often are much easier to read with vertical output:
1462
mysql> \fBSELECT * FROM mails WHERE LENGTH(txt) < 300 LIMIT 300,1\\G\fR
1463
*************************** 1. row ***************************
1465
date: 2000\-03\-01 23:29:50
1468
reply: monty@no.spam.com
1469
mail_to: "Thimble Smith" <tim@no.spam.com>
1471
txt: >>>>> "Thimble" == Thimble Smith writes:
1472
Thimble> Hi. I think this is a good idea. Is anyone familiar
1473
Thimble> with UTF\-8 or Unicode? Otherwise, I'll put this on my
1474
Thimble> TODO list and see what happens.
1475
Yes, please do that.
1478
file: inbox\-jani\-1
1480
1 row in set (0.09 sec)
1483
.\" end of SS subsection "Displaying Query Results Vertically"
1484
.SS "Using the \-\-safe\-updates Option"
1486
For beginners, a useful startup option is
1487
\fB\-\-safe\-updates\fR
1489
\fB\-\-i\-am\-a\-dummy\fR, which has the same effect). It is helpful for cases when you might have issued a
1490
DELETE FROM \fItbl_name\fR
1491
statement but forgotten the
1493
clause. Normally, such a statement deletes all rows from the table. With
1494
\fB\-\-safe\-updates\fR, you can delete rows only by specifying the key values that identify them. This helps prevent accidents.
1497
\fB\-\-safe\-updates\fR
1500
issues the following statement when it connects to the Drizzle server:
1504
SET sql_safe_updates=1, sql_select_limit=1000, sql_max_join_size=1000000;
1509
Section\ 5.1.4, \(lqSession System Variables\(rq.
1513
statement has the following effects:
1516
You are not allowed to execute an
1520
statement unless you specify a key constraint in the
1524
clause (or both). For example:
1528
UPDATE \fItbl_name\fR SET \fInot_key_column\fR=\fIval\fR WHERE \fIkey_column\fR=\fIval\fR;
1529
UPDATE \fItbl_name\fR SET \fInot_key_column\fR=\fIval\fR LIMIT 1;
1534
The server limits all large
1536
results to 1,000 rows unless the statement includes a
1541
The server aborts multiple\-table
1543
statements that probably need to examine more than 1,000,000 row combinations.
1547
To specify limits different from 1,000 and 1,000,000, you can override the defaults by using the
1548
\fB\-\-select_limit\fR
1550
\fB\-\-max_join_size\fR
1555
shell> \fBmysql \-\-safe\-updates \-\-select_limit=500 \-\-max_join_size=10000\fR
1558
.\" end of SS subsection "Using the \-\-safe\-updates Option"
1559
.SS "Disabling mysql Auto\-Reconnect"
1563
client loses its connection to the server while sending a statement, it immediately and automatically tries to reconnect once to the server and send the statement again. However, even if
1565
succeeds in reconnecting, your first connection has ended and all your previous session objects and settings are lost: temporary tables, the autocommit mode, and user\-defined and session variables. Also, any current transaction rolls back. This behavior may be dangerous for you, as in the following example where the server was shut down and restarted between the first and second statements without you knowing it:
1569
mysql> \fBSET @a=1;\fR
1570
Query OK, 0 rows affected (0.05 sec)
1571
mysql> \fBINSERT INTO t VALUES(@a);\fR
1572
ERROR 2006: Drizzle server has gone away
1573
No connection. Trying to reconnect...
1575
Current database: test
1576
Query OK, 1 row affected (1.30 sec)
1577
mysql> \fBSELECT * FROM t;\fR
1583
1 row in set (0.05 sec)
1589
user variable has been lost with the connection, and after the reconnection it is undefined. If it is important to have
1591
terminate with an error if the connection has been lost, you can start the
1594
\fB\-\-skip\-reconnect\fR
1597
For more information about auto\-reconnect and its effect on state information when a reconnection occurs, see
1598
Section\ 20.10.11, \(lqControlling Automatic Reconnection Behavior\(rq.
1599
.\" end of SS subsection "Disabling mysql Auto\-Reconnect"
1602
Copyright 2007\-2008 MySQL AB, 2009 Sun Microsystems, Inc.
1604
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
1606
This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
1608
You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110\-1301 USA or see http://www.gnu.org/licenses/.
1612
\%http://bugs.mysql.com/25946
1614
For more information, please refer to the Drizzle Reference Manual,
1615
which may already be installed locally and which is also available
1616
online at http://dev.mysql.com/doc/.
1618
Sun Microsystems, Inc. (http://www.mysql.com/).