| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
MySQL Server includes some extensions that you probably will not find in
other SQL databases. Be warned that if you use them, your code will not be
portable to other SQL servers. In some cases, you can write code that
includes MySQL extensions, but is still portable, by using comments
of the form /*! ... */. In this case, MySQL Server will parse and
execute the code within the comment as it would any other MySQL
statement, but other SQL servers will ignore the extensions. For example:
SELECT /*! STRAIGHT_JOIN */ col_name FROM table1,table2 WHERE ... |
If you add a version number after the '!' character, the syntax within
the comment will be
executed only if the MySQL version is equal to or newer than the specified
version number:
CREATE /*!32302 TEMPORARY */ TABLE t (a INT); |
This means that if you have Version 3.23.02 or newer, MySQL
Server will use the TEMPORARY keyword.
The following descriptions list MySQL extensions, organized by category.
MySQL Server maps each database to a directory under the MySQL data directory, and tables within a database to filenames in the database directory. This has a few implications:
MyISAM or ISAM storage engines.
For example, to rename a MyISQM table, rename the `.MYD',
`.MYI', and `.frm' files to which the table corresponds.
db_name.tbl_name syntax. Some SQL servers provide
the same functionality but call this User space.
MySQL Server doesn't support tablespaces such as used in statements like this:
CREATE TABLE ralph.my_table...IN my_tablespace.
ANALYZE TABLE, CHECK TABLE, OPTIMIZE TABLE, and
REPAIR TABLE statements.
CREATE DATABASE and DROP DATABASE statements.
See section CREATE DATABASE.
DO statement.
EXPLAIN SELECT to get a description of how tables are joined.
FLUSH and RESET statements.
SET statement. See section SET.
SHOW statement.
See section SHOW.
LOAD DATA INFILE. In many cases, this syntax is compatible with
Oracle's LOAD DATA INFILE. See section LOAD DATA.
RENAME TABLE. See section RENAME TABLE.
REPLACE instead of DELETE + INSERT.
See section REPLACE.
CHANGE col_name, DROP col_name, or DROP
INDEX, IGNORE or RENAME in an ALTER TABLE
statement.
Use of multiple ADD, ALTER, DROP, or CHANGE
clauses in an ALTER TABLE statement.
See section ALTER TABLE.
INDEX or KEY in a CREATE TABLE
statement. See section CREATE TABLE.
TEMPORARY or IF NOT EXISTS with CREATE TABLE.
IF EXISTS with DROP TABLE.
DROP TABLE statement.
ORDER BY and LIMIT clauses of the UPDATE and
DELETE statements.
INSERT INTO ... SET col_name = ... syntax.
DELAYED clause of the INSERT and REPLACE
statements.
LOW_PRIORITY clause of the INSERT, REPLACE,
DELETE, and UPDATE statements.
INTO OUTFILE and STRAIGHT_JOIN in a SELECT
statement. See section SELECT.
SQL_SMALL_RESULT option in a SELECT statement.
GROUP BY part.
This gives better performance for some very specific, but quite normal
queries.
See section 12.7 Functions and Modifiers for Use with GROUP BY Clauses.
ASC and DESC with GROUP BY.
:= assignment
operator:
mysql> SELECT @a:=SUM(total),@b=COUNT(*),@a/@b AS avg
-> FROM test_table;
mysql> SELECT @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
|
MEDIUMINT, SET, ENUM, and the
different BLOB and TEXT types.
AUTO_INCREMENT, BINARY, NULL,
UNSIGNED, and ZEROFILL.
|| and && operators to mean
logical OR and AND, as in the C programming language. In MySQL Server,
|| and OR are synonyms, as are && and AND.
Because of this nice syntax, MySQL Server doesn't support
the standard SQL-99 || operator for string concatenation; use
CONCAT() instead. Because CONCAT() takes any number
of arguments, it's easy to convert use of the || operator to
MySQL Server.
COUNT(DISTINCT list) where list has more than one element.
BINARY attribute or use the BINARY cast, which causes
comparisons to be done according to the ASCII order used on the
MySQL server host.
% operator is a synonym for MOD(). That is,
N % M is equivalent to MOD(N,M). % is supported
for C programmers and for compatibility with PostgreSQL.
=, <>, <= ,<, >=,>,
<<, >>, <=>, AND, OR, or LIKE
operators may be used in column comparisons to the left of the
FROM in SELECT statements. For example:
mysql> SELECT col1=1 AND col2=2 FROM tbl_name; |
LAST_INSERT_ID() function.
See section 12.6.3 Information Functions.
LIKE is allowed on numeric columns.
REGEXP and NOT REGEXP extended regular expression
operators.
CONCAT() or CHAR() with one argument or more than two
arguments. (In MySQL Server, these functions can take any number of
arguments.)
BIT_COUNT(), CASE, ELT(),
FROM_DAYS(), FORMAT(), IF(), PASSWORD(),
ENCRYPT(), MD5(), ENCODE(), DECODE(),
PERIOD_ADD(), PERIOD_DIFF(), TO_DAYS(), or
WEEKDAY() functions.
TRIM() to trim substrings. SQL-99 supports removal
of single characters only.
GROUP BY functions STD(), BIT_OR(),
BIT_AND(), BIT_XOR(), and GROUP_CONCAT().
See section 12.7 Functions and Modifiers for Use with GROUP BY Clauses.
For a prioritized list indicating when new extensions will be added to MySQL Server, you should consult the online MySQL TODO list at http://www.mysql.com/doc/en/TODO.html. That is the latest version of the TODO list in this manual. See section 1.6 MySQL and the Future (The TODO).
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |