(We had to use the @code{:=} syntax here, because @code{=} was reserved for
comparisons.)
User variables may be used where expressions are allowed. Note that
this does not currently include use in contexts where a number is explicitly
this does not currently include contexts where a number is explicitly
required, such as in the @code{LIMIT} clause of a @code{SELECT} statement,
or the @code{IGNORE number LINES} clause of a @code{LOAD DATA} statement.
@strong{NOTE:} In a @code{SELECT} statement, each expression is only
evaluated when it's sent to the client. This means that in the @code{HAVING},
@strong{NOTE:} In a @code{SELECT} statement, each expression is evaluated
only when it's sent to the client. This means that in the @code{HAVING},
@code{GROUP BY}, or @code{ORDER BY} clause, you can't refer to an expression
that involves variables that are set in the @code{SELECT} part. For example,
the following statement will NOT work as expected:
...
...
@@ -28185,8 +28190,8 @@ multiple-line comment
1;
@end example
Note that the @code{--} comment style requires you to have at least one space
after the @code{--}!
Note that the @code{--} (double-dash) comment style requires you to have at
least one space after the second dash!
Although the server understands the comment syntax just described,
there are some limitations on the way that the @code{mysql} client
...
...
@@ -28210,8 +28215,8 @@ These limitations apply both when you run @code{mysql} interactively
and when you put commands in a file and tell @code{mysql} to read its
input from that file with @code{mysql < some-file}.
MySQL only supports the @samp{--} ANSI SQL comment style if it is
followed by a space. @xref{ANSI diff comments}.
MySQL supports the @samp{--} ANSI SQL comment style only if the second dash
is followed by a space. @xref{ANSI diff comments}.
@node Reserved words, , Comments, Language Structure
...
...
@@ -28224,12 +28229,12 @@ A common problem stems from trying to create a table with column names that
use the names of datatypes or functions built into MySQL, such as
@code{TIMESTAMP} or @code{GROUP}. You're allowed to do it (for example,
@code{ABS} is an allowed column name), but whitespace is not allowed between
a function name and the @samp{(} when using functions whose names are also
column names.
a function name and the immediately following @samp{(} when using functions
whose names are also column names.
The following words are explicitly reserved in MySQL. Most of
them are forbidden by ANSI SQL92 as column and/or table names
(for example, @code{group}).
(for example, @code{GROUP}).
A few are reserved because MySQL needs them and is
(currently) using a @code{yacc} parser:
...
...
@@ -28440,12 +28445,12 @@ A large integer. The signed range is @code{-9223372036854775808} to
@code{9223372036854775807}. The unsigned range is @code{0} to
@code{18446744073709551615}.
Some things you should be aware about @code{BIGINT} columns:
Some things you should be aware of with respect to @code{BIGINT} columns:
@itemize @bullet
@item
@cindex rounding errors
As all arithmetic is done using signed @code{BIGINT} or @code{DOUBLE}
All arithmetic is done using signed @code{BIGINT} or @code{DOUBLE}
values, so you shouldn't use unsigned big integers larger than
@code{9223372036854775807} (63 bits) except with bit functions! If you
do that, some of the last digits in the result may be wrong because of
...
...
@@ -28458,17 +28463,17 @@ Use integers to store big unsigned values in a @code{BIGINT} column.
@item
In @code{MIN(big_int_column)} and @code{MAX(big_int_column)}.
@item
When using operators (@code{+}, @code{-}, @code{*} etc) where
When using operators (@code{+}, @code{-}, @code{*}, etc.) where
both operands are integers.
@end itemize
@item
You can always store an exact integer value in a @code{BIGINT} column by
storing it as a string, as there is in this case there will be no
intermediate double representation.
storing it as a string. In this case, MySQL will perform a string-to-number
conversion that involves no intermediate double representation.
@item
@samp{-}, @samp{+}, and @samp{*} will use @code{BIGINT} arithmetic when
both arguments are @code{INTEGER} values! This means that if you
both arguments are integer values! This means that if you
multiply two big integers (or results from functions that return
integers) you may get unexpected results when the result is larger than
@code{9223372036854775807}.
...
...
@@ -28504,7 +28509,7 @@ This syntax is provided for ODBC compatibility.
A small (single-precision) floating-point number. Cannot be unsigned.
Allowable values are @code{@w{-3.402823466E+38}} to
@code{@w{-1.175494351E-38}}, @code{0}, and @code{@w{1.175494351E-38}} to
@code{3.402823466E+38}. The M is the display width and D is the
@code{3.402823466E+38}. The @code{M} is the display width and @code{D} is the
number of decimals. @code{FLOAT} without an argument or with an argument of
<= 24 stands for a single-precision floating-point number.
...
...
@@ -28515,10 +28520,10 @@ number of decimals. @code{FLOAT} without an argument or with an argument of
A normal-size (double-precision) floating-point number. Cannot be
unsigned. Allowable values are @code{@w{-1.7976931348623157E+308}} to
@code{@w{-2.2250738585072014E-308}}, @code{0}, and
@code{2.2250738585072014E-308} to @code{1.7976931348623157E+308}. The M
is the display width and D is the number of decimals. @code{DOUBLE}
without an argument or @code{FLOAT(X)} where 25 <= X <= 53 stands for a
double-precision floating-point number.
@code{2.2250738585072014E-308} to @code{1.7976931348623157E+308}. The
@code{M} is the display width and @code{D} is the number of decimals.
@code{DOUBLE} without an argument or @code{FLOAT(X)} where 25 <= @code{X}
<= 53 stands for a double-precision floating-point number.
@tindex DOUBLE PRECISION
@tindex REAL
...
...
@@ -28533,17 +28538,18 @@ These are synonyms for @code{DOUBLE}.
An unpacked floating-point number. Cannot be unsigned. Behaves like a
@code{CHAR} column: ``unpacked'' means the number is stored as a string,
using one character for each digit of the value. The decimal point and,
for negative numbers, the @samp{-} sign, are not counted in M (but space
for these are reserved). If @code{D} is 0, values will have no decimal
for negative numbers, the @samp{-} sign, are not counted in @code{M} (but
space for these is reserved). If @code{D} is 0, values will have no decimal
point or fractional part. The maximum range of @code{DECIMAL} values is
the same as for @code{DOUBLE}, but the actual range for a given
@code{DECIMAL} column may be constrained by the choice of @code{M} and
@code{D}.
If @code{D} is left out it's set to 0. If @code{M} is left out it's set to 10.
If @code{D} is omitted, the default is 0. If @code{M} is omitted, the
default is 10.
Note that in MySQL Version 3.22 the @code{M} argument had to
includes the space needed for the sign and the decimal point.
Prior to MySQL Version 3.23, the @code{M} argument must include the space
needed for the sign and the decimal point.
@tindex NUMERIC
@item NUMERIC(M,D) [ZEROFILL]
...
...
@@ -28582,14 +28588,14 @@ recent operation if you don't give it a value yourself. You can also set it
to the current date and time by assigning it a @code{NULL} value. @xref{Date
and time types}.
A @code{TIMESTAMP} is always stored in 4 bytes. The @code{M} argument only
affects how the @code{TIMESTAMP} column is displayed.
The @code{M} argument affects only how a @code{TIMESTAMP} column is displayed;
its values always are stored using 4 bytes each.
Note that @code{TIMESTAMP(X)} columns where X is 8 or 14 are reported to
be numbers while other @code{TIMESTAMP(X)} columns are reported to be
Note that @code{TIMESTAMP(M)} columns where @code{M} is 8 or 14 are reported to
be numbers while other @code{TIMESTAMP(M)} columns are reported to be
strings. This is just to ensure that one can reliably dump and restore
the table with these types!
@xref{DATETIME}.
@xref{DATETIME, , @code{DATETIME}}.
@tindex TIME
@item TIME
...
...
@@ -28597,7 +28603,7 @@ the table with these types!
A time. The range is @code{'-838:59:59'} to @code{'838:59:59'}.
MySQL displays @code{TIME} values in @code{'HH:MM:SS'} format, but
allows you to assign values to @code{TIME} columns using either strings or
numbers. @xref{TIME}.
numbers. @xref{TIME, , @code{TIME}}.
@tindex YEAR
@item YEAR[(2|4)]
...
...
@@ -28607,7 +28613,7 @@ are @code{1901} to @code{2155}, @code{0000} in the 4-digit year format,
and 1970-2069 if you use the 2-digit format (70-69). MySQL displays
@code{YEAR} values in @code{YYYY} format, but allows you to assign values to
@code{YEAR} columns using either strings or numbers. (The @code{YEAR} type is
new in MySQL Version 3.22.) @xref{YEAR}.
unavailable prior to MySQL Version 3.22.) @xref{YEAR, , @code{YEAR}}.
@tindex NATIONAL CHAR
@tindex NCHAR
...
...
@@ -28616,14 +28622,15 @@ new in MySQL Version 3.22.) @xref{YEAR}.
@item [NATIONAL] CHAR(M) [BINARY]
A fixed-length string that is always right-padded with spaces to the
specified length when stored. The range of @code{M} is 1 to 255 characters.
specified length when stored. The range of @code{M} is 0 to 255 characters
(1 to 255 prior to MySQL Version 3.23).
Trailing spaces are removed when the value is retrieved. @code{CHAR} values
are sorted and compared in case-insensitive fashion according to the
default character set unless the @code{BINARY} keyword is given.
@code{NATIONAL CHAR} (short form @code{NCHAR}) is the ANSI SQL way to
define that a CHAR column should use the default CHARACTER set. This is
the default in MySQL.
@code{NATIONAL CHAR} (or its equivalent short form, @code{NCHAR}) is the
ANSI SQL way to define that a @code{CHAR} column should use the default
CHARACTER set. This is the default in MySQL.
@code{CHAR} is a shorthand for @code{CHARACTER}.
...
...
@@ -28632,8 +28639,8 @@ MySQL allows you to create a column of type
some old applications that depend on the existence of a column but that do not
actually use the value. This is also quite nice when you need a
column that only can take 2 values: A @code{CHAR(0)}, that is not defined
as @code{NOT NULL}, will only occupy one bit and can only take 2 values:
@code{NULL} or @code{""}. @xref{CHAR}.
as @code{NOT NULL}, will occupy only one bit and can take only 2 values:
@code{NULL} or @code{""}. @xref{CHAR, , @code{CHAR}}.
@tindex BOOL
@tindex BIT
...
...
@@ -35026,7 +35033,7 @@ The options work for all table types, if not otherwise indicated:
@item @code{MAX_ROWS} @tab Max number of rows you plan to store in the table.
@item @code{MIN_ROWS} @tab Minimum number of rows you plan to store in the table.
@item @code{PACK_KEYS} @tab Set this to 1 if you want to have a smaller index. This usually makes updates slower and reads faster (MyISAM, ISAM). Setting this to 0 will disable all packing of keys. Setting this to @code{DEFAULT} (MySQL 4.0) will tell the table handler to only pack long @code{CHAR}/@code{VARCHAR} columns.
@item @code{PASSWORD} @tab Encrypt the @code{.frm} file with a password. This option doesn't do anything in the standard MySQL version.
@item @code{PASSWORD} @tab Encrypt the @file{.frm} file with a password. This option doesn't do anything in the standard MySQL version.
@item @code{DELAY_KEY_WRITE} @tab Set this to 1 if want to delay key table updates until the table is closed (MyISAM).
@item @code{ROW_FORMAT} @tab Defines how the rows should be stored. Currently this option only works with MyISAM tables, which supports the @code{DYNAMIC} and @code{FIXED} row formats. @xref{MyISAM table formats}.
@end multitable
...
...
@@ -36510,7 +36517,7 @@ or @code{BDB}), depending on how you compile it.
When you create a new table, you can tell MySQL which table
type it should use for the table. MySQL will always create a
@code{.frm} file to hold the table and column definitions. Depending on
@file{.frm} file to hold the table and column definitions. Depending on
the table type, the index and data will be stored in other files.
Note that to use @code{InnoDB} tables you have to use at least
...
...
@@ -36583,8 +36590,8 @@ of both worlds.
@code{MyISAM} is the default table type in MySQL Version 3.23. It's
based on the @code{ISAM} code and has a lot of useful extensions.
The index is stored in a file with the @code{.MYI} (MYIndex) extension,
and the data is stored in a file with the @code{.MYD} (MYData) extension.
The index is stored in a file with the @file{.MYI} (MYIndex) extension,
and the data is stored in a file with the @file{.MYD} (MYData) extension.
You can check/repair @code{MyISAM} tables with the @code{myisamchk}
utility. @xref{Crash recovery}. You can compress @code{MyISAM} tables with
@code{myisampack} to take up much less space. @xref{myisampack}.
...
...
@@ -37018,7 +37025,7 @@ case of this. @xref{Reproduceable test case}.