Sams Teach Yourself MySQLin 10 Minutesby Chris Newman ISBN: 0-672-32863-1Copyright © 2006 by Sams Publishing
www.samspublishing.com
Appendix C:SQL Syntax Reference 259
Appendix D:MySQL Data Type Reference 270
Appendix E:Common Configuration Options 276
Appendix F:MySQL Reserved Words 279
BONUS CONTENT
0672328631_Bonus_Overview.qxd 5/1/06 3:20 PM Page 1
Sams Teach Yourself MySQLin 10 Minutesby Chris Newman ISBN: 0-672-32863-1Copyright © 2006 by Sams Publishing
www.samspublishing.com
Appendix C:SQL Syntax Reference
BONUS CONTENT
Database-Manipulation Statements 260
Data-Definition Statements 262
References 269
Web02_0672328631_1_C.qxd 5/1/06 3:24 PM Page 1
APPENDIX CSQL SyntaxReference
This appendix is intended to act as a quick reference so that you can findthe syntax for a particular SQL statement when you need it.
The statements are listed in two sections:
• Database-manipulation statements—Commands that deal withdata manipulation and retrieval
• Database-definition statements—Commands that are used tomanage databases objects
Lesson References The descriptions given in thisappendix are brief, so check back to the correspond-ing lessons for more information if you need it.
When reading the syntax definitions in this appendix, remember the fol-lowing conventions:
• The | symbol separates different options. For instance,NULL|NOT NULL means that you should use either NULL orNOT NULL.
• Square brackets are used to indicate components of the state-ment that are optional.
Web02_0672328631_appC.qxd 4/10/06 9:58 AM Page 259
260 Appendix C
Database-Manipulation StatementsThese statements deal with data manipulation and retrieval.
The SELECT statement is introduced in Lesson 3, “Retrieving Data,” andits use is covered in subsequent chapters.
Refer to Lesson 15, “Working with Data,” for more information on theother database-manipulation statements.
DELETEDELETE deletes one or more rows from a table.
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name[WHERE where_definition][ORDER BY ...][LIMIT row_count]
INSERTINSERT is used to add a row to a table.
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE][INTO] tbl_name [(col_name,...)]VALUES ({expr | DEFAULT},...),(...),...[ ON DUPLICATE KEY UPDATE col_name=expr, ... ]
The following is an alternative syntax:
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE][INTO] tbl_nameSET col_name={expr | DEFAULT}, ...[ ON DUPLICATE KEY UPDATE col_name=expr, ... ]
INSERT ... SELECTINSERT ... SELECT can be used to add many rows to a table from theresult of a query.
INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE][INTO] tbl_name [(col_name,...)]SELECT ...[ ON DUPLICATE KEY UPDATE col_name=expr, ... ]
Web02_0672328631_appC.qxd 4/10/06 9:58 AM Page 260
261SQL Syntax Reference
LOAD DATA INFILELOAD DATA INFILE reads rows from a text file and inserts them into adatabase table.
LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE➥‘file_name.txt’
[REPLACE | IGNORE]INTO TABLE tbl_name[FIELDS
[TERMINATED BY ‘string’][[OPTIONALLY] ENCLOSED BY ‘char’][ESCAPED BY ‘char’ ]
][LINES
[STARTING BY ‘string’][TERMINATED BY ‘string’]
][IGNORE number LINES][(col_name,...)]
REPLACEREPLACE works like INSERT, except that where a row already exists in thetable with the same value in a PRIMARY KEY or UNIQUE column as thevalue being inserted, it will be deleted first.
REPLACE [LOW_PRIORITY | DELAYED][INTO] tbl_name [(col_name,...)]VALUES ({expr | DEFAULT},...),(...),...
The following is an alternative syntax:
REPLACE [LOW_PRIORITY | DELAYED][INTO] tbl_nameSET col_name={expr | DEFAULT}, ...
REPLACE ... SELECTREPLACE ... SELECT works just like INSERT ... SELECT, with thesame rule for deleting records if a PRIMARY KEY or UNIQUE column valueis the same as the row being inserted.
REPLACE [LOW_PRIORITY | DELAYED][INTO] tbl_name [(col_name,...)]SELECT ...
Web02_0672328631_appC.qxd 4/10/06 9:58 AM Page 261
262 Appendix C
SELECTSELECT is used to retrieve data from one or more database tables.
SELECT[ALL | DISTINCT | DISTINCTROW ]
[HIGH_PRIORITY][STRAIGHT_JOIN][SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT][SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
select_expr, ...[INTO OUTFILE ‘file_name’ export_options
| INTO DUMPFILE ‘file_name’][FROM table_references[WHERE where_definition][GROUP BY {col_name | expr | position}
[ASC | DESC], ... [WITH ROLLUP]][HAVING where_definition][ORDER BY {col_name | expr | position}
[ASC | DESC] , ...][LIMIT {[offset,] row_count | row_count OFFSET offset}][PROCEDURE procedure_name(argument_list)][FOR UPDATE | LOCK IN SHARE MODE]]
TRUNCATETRUNCATE empties a table. The behavior is the same as DELETE with noWHERE clause, but TRUNCATE often works faster.
TRUNCATE [TABLE] tbl_name
UPDATEUPDATE updates one or more rows in a table.
UPDATE [LOW_PRIORITY] [IGNORE] tbl_nameSET col_name1=expr1 [, col_name2=expr2 ...][WHERE where_definition][ORDER BY ...][LIMIT row_count]
Data-Definition StatementsThis section deals with commands that are used to manage the structureof a database.
Web02_0672328631_appC.qxd 4/10/06 9:58 AM Page 262
263SQL Syntax Reference
Refer to Lesson 14, “Creating and Modifying Tables,” for more informa-tion about working with database tables. Lesson 17, “Keys and Indexes,”deals with indexes, and Lessons 19, “Views,” to 21, “Triggers,” coverviews, procedures, and triggers, respectively.
ALTER DATABASEALTER DATABASE is used to change overall properties of a database.
ALTER {DATABASE | SCHEMA} [db_name]alter_specification [, alter_specification] ...
These properties can be used in alter_specification:
[DEFAULT] CHARACTER SET charset_name| [DEFAULT] COLLATE collation_name
ALTER PROCEDURE and ALTER FUNCTIONALTER PROCEDURE and ALTER FUNCTION are used to modify an existingstored routine.
ALTER {PROCEDURE | FUNCTION} sp_name [characteristic ...]
characteristic:{ CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL
➥DATA }| SQL SECURITY { DEFINER | INVOKER }| COMMENT ‘string’
ALTER TABLEALTER TABLE is used to modify the structure of an existing table.
ALTER [IGNORE] TABLE tbl_namealter_specification [, alter_specification] ...
alter_specification:ADD [COLUMN] column_definition [FIRST | AFTER col_name ]
| ADD [COLUMN] (column_definition,...)| ADD INDEX [index_name] [index_type] (index_col_name,...)| ADD [CONSTRAINT [symbol]]
PRIMARY KEY [index_type] (index_col_name,...)| ADD [CONSTRAINT [symbol]]
Web02_0672328631_appC.qxd 4/10/06 9:58 AM Page 263
264 Appendix C
UNIQUE [index_name] [index_type] (index_col_name,...)| ADD [FULLTEXT|SPATIAL] [index_name] (index_col_name,...)| ADD [CONSTRAINT [symbol]]
FOREIGN KEY [index_name] (index_col_name,...)[reference_definition]
| ALTER [COLUMN] col_name {SET DEFAULT literal | DROP➥DEFAULT}
| CHANGE [COLUMN] old_col_name column_definition[FIRST|AFTER col_name]
| MODIFY [COLUMN] column_definition [FIRST | AFTER col_name]| DROP [COLUMN] col_name| DROP PRIMARY KEY| DROP INDEX index_name| DROP FOREIGN KEY fk_symbol| DISABLE KEYS| ENABLE KEYS| RENAME [TO] new_tbl_name| ORDER BY col_name| CONVERT TO CHARACTER SET charset_name [COLLATE
➥collation_name]| [DEFAULT] CHARACTER SET charset_name [COLLATE
➥collation_name]| DISCARD TABLESPACE| IMPORT TABLESPACE| table_options
ALTER VIEWALTER VIEW is used to modify the definition of an existing view.
ALTER[ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}][DEFINER = { user | CURRENT_USER }][SQL SECURITY { DEFINER | INVOKER }]VIEW view_name [(column_list)]AS select_statement[WITH [CASCADED | LOCAL] CHECK OPTION]
CREATE DATABASECREATE DATABASE creates a new database with a given name. You musthave sufficient permissions to create a new database.
CREATE {DATABASE | SCHEMA} [IF NOT EXISTS] db_name[create_specification [, create_specification] ...]
Web02_0672328631_appC.qxd 4/10/06 9:58 AM Page 264
265SQL Syntax Reference
create_specification:[DEFAULT] CHARACTER SET charset_name
| [DEFAULT] COLLATE collation_name
CREATE INDEXCREATE INDEX adds an index to an existing table. It is equivalent to theALTER TABLE ... ADD INDEX statement.
CREATE [UNIQUE|FULLTEXT|SPATIAL] INDEX index_name[USING index_type]ON tbl_name (index_col_name,...)
index_col_name:col_name [(length)] [ASC | DESC]
CREATE PROCEDURE and CREATE FUNCTIONCREATE PROCEDURE and CREATE FUNCTION create routines that are storedat the database level. You must have the CREATE ROUTINE privilege to usethem.
CREATE PROCEDURE sp_name ([proc_parameter[,...]])[characteristic ...] routine_body
CREATE FUNCTION sp_name ([func_parameter[,...]])RETURNS type[characteristic ...] routine_body
proc_parameter:[ IN | OUT | INOUT ] param_name type
func_parameter:param_name type
type:Any valid MySQL data type
characteristic:LANGUAGE SQL
| [NOT] DETERMINISTIC| { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL
➥DATA }| SQL SECURITY { DEFINER | INVOKER }
Web02_0672328631_appC.qxd 4/10/06 9:58 AM Page 265
266 Appendix C
| COMMENT ‘string’
routine_body:Valid SQL procedure statement or statements
CREATE TABLECREATE TABLE creates a new database table.
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name[(create_definition,...)][table_options] [select_statement]
create_definition:column_definition
| [CONSTRAINT [symbol]] PRIMARY KEY [index_type]➥(index_col_name,...)
| KEY [index_name] [index_type] (index_col_name,...)| INDEX [index_name] [index_type] (index_col_name,...)| [CONSTRAINT [symbol]] UNIQUE [INDEX]
[index_name] [index_type] (index_col_name,...)| [FULLTEXT|SPATIAL] [INDEX] [index_name]
(index_col_name,...)| [CONSTRAINT [symbol]] FOREIGN KEY
[index_name] (index_col_name,...)➥[reference_definition]
| CHECK (expr)
column_definition:col_name type [NOT NULL | NULL] [DEFAULT default_value]
[AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY][COMMENT ‘string’] [reference_definition]
type:TINYINT[(length)] [UNSIGNED] [ZEROFILL]
| SMALLINT[(length)] [UNSIGNED] [ZEROFILL]| MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]| INT[(length)] [UNSIGNED] [ZEROFILL]| INTEGER[(length)] [UNSIGNED] [ZEROFILL]| BIGINT[(length)] [UNSIGNED] [ZEROFILL]| REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]| DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]| FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]| DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]| NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]
Web02_0672328631_appC.qxd 4/10/06 9:58 AM Page 266
267SQL Syntax Reference
| DATE| TIME| TIMESTAMP| DATETIME| CHAR(length) [BINARY | ASCII | UNICODE]| VARCHAR(length) [BINARY]| TINYBLOB| BLOB| MEDIUMBLOB| LONGBLOB| TINYTEXT [BINARY]| TEXT [BINARY]| MEDIUMTEXT [BINARY]| LONGTEXT [BINARY]| ENUM(value1,value2,value3,...)| SET(value1,value2,value3,...)| spatial_type
index_col_name:col_name [(length)] [ASC | DESC]
reference_definition:REFERENCES tbl_name [(index_col_name,...)]
[MATCH FULL | MATCH PARTIAL | MATCH SIMPLE][ON DELETE reference_option][ON UPDATE reference_option]
reference_option:RESTRICT | CASCADE | SET NULL | NO ACTION
table_options: table_option [table_option] ...
table_option:{ENGINE|TYPE} = engine_name
| AUTO_INCREMENT = value| AVG_ROW_LENGTH = value| [DEFAULT] CHARACTER SET charset_name [COLLATE
➥collation_name]| CHECKSUM = {0 | 1}| COMMENT = ‘string’| CONNECTION = ‘connect_string’| MAX_ROWS = value| MIN_ROWS = value| PACK_KEYS = {0 | 1 | DEFAULT}| PASSWORD = ‘string’| DELAY_KEY_WRITE = {0 | 1}
Web02_0672328631_appC.qxd 4/10/06 9:58 AM Page 267
268 Appendix C
| ROW_FORMAT =➥{DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT}
| UNION = (tbl_name[,tbl_name]...)| INSERT_METHOD = { NO | FIRST | LAST }| DATA DIRECTORY = ‘absolute path to directory’| INDEX DIRECTORY = ‘absolute path to directory’
select_statement:[IGNORE | REPLACE] [AS] SELECT ... (Some legal select
statement)
CREATE TRIGGERCREATE TRIGGER creates a new database-level trigger.
CREATE[DEFINER = { user | CURRENT_USER }]TRIGGER trigger_name trigger_time trigger_eventON tbl_name FOR EACH ROW trigger_stmt
CREATE VIEWCREATE VIEW creates a new view based on the SQL SELECT statementgiven.
CREATE[OR REPLACE][ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}][DEFINER = { user | CURRENT_USER }][SQL SECURITY { DEFINER | INVOKER }]VIEW view_name [(column_list)]AS select_statement[WITH [CASCADED | LOCAL] CHECK OPTION]
DROP DATABASEDROP DATABASE drops all tables from a database and then deletes thedatabase.
DROP {DATABASE | SCHEMA} [IF EXISTS] db_name
DROP INDEXDROP INDEX drops a named index from the specified table.
DROP INDEX index_name ON tbl_name
Web02_0672328631_appC.qxd 4/10/06 9:58 AM Page 268
269SQL Syntax Reference
DROP PROCEDURE and DROP FUNCTIONDROP PROCEDURE and DROP FUNCTION are used to remove stored rou-tines from the database.
DROP {PROCEDURE | FUNCTION} [IF EXISTS] sp_name
DROP TABLEDROP TABLE removes one or more tables from a database.
DROP [TEMPORARY] TABLE [IF EXISTS]tbl_name [, tbl_name] ...[RESTRICT | CASCADE]
DROP TRIGGERDROP TRIGGER causes a database-level trigger to be dropped.
DROP TRIGGER [schema_name.]trigger_name
DROP VIEWDROP VIEW removes one or more views from a database.
DROP VIEW [IF EXISTS]view_name [, view_name] ...[RESTRICT | CASCADE]
RENAME TABLERENAME TABLE renames one or more tables.
RENAME TABLE tbl_name TO new_tbl_name[, tbl_name2 TO new_tbl_name2] ...
ReferencesThe complete SQL syntax for MySQL can be found online athttp://dev.mysql.com/doc/refman/5.0/en/sql-syntax.html.
Web02_0672328631_appC.qxd 4/10/06 9:58 AM Page 269
Sams Teach Yourself MySQLin 10 Minutesby Chris Newman ISBN: 0-672-32863-1Copyright © 2006 by Sams Publishing
www.samspublishing.com
Appendix D:MySQL Data TypeReference
BONUS CONTENT
Numeric Types 270
Date and Time Types 272
String Types 273
References 275
Web02_0672328631_2_D.qxd 5/1/06 3:19 PM Page 1
APPENDIX DMySQL DataType Reference
Every column in a MySQL database has a predefined data type, whichenforces certain rules on the values that can be stored.
This appendix lists the different data types available to MySQL.
Numeric TypesThese data types are used to store numeric values in the database.
Unsigned Numbers Using the UNSIGNED attribute witha numeric data type increases the range of values thatcan be stored but prevents the column from storingnegative numbers.
BITThis is a bit-type field containing M bits. The default is 1 if M is not given.
BIT[(M)]
TINYINTThis is a very small integer in the range –128 to 127. Unsigned its rangeis 0 to 255. Requires 1 byte of storage.
TINYINT[(M)] [UNSIGNED] [ZEROFILL]
Web03_0672328631_appD.qxd 4/10/06 9:58 AM Page 270
SMALLINTThis is a small integer in the range –32768 to 32767. Unsigned its rangeis 0 to 65535. It requires 2 bytes of storage.
SMALLINT[(M)] [UNSIGNED] [ZEROFILL]
MEDIUMINTThis is a medium-size integer in the range –8388608 to 8388607.Unsigned its range is 0 to 16777215. It requires 3 bytes of storage.
MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]
INTEGER or INTThis is a normal-size integer in the range -2147483648 to 2147483647.Unsigned its range is 0 to 4294967295. It requires 4 bytes of storage.
INT[(M)] [UNSIGNED] [ZEROFILL]INTEGER[(M)] [UNSIGNED] [ZEROFILL]
BIGINTThis is a large integer in the range -9223372036854775808 to9223372036854775807. Unsigned its range is 0 to18446744073709551615. It requires 8 bytes of storage.
BIGINT[(M)] [UNSIGNED] [ZEROFILL]
FLOATThis is a single-precision floating-point number. The theoretical range ofallowed values is -3.402823466E+38 to -1.175494351E-38, 0, and1.175494351E-38 to 3.402823466E+38.
FLOAT[(M,D)] [UNSIGNED] [ZEROFILL]
Web03_0672328631_appD.qxd 4/10/06 9:58 AM Page 271
272 Appendix D
Single Precision Because MySQL performs calcula-tions using double-precision arithmetic, you shouldusually use DOUBLE instead of FLOAT.
DOUBLE or DOUBLE PRECISIONThis is a double-precision floating point number. The theoretical range ofallowed values is 1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308.
DOUBLE[(M,D)] [UNSIGNED] [ZEROFILL]DOUBLE PRECISION[(M,D)] [UNSIGNED] [ZEROFILL]
DECIMALThis is an exact, fixed-point number. M is the total number of digits, up toa maximum of 65, and D is the number of digits after the decimal point,up to 30.
DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]
Date and Time TypesThese data types are used to store date and time values in the database.
Date and Time Values MySQL does not validate thevalue of a date or time value, other than checkingthat it is in the correct format. No check is performedto see whether a date actually exists.
DATEThis is a date value represented in the format YYYY-MM-DD. DATE can storevalues in the range 1000-01-01 to 9999-12-31.
Web03_0672328631_appD.qxd 4/10/06 9:58 AM Page 272
273MySQL Data Type Reference
DATETIMEThis is a combined date and time value represented in the format YYYY-MM-DD HH:MM:SS. DATETIME can store values in the range 1000-01-0100:00:00 to 9999-12-31 23:59:59.
TIMESTAMPThis is a time stamp value displayed in the format YYYY-MM-DDHH:MM:SS, but stored as the number of seconds since 1970-01-0100:00:00. Its maximum value is in the year 2037.
TIMEThis is a time value represented in the format HH:MM:SS. TIME can storevalues in the range –838:59:59 to 838:59:59.
YEARThis is a year value in two-digit or four-digit format. Allowable four-digitvalues are in the range 1901 to 2155, and 0000. Allowable two-digitvalues are between 70 (for 1970) and 69 (for 2069).
YEAR[(2|4)]
String TypesThese data types are used to store character strings in the database.
Binary Data A column defined as a binary datatype—BINARY, VARBINARY, or BLOB—treats its data as asequence of bytes. By contrast, the text data types—CHAR, VARCHAR, and TEXT—store data based on a charac-ter set.
Web03_0672328631_appD.qxd 4/10/06 9:58 AM Page 273
274 Appendix D
CHARThis is a fixed-length string, right-padded with spaces to the specifiedlength. Its maximum length is 255 characters.
[NATIONAL] CHAR(M) [BINARY | ASCII | UNICODE]
The BINARY attribute specifies binary collation on a column, most com-monly used to enforce case-sensitive comparisons.
ASCII and UNICODE specify particular character sets to be used—latin1
and ucs2, respectively.
BINARYBINARY is similar to CHAR but stores fixed-length binary byte strings.
VARCHARThis is a variable-length string with a given maximum length. The maxi-mum length is 65,535 characters in MySQL version 5.0.3 and later, but255 characters in earlier versions.
[NATIONAL] VARCHAR(M) [BINARY]
VARBINARYVARBINARY is similar to VARCHAR but stores variable-length binary bytestrings.
TINYTEXT or TINYBLOBThis is a small TEXT or BLOB column with a maximum length of 255 char-acters or bytes.
TEXT or BLOBA variable-length text or byte string column with a maximum length of65,535 characters or bytes (64KB).
Web03_0672328631_appD.qxd 4/10/06 9:58 AM Page 274
275MySQL Data Type Reference
Default Values TEXT and BLOB data types cannot havea DEFAULT value.
MEDIUMTEXT or MEDIUMBLOBThis is a medium-size TEXT or BLOB column with a maximum length of16,777,215 characters or bytes (16MB).
LONGTEXT or LONGBLOBThis is a long TEXT or BLOB column with a maximum length of4,294,967,295 characters or bytes (4GB).
ENUMThis is an enumerated list of string values. Only the values defined in thecolumn are acceptable, and values are stored in the database as integers.The maximum number of distinct values is 65,535.
ENUM(‘value1’, ‘value2’, ...)
SETThis is a string object that can have multiple values. Values are stored inthe database as integers. The maximum number of members in a SETis 64.
SET(‘value1’, ‘value2’, ...)
ReferencesThe online manual section that covers data types can be found athttp://dev.mysql.com/doc/refman/5.0/en/column-types.html.
Web03_0672328631_appD.qxd 4/10/06 9:58 AM Page 275
Sams Teach Yourself MySQLin 10 Minutesby Chris Newman ISBN: 0-672-32863-1Copyright © 2006 by Sams Publishing
www.samspublishing.com
Appendix E:Common ConfigurationOptions
BONUS CONTENT
Server Configuration 276
Client Configuration 277
Web02_0672328631_3_E.qxd 5/1/06 3:19 PM Page 1
APPENDIX ECommonConfigurationOptions
This appendix contains some of the common directives that are used toconfigure MySQL in the my.cnf file.
MySQL reads configuration information from my.cnf in three locations,in this order:
• Systemwide configuration: /etc/my.cnf
• Server-specific configuration: the MySQL data directory, such as/var/lib/mysql/my.cnf
• Per-user configuration: $HOME/.my.cnf
Server ConfigurationThe following directives appear in the [mysqld] section of the configura-tion file and control the behavior of the MySQL server.
Server Startup Options• port=PORT—Specifies the TCP/IP port on which the server will
accept connections
• socket=/path/to/socket—Specifies the path of the socket thatis used for localhost connections
• user=USERNAME—Specifies the user to run the mysqld process as
• skip-grant-tables—Causes MySQL to start without using theprivilege system, allowing access to any user
Web04_0672328631_appE.qxd 4/10/06 9:59 AM Page 276
• skip-networking—Completely disables TCP/IP networkconnections
Logging Options• log=/path/to/log—Writes the general query log to the given
file
• log-error=/path/to/error-log—Writes the error log to thegiven file
• log-bin=/path/to/binary-log—Writes the binary log to thegiven file
• log-slow-queries=/path/to/slow-query-log—Writes theslow query log to the given file
• long_query_time=N—Specifies the execution time limit, inseconds, for slow query logging
• log-queries-not-using-indexes—Prevents slow queries thatdo not use an index from being logged
• log-short-format—Causes the update log, binary log, and slowquery log to contain less information
Client ConfigurationEntries in my.cnf contained in the [client] section apply to all clientprograms. You can specify configuration options for a program by usingits name as the section header, as in [mysql] or [mysqldump].
Connection Options• user=USER—The MySQL username to use when connecting to
the server
• password=PASSWORD—The password to use for databaseauthentication
Web04_0672328631_appE.qxd 4/10/06 9:59 AM Page 277
278 Appendix E
• port=PORT—The TCP/IP port for database connections
• socket=/path/to/socket—The socket file for localhost con-nections
Safety Options• safe-updates—Prohibits UPDATE and DELETE statements that do
not include a WHERE or LIMIT clause
Web04_0672328631_appE.qxd 4/10/06 9:59 AM Page 278
Sams Teach Yourself MySQLin 10 Minutesby Chris Newman ISBN: 0-672-32863-1Copyright © 2006 by Sams Publishing
www.samspublishing.com
Appendix F:MySQL ReservedWords
BONUS CONTENT
Web02_0672328631_4_F.qxd 5/1/06 3:20 PM Page 1
APPENDIX FMySQLReservedWords
The SQL language is made up of keywords. Each keyword is reserved fora particular use; you must be careful not to use it elsewhere, or you willget unexpected results.
In this appendix, you will find an alphabetical list of the reserved key-words in MySQL 5.1.
MySQL Version Even if you use an earlier version ofMySQL, you should avoid keywords reserved for alater version, for future compatibility.
ADD ALL ALTER
ANALYZE AND AS
ASC ASENSITIVE BEFORE
BETWEEN BIGINT BINARY
BLOB BOTH BY
CALL CASCADE CASE
CHANGE CHAR CHARACTER
CHECK COLLATE COLUMN
CONDITION CONNECTION CONSTRAINT
CONTINUE CONVERT CREATE
CROSS CURRENT_DATE CURRENT_TIME
CURRENT_TIMESTAMP CURRENT_USER CURSOR
Web05_0672328631_appF.qxd 4/10/06 9:59 AM Page 279
280 Appendix F
DATABASE DATABASES DAY_HOUR
DAY_MICROSECOND DAY_MINUTE DAY_SECOND
DEC DECIMAL DECLARE
DEFAULT DELAYED DELETE
DESC DESCRIBE DETERMINISTIC
DISTINCT DISTINCTROW DIV
DOUBLE DROP DUAL
EACH ELSE ELSEIF
ENCLOSED ESCAPED EXISTS
EXIT EXPLAIN FALSE
FETCH FLOAT FLOAT4
FLOAT8 FOR FORCE
FOREIGN FROM FULLTEXT
GOTO GRANT GROUP
HAVING HIGH_PRIORITY HOUR_MICROSECOND
HOUR_MINUTE HOUR_SECOND IF
IGNORE IN INDEX
INFILE INNER INOUT
INSENSITIVE INSERT INT
INT1 INT2 INT3
INT4 INT8 INTEGER
INTERVAL INTO IS
ITERATE JOIN KEY
KEYS KILL LABEL
LEADING LEAVE LEFT
LIKE LIMIT LINEAR
LINES LOAD LOCALTIME
LOCALTIMESTAMP LOCK LONG
LONGBLOB LONGTEXT LOOP
LOW_PRIORITY MATCH MEDIUMBLOB
MEDIUMINT MEDIUMTEXT MIDDLEINT
MINUTE_MICROSECOND MINUTE_SECOND MOD
Web05_0672328631_appF.qxd 4/10/06 9:59 AM Page 280
281MySQL Reserved Words
MODIFIES NATURAL NOT
NO_WRITE_TO_BINLOG NULL NUMERIC
ON OPTIMIZE OPTION
OPTIONALLY OR ORDER
OUT OUTER OUTFILE
PRECISION PRIMARY PROCEDURE
PURGE RAID0 RANGE
READ READS REAL
REFERENCES REGEXP RELEASE
RENAME REPEAT REPLACE
REQUIRE RESTRICT RETURN
REVOKE RIGHT RLIKE
SCHEMA SCHEMAS SECOND_
MICROSECOND
SELECT SENSITIVE SEPARATOR
SET SHOW SMALLINT
SPATIAL SPECIFIC SQL
SQLEXCEPTION SQLSTATE SQLWARNING
SQL_BIG_RESULT SQL_CALC_FOUND_ROWS SQL_SMALL_RESULT
SSL STARTING STRAIGHT_JOIN
TABLE TERMINATED THEN
TINYBLOB TINYINT TINYTEXT
TO TRAILING TRIGGER
TRUE UNDO UNION
UNIQUE UNLOCK UNSIGNED
UPDATE USAGE USE
USING UTC_DATE UTC_TIME
UTC_TIMESTAMP VALUES VARBINARY
VARCHAR VARCHARACTER VARYING
WHEN WHERE WHILE
WITH WRITE X509
XOR YEAR_MONTH ZEROFILL
Web05_0672328631_appF.qxd 4/10/06 9:59 AM Page 281