By George Reese
Cover | Table of Contents
ALTER
TABLE that you generally never use, you can reach into your
laptop case and grab this reference. As an experienced MySQL
architect, administrator, or programmer, you can look to this
reference.Constant widthALTER
TABLE that you generally never use, you can reach into your
laptop case and grab this reference. As an experienced MySQL
architect, administrator, or programmer, you can look to this
reference.Constant widthhttp://www.mysql.com.configure
--option[=value].
For example, configure --prefix=/usr/local/mysql
tells the installer to use /usr/local/mysql as
its installation directory.chown -R root {INSTALL_DIR}
chgrp -R mysql {INSTALL_DIR}
chown -R mysql {DATA_DIR}
password option
specified on the command line, in your configuration file, and in an
environment variable, the command-line option wins. Table 1-1 shows a list of configuration options. Each
option applies to one or more MySQL tools, depending on the context.|
Option
|
Description
|
|---|---|
basedir=directory |
Specifies the root directory of your MySQL install.
|
batch |
Executes in batch mode, meaning no command-line prompts or other
information is sent to stdout. This is the default mode when used
with a pipe. |
mysql --password=mypass
mysql -p mypass
[23:00:03] george@firenze$ man -M/usr/local/mysql/man
mysql
MYSQL(1)
MYSQL(1)
NAME
mysql - text-based client for mysqld, a
SQL-based relational database daemon
SYNOPSIS
mysql [-B|--batch] [-#|--debug= logfile]
[-T|--debug-info] [-e|--exec= command] [-f|--force]
[-?|--help] [-h|--host=hostname] [-n|--unbuffered]
[-p[pwd]] [--password=[pwd]] [-P|--port= pnum]
[-q|--quick] [-r|--raw] [-s|--silent]
[-S|--socket= snum] [-u|--user= uname]
[-v|--verbose] [-V|--version] [-w|--wait]
DESCRIPTION
The mysql program provides a curses-based interface to
the SQL-based database server daemon, mysqld(1). Full
fuller documentation, refer to the HTML documents
installed with the package.
OPTIONS
-B|--batch
Print results with a tab as separator, each row on
[
]) to indicate optional parts of the syntax. The following
example shows how BIGINT is explained in this
chapter:BIGINT[(display_size)]
BIGINT alone or
with a display size value. The italics indicate that you do not enter
display_size literally, but instead enter
your own value. Possible uses of BIGINT include:BIGINT BIGINT(20)
BIGINT type, many other MySQL
data types support the specification of a display size. Unless
otherwise specified, this value must be an integer between 1 and 255.VARCHAR -> CHARVARCHAR column size is less
than four characters, it is converted to CHAR.CHAR -> VARCHARCHAR columns greater than three characters in
length are converted to VARCHAR.TIMESTAMP display sizesTIMESTAMP fields must be an even
value between 2 and 14. A display size of 0 or greater than 14 will
convert the field to a display size of 14. An odd-valued display size
will be converted to the next highest even value.|
Token type
|
Case-sensitivity
|
|---|---|
|
Keywords
|
Case-insensitive.
|
|
Identifiers (databases and tables)
|
Dependent on the case-sensitivity for the underlying OS. On all UNIX
systems except Mac OS X using HFS+, database and table names are
case-sensitive. On Mac OS X using HFS+ and Windows, they are
case-insensitive.
|
|
Table aliases
|
Case-sensitive
|
|
Column aliases
|
Case-insensitive
|
This is
a ''quote'''. However, you do
not need to double up on single quotes when the string is enclosed by
double quotes: "This is
a 'quote'".|
Escape sequence
|
Value
|
|---|---|
\0 |
NUL |
\` |
Single quote
|
\" |
Double quote
|
\b |
Backspace
|
\n |
Newline
|
\r |
Carriage return
|
\t |
Tab |
BINARYNOT^- (unary minus)* / %+ -<< >>&|< <= > >= = <=> <> IN IS LIKE
REGEXPBETWEEN CASEANDOR XOR+ - * /%|OR on two integer values^&AND on two integer values<<>><=>
operator, NULL values cause a comparison operator
to evaluate to NULL.<> or !=<=<>=>BETWEEN value1 AND value2 IN (value1,value2,...)NOT IN (value1, value2,...)LIKE value2%',
which matches any number of characters (including 0), and
'_', which matches exactly one character. Its most
common use is comparing a field value with a literal containing a
wildcard (e.g., SELECT AVG(height) FROM
kids would return the average of all the values of the
height field in the kids table.AVG(expression)SELECT
AVG(score) FROM tests).BIT_AND(expression)AND aggregate of all the
values in expression (e.g.,
SELECT BIT_AND(flags) FROM
options). A bit will be set in the result if and only if
the bit is set in every input field.BIT_OR(expression)OR aggregate of all the values
in expression (e.g.,
SELECT BIT_OR(flags) FROM
options). A bit is set in the result if it is set in at
least one of the input fields.COUNT(expression)COUNT(*) will return the number of rows
with some data in the entire table (e.g., SELECT
COUNT(*) FROM
folders).MAX(expression)SELECT MAX
(elevation) FROM mountains).MIN(expression)SELECT MIN(level)
FROM toxic_waste).STD(expression)/STDDEV(expression)SELECT STDDEV(points) FROM
data).SUM(expression)SELECT SUM(calories) FROM
daily_diet).ABS(number)ABS(-10) returns
"10").ACOS(number)ACOS(0) returns
"1.570796").ADDDATE(date, INTERVAL, amount, type)DATE_ADD.ASCII(char)ASCII(h) returns
"104").ASIN(number)ASIN(0) returns
"0.000000").|
Type
|
Transactional
|
Description
|
|---|---|---|
|
BDB
|
Yes
|
Transaction-safe tables with page locking
|
|
Berkeley_db
|
Yes
|
Alias for BDB
|
|
HEAP
|
No
|
Memory-based table; not persistent
|
|
ISAM
|
No
|
Obsolete format; replaced by MyISAM
|
|
InnoDB
|
Yes
|
Transaction-safe tables with row locking
|
|
MERGE
|
No
|
A collection of MyISAM tables merged as a single table
|
|
MyISAM
|
No
|
A newer, portable table type to replace ISAM
|
Return to MySQL Pocket Reference