Whole document tree
    

Whole document tree

MySQL Reference Manual for version 3.23.51. - 1 General Information About MySQL Go to the first, previous, next, last section, table of contents.


1 General Information About MySQL

This is the MySQL reference manual; it documents MySQL Version 3.23.51. As MySQL is work in progress, the manual gets updated frequently. There is a very good chance that this version is out of date, unless you are looking at it online. The most recent version of this manual is available at http://www.mysql.com/documentation/ in many different formats. If you have a hard time finding information in the manual, you can try the searchable PHP version at http://www.mysql.com/documentation/manual.php.

MySQL is a very fast, multi-threaded, multi-user, and robust SQL (Structured Query Language) database server.

MySQL is free software. It is licensed with the GNU GENERAL PUBLIC LICENSE http://www.gnu.org/. See section 1.3 MySQL Licensing and Support.

The MySQL home page provides the latest information about MySQL.

The following list describes some useful sections of the manual:

IMPORTANT:

Reports of errors (often called bugs), as well as questions and comments, should be sent to the mailing list at mysql@lists.mysql.com. See section 1.2.22.3 How to Report Bugs or Problems. The mysqlbug script should be used to generate bug reports. For source distributions, the mysqlbug script can be found in the `scripts' directory. For binary distributions, mysqlbug can be found in the `bin' directory. If you have found a sensitive security bug in MySQL, you should send an email to security@mysql.com.

If you have any suggestions concerning additions or corrections to this manual, please send them to the manual team at docs@mysql.com.

This is a reference manual; it does not provide general instruction on SQL or relational database concepts. If you want general information about SQL, see section 1.2.2 General SQL Information and Tutorials. For books that focus more specifically on MySQL, see section 1.2.1 Books About MySQL.

1.1 MySQL, MySQL AB, and Open Source

1.1.1 What Is MySQL

MySQL, the most popular Open Source SQL database, is provided by MySQL AB. MySQL AB is a commercial company that builds its business providing services around the MySQL database. See section 1.1.2 What Is MySQL AB.

MySQL is a database management system.
A database is a structured collection of data. It may be anything from a simple shopping list to a picture gallery or the vast amounts of information in a corporate network. To add, access, and process data stored in a computer database, you need a database management system such as MySQL. Since computers are very good at handling large amounts of data, database management plays a central role in computing, as stand-alone utilities, or as parts of other applications.
MySQL is a relational database management system.
A relational database stores data in separate tables rather than putting all the data in one big storeroom. This adds speed and flexibility. The tables are linked by defined relations making it possible to combine data from several tables on request. The SQL part of MySQL stands for "Structured Query Language" - the most common standardized language used to access databases.
MySQL is Open Source Software.
Open Source means that it is possible for anyone to use and modify. Anybody can download MySQL from the Internet and use it without paying anything. Anybody so inclined can study the source code and change it to fit their needs. MySQL uses the GPL (GNU General Public License) http://www.gnu.org, to define what you may and may not do with the software in different situations. If you feel uncomfortable with the GPL or need to embed MySQL into a commercial application you can buy a commercially licensed version from us.
Why use MySQL?
MySQL is very fast, reliable, and easy to use. If that is what you are looking for, you should give it a try. MySQL also has a very practical set of features developed in very close cooperation with our users. You can find a performance comparison of MySQL to some other database managers on our benchmark page. See section 5.1.4 The MySQL Benchmark Suite. MySQL was originally developed to handle very large databases much faster than existing solutions and has been successfully used in highly demanding production environments for several years. Though under constant development, MySQL today offers a rich and very useful set of functions. The connectivity, speed, and security make MySQL highly suited for accessing databases on the Internet.
The technical features of MySQL
For advanced technical information, see section 6 MySQL Language Reference. MySQL is a client/server system that consists of a multi-threaded SQL server that supports different backends, several different client programs and libraries, administrative tools, and several programming interfaces. We also provide MySQL as a multi-threaded library which you can link into your application to get a smaller, faster, easier to manage product.
MySQL has a lot of contributed software available.
It is very likely that you will find that your favorite application or language already supports MySQL.

The official way to pronounce MySQL is ``My Ess Que Ell'' (not MY-SEQUEL). But we try to avoid correcting people who say MY-SEQUEL.

1.1.2 What Is MySQL AB

MySQL AB is the Swedish company owned and run by the MySQL founders and main developers. We are dedicated to developing MySQL and spreading our database to new users. MySQL AB owns the copyright to the MySQL server source code and the MySQL trademark. A significant amount of revenues from our services goes to developing MySQL. See section 1.1.1 What Is MySQL.

MySQL AB has been profitable providing MySQL from the start. We don't get any outside funding, but have earned all our money ourselves.

We are searching after partners that would like to support our development of MySQL so that we could accelerate the development pace. If you are interested in doing this, you can email partner@mysql.com about this!

MySQL AB has currently 20+ people (http://www.mysql.com/development/team.html) on its payroll and is growing rapidly.

Our main sources of income are:

  • Commercial high quality support for MySQL provided by the MySQL developers themselves. If you are interested in purchasing a support contract, please visit https://order.mysql.com/ to view our support options or to order support.
  • Consulting services. We have developers and consultants in 12 countries and partners in many other countries that can help you with almost any MySQL related issues. If you need consulting services, please email a good description of your needs to info@mysql.com! If we can't handle this ourselves we can usually find a partner or a developer that can help you with your problems.
  • We sell licenses for using MySQL as an embedded database. See section 1.3.4 MySQL Licensing and Support Costs. If you have a commercial product for which you need a fast, high quality database, but you can't afford to make your product Open Source, you can buy the right to use the MySQL server under a normal commercial copyright. If you are interested in this you can buy MySQL licenses at https://order.mysql.com/ or contact us at licensing@mysql.com.
  • Advertising. http://www.mysql.com/ is a very popular web site with more than 10,000,000 page views per months (January 2001). By putting a banner on this you are guaranteed to reach a lot of potential customers in the Open source, Linux and database community. If you are interested in this email advertising@mysql.com.
  • We are building a partner program to be able to provide MySQL services in every country. If you are interested in becoming a partner of MySQL AB please visit http://www.mysql.com/information/partners.html or email partner@mysql.com.
  • We provide MySQL training through our partner programs. For more information, please email info@mysql.com.
  • The MySQL brand has, since 1995, been associated with speed and reliability, and is known to be something you can depend upon. If you are interested in using the MySQL trademark in your marketing, you can email info@mysql.com about this.

The MySQL core values show our dedication to MySQL and Open Source.

We want MySQL to be:

  • The best and the most used database in the world.
  • Available and affordable for all.
  • Easy to use.
  • Continuously improved while remaining fast and safe.
  • Fun to use and improve.
  • Free from bugs.

MySQL AB and the people of MySQL AB:

  • Promote Open Source Philosophy and support the Open Source Community.
  • Aim to be good citizens.
  • Prefer partners that share our values and mind-set.
  • Answer mail and give support.
  • Are a virtual company, networking with others.
  • Work against software patents.

1.1.3 About This Manual

This manual is currently available in Texinfo, plain text, Info, HTML, PostScript, and PDF versions. The primary document is the Texinfo file. The HTML version is produced automatically using a modified version of texi2html. The plain text and Info versions are produced with makeinfo. The Postscript version is produced using texi2dvi and dvips. The PDF version is produced with pdftex.

This manual is written and maintained by David Axmark, Michael (Monty) Widenius, Jeremy Cole, and Paul DuBois. For other contributors, see section E Credits.

1.1.4 Conventions Used in This Manual

This manual uses certain typographical conventions:

constant
Constant-width font is used for command names and options; SQL statements; database, table and column names; C and Perl code; and environment variables. Example: ``To see how mysqladmin works, invoke it with the --help option.''
`filename'
Constant-width font with surrounding quotes is used for filenames and pathnames. Example: ``The distribution is installed under the `/usr/local/' directory.''
`c'
Constant-width font with surrounding quotes is also used to indicate character sequences. Example: ``To specify a wild card, use the `%' character.''
italic
Italic font is used for emphasis, like this.
boldface
Boldface font is used for access privilege names (for example, ``do not grant the process privilege lightly'') and occasionally to convey especially strong emphasis.

When commands are shown that are meant to be executed by a particular program, the program is indicated by a prompt shown before the command. For example, shell> indicates a command that you execute from your login shell, and mysql> indicates a command that you execute from the mysql client program:

shell> type a shell command here
mysql> type a mysql command here

Shell commands are shown using Bourne shell syntax. If you are using a csh-style shell, you may need to issue commands slightly differently. For example, the sequence to set an environment variable and run a command looks like this in Bourne shell syntax:

shell> VARNAME=value some_command

For csh, you would execute the sequence like this:

shell> setenv VARNAME value
shell> some_command

Often, database, table, and column names must be substituted into commands. To indicate that such substitution is necessary, this manual uses db_name, tbl_name and col_name. For example, you might see a statement like this:

mysql> SELECT col_name FROM db_name.tbl_name;

This means that if you were to enter a similar statement, you would supply your own database, table, and column names, perhaps like this:

mysql> SELECT author_name FROM biblio_db.author_list;

SQL statements may be written in uppercase or lowercase. When this manual shows a SQL statement, uppercase is used for particular keywords if those keywords are under discussion (to emphasize them) and lowercase is used for the rest of the statement. For example, you might see the following in a discussion of the SELECT statement:

mysql> SELECT count(*) FROM tbl_name;

On the other hand, in a discussion of the COUNT() function, the same statement would be written like this:

mysql> select COUNT(*) from tbl_name;

If no particular emphasis is intended, all keywords are written uniformly in uppercase.

In syntax descriptions, square brackets (`[' and `]') are used to indicate optional words or clauses:

DROP TABLE [IF EXISTS] tbl_name

When a syntax element consists of a number of alternatives, the alternatives are separated by vertical bars (`|'). When one member from a set of choices may be chosen, the alternatives are listed within square brackets (`[' and `]'):

TRIM([[BOTH | LEADING | TRAILING] [remstr] FROM] str)

When one member from a set of choices must be chosen, the alternatives are listed within braces (`{' and `}'):

{DESCRIBE | DESC} tbl_name {col_name | wild}

1.1.5 History of MySQL

We once started out with the intention of using mSQL to connect to our tables using our own fast low-level (ISAM) routines. However, after some testing we came to the conclusion that mSQL was not fast enough nor flexible enough for our needs. This resulted in a new SQL interface to our database but with almost the same API interface as mSQL. This API was chosen to ease porting of third-party code.

The derivation of the name MySQL is not perfectly clear. Our base directory and a large number of our libraries and tools have had the prefix ``my'' for well over 10 years. However, Monty's daughter (some years younger) is also named My. Which of the two gave its name to MySQL is still a mystery, even for us.

1.1.6 The Main Features of MySQL

The following list describes some of the important characteristics of MySQL:

  • Fully multi-threaded using kernel threads. This means it can easily use multiple CPUs if available.
  • C, C++, Eiffel, Java, Perl, PHP, Python and Tcl APIs. See section 8 MySQL APIs.
  • Works on many different platforms. See section 2.2.2 Operating Systems Supported by MySQL.
  • Many column types: signed/unsigned integers 1, 2, 3, 4, and 8 bytes long, FLOAT, DOUBLE, CHAR, VARCHAR, TEXT, BLOB, DATE, TIME, DATETIME, TIMESTAMP, YEAR, SET, and ENUM types. See section 6.2 Column Types.
  • Very fast joins using an optimized one-sweep multi-join.
  • Full operator and function support in the SELECT and WHERE parts of queries. For example:
    mysql> SELECT CONCAT(first_name, " ", last_name) FROM tbl_name
               WHERE income/dependents > 10000 AND age > 30;
    
  • SQL functions are implemented through a highly optimized class library and should be as fast as possible! Usually there isn't any memory allocation at all after query initialization.
  • Full support for SQL GROUP BY and ORDER BY clauses. Support for group functions (COUNT(), COUNT(DISTINCT ...), AVG(), STD(), SUM(), MAX() and MIN()).
  • Support for LEFT OUTER JOIN and RIGHT OUTER JOIN with ANSI SQL and ODBC syntax.
  • You can mix tables from different databases in the same query (as of Version 3.22).
  • A privilege and password system that is very flexible and secure, and allows host-based verification. Passwords are secure because all password traffic is encrypted when you connect to a server.
  • ODBC (Open-DataBase-Connectivity) support for Win32 (with source). All ODBC 2.5 functions and many others. For example, you can use MS Access to connect to your MySQL server. See section 8.3 MySQL ODBC Support.
  • Very fast B-tree disk tables with index compression.
  • Up to 32 indexes per table are allowed. Each index may consist of 1 to 16 columns or parts of columns. The maximum index length is 500 bytes (this may be changed when compiling MySQL). An index may use a prefix of a CHAR or VARCHAR field.
  • Fixed-length and variable-length records.
  • In-memory hash tables which are used as temporary tables.
  • Handles large databases. We are using MySQL with some databases that contain 50,000,000 records and we know of users that uses MySQL with 60,000 tables and about 5,000,000,000 rows
  • All columns have default values. You can use INSERT to insert a subset of a table's columns; those columns that are not explicitly given values are set to their default values.
  • Uses GNU Automake, Autoconf, and Libtool for portability.
  • Written in C and C++. Tested with a broad range of different compilers.
  • A very fast thread-based memory allocation system.
  • No memory leaks. MySQL has been tested with Purify, a commercial memory leakage detector.
  • Includes myisamchk, a very fast utility for table checking, optimization, and repair. All of the functionality of myisamchk is also available through the SQL interface as well. See section 4 MySQL Database Administration.
  • Full support for several different character sets, including ISO-8859-1 (Latin1), big5, ujis, and more. For example, the Scandinavian characters `@ringaccent{a}', `@"a' and `@"o' are allowed in table and column names.
  • All data are saved in the chosen character set. All comparisons for normal string columns are case insensitive.
  • Sorting is done according to the chosen character set (the Swedish way by default). It is possible to change this when the MySQL server is started up. To see an example of very advanced sorting, look at the Czech sorting code. MySQL supports many different character sets that can be specified at compile and run time.
  • Aliases on tables and columns are allowed as in the SQL92 standard.
  • DELETE, INSERT, REPLACE, and UPDATE return the number of rows that were changed (affected). It is possible to return the number of rows matched instead by setting a flag when connecting to the server.
  • Function names do not clash with table or column names. For example, ABS is a valid column name. The only restriction is that for a function call, no spaces are allowed between the function name and the `(' that follows it. See section 6.1.6 Is MySQL Picky About Reserved Words?.
  • All MySQL programs can be invoked with the --help or -? options to obtain online assistance.
  • The server can provide error messages to clients in many languages. See section 4.6.2 Non-English Error Messages.
  • Clients may connect to the MySQL server using TCP/IP Sockets, Unix Sockets (Unix), or Named Pipes (NT).
  • The MySQL-specific SHOW command can be used to retrieve information about databases, tables, and indexes. The EXPLAIN command can be used to determine how the optimizer resolves a query.

1.1.7 How Stable Is MySQL?

This section addresses the questions ``How stable is MySQL?'' and ``Can I depend on MySQL in this project?'' We will try to clarify some issues and to answer some of the more important questions that seem to concern many people. This section has been put together from information gathered from the mailing list (which is very active in reporting bugs).

At TcX, MySQL has worked without any problems in our projects since mid-1996. When MySQL was released to a wider public, we noticed that there were some pieces of ``untested code'' that were quickly found by the new users who made queries in a manner different than our own. Each new release has had fewer portability problems than the previous one (even though each has had many new features).

Each release of MySQL has been usable, and there have been problems only when users start to use code from the ``gray zones.'' Naturally, outside users don't know what the gray zones are; this section attempts to indicate those that are currently known. The descriptions deal with Version 3.23 of MySQL. All known and reported bugs are fixed in the latest version, with the exception of the bugs listed in the bugs section, which are things that are design-related. See section 1.4.7 Known errors and design deficiencies in MySQL.

MySQL is written in multiple layers and different independent modules. These modules are listed below with an indication of how well-tested each of them is:

The ISAM table handler -- Stable
This manages storage and retrieval of all data in MySQL Version 3.22 and earlier. In all MySQL releases there hasn't been a single (reported) bug in this code. The only known way to get a corrupted table is to kill the server in the middle of an update. Even that is unlikely to destroy any data beyond rescue, because all data are flushed to disk between each query. There hasn't been a single bug report about lost data because of bugs in MySQL.
The MyISAM table handler -- Stable
This is new in MySQL Version 3.23. It's largely based on the ISAM table code but has a lot of new and very useful features.
The parser and lexical analyser -- Stable
There hasn't been a single reported bug in this system for a long time.
The C client code -- Stable
No known problems. In early Version 3.20 releases, there were some limitations in the send/receive buffer size. As of Version 3.21, the buffer size is now dynamic up to a default of 16M.
Standard client programs -- Stable
These include mysql, mysqladmin, mysqlshow, mysqldump, and mysqlimport.
Basic SQL -- Stable
The basic SQL function system and string classes and dynamic memory handling. Not a single reported bug in this system.
Query optimizer -- Stable
Range optimizer -- Stable
Join optimizer -- Stable
Locking -- Gamma
This is very system-dependent. On some systems there are big problems using standard OS locking (fcntl()). In these cases, you should run the MySQL daemon with the --skip-locking flag. Problems are known to occur on some Linux systems, and on SunOS when using NFS-mounted file systems.
Linux threads -- Stable
The major problem found has been with the fcntl() call, which is fixed by using the --skip-locking option to mysqld. Some people have reported lockup problems with Version 0.5. LinuxThreads will need to be recompiled if you plan to use 1000+ concurrent connections. Although it is possible to run that many connections with the default LinuxThreads (however, you will never go above 1021), the default stack spacing of 2 MB makes the application unstable, and we have been able to reproduce a coredump after creating 1021 idle connections. See section 2.6.1 Linux Notes (All Linux Versions).
Solaris 2.5+ pthreads -- Stable
We use this for all our production work.
MIT-pthreads (Other systems) -- Stable
There have been no reported bugs since Version 3.20.15 and no known bugs since Version 3.20.16. On some systems, there is a ``misfeature'' where some operations are quite slow (a 1/20 second sleep is done between each query). Of course, MIT-pthreads may slow down everything a bit, but index-based SELECT statements are usually done in one time frame so there shouldn't be a mutex locking/thread juggling.
Other thread implementions -- Beta - Gamma
The ports to other systems are still very new and may have bugs, possibly in MySQL, but most often in the thread implementation itself.
LOAD DATA ..., INSERT ... SELECT -- Stable
Some people thought they had found bugs here, but these usually have turned out to be misunderstandings. Please check the manual before reporting problems!
ALTER TABLE -- Stable
Small changes in Version 3.22.12.
DBD -- Stable
Now maintained by Jochen Wiedmann (wiedmann@neckar-alb.de). Thanks!
mysqlaccess -- Stable
Written and maintained by Yves Carlier (Yves.Carlier@rug.ac.be). Thanks!
GRANT -- Stable
Big changes made in MySQL Version 3.22.12.
MyODBC (uses ODBC SDK 2.5) -- Gamma
It seems to work well with some programs.
Replication -- Beta / Gamma
We are still working on replication, so don't expect this to be rock solid yet. On the other hand, some MySQL users are already using this with good results.
BDB Tables -- Beta
The Berkeley DB code is very stable, but we are still improving the interface between MySQL and BDB tables, so it will take some time before this is as tested as the other table types.
InnoDB Tables -- Beta
This is a recent addition to MySQL. They appear to work good and can be used after some initial testing.
Automatic recovery of MyISAM tables - Beta
This only affects the new code that checks if the table was closed properly on open and executes an automatic check/repair of the table if it wasn't.
MERGE tables -- Beta / Gamma
The usage of keys on MERGE tables is still not that tested. The other part of the MERGE code is quite well tested.
FULLTEXT -- Beta
Text search seems to work, but is still not widely used.

MySQL AB provides e-mail support for paying customers, but the MySQL mailing list usually provides answers to common questions. Bugs are usually fixed right away with a patch; for serious bugs, there is almost always a new release.

1.1.8 How Big Can MySQL Tables Be?

MySQL Version 3.22 has a 4G limit on table size. With the new MyISAM in MySQL Version 3.23 the maximum table size is pushed up to 8 million terabytes (2 ^ 63 bytes).

Note, however, that operating systems have their own file size limits. Here are some examples:

Operating System File Size Limit
Linux-Intel 32 bit 2G, 4G or more, depends on Linux version
Linux-Alpha 8T (?)
Solaris 2.5.1 2G (possible 4G with patch)
Solaris 2.6 4G
Solaris 2.7 Intel 4G
Solaris 2.7 ULTRA-SPARC 8T (?)

On Linux 2.2 you can get bigger tables than 2G by using the LFS patch for the ext2 file system. On Linux 2.4 there exists also patches for ReiserFS to get support for big files.

This means that the table size for MySQL is normally limited by the operating system.

By default, MySQL tables have a maximum size of about 4G. You can check the maximum table size for a table with the SHOW TABLE STATUS command or with the myisamchk -dv table_name. See section 4.5.5 SHOW Syntax.

If you need bigger tables than 4G (and your operating system supports this), you should set the AVG_ROW_LENGTH and MAX_ROWS parameter when you create your table. See section 6.5.3 CREATE TABLE Syntax. You can also set these later with ALTER TABLE. See section 6.5.4 ALTER TABLE Syntax.

If your big table is going to be read-only, you could use myisampack to merge and compress many tables to one. myisampack usually compresses a table by at least 50%, so you can have, in effect, much bigger tables. See section 4.7.4 myisampack, The MySQL Compressed Read-only Table Generator.

You can go around the operating system file limit for MyISAM data files by using the RAID option. See section 6.5.3 CREATE TABLE Syntax.

Another solution can be the included MERGE library, which allows you to handle a collection of identical tables as one. See section 7.2 MERGE Tables.

1.1.9 Year 2000 Compliance

MySQL itself has no problems with Year 2000 (Y2K) compliance:

  • MySQL uses Unix time functions and has no problems with dates until 2069; all 2-digit years are regarded to be in the range 1970 to 2069, which means that if you store 01 in a year column, MySQL treats it as 2001.
  • All MySQL date functions are stored in one file `sql/time.cc' and coded very carefully to be year 2000-safe.
  • In MySQL Version 3.22 and later, the new YEAR column type can store years 0 and 1901 to 2155 in 1 byte and display them using 2 or 4 digits.

You may run into problems with applications that use MySQL in a way that is not Y2K-safe. For example, many old applications store or manipulate years using 2-digit values (which are ambiguous) rather than 4-digit values. This problem may be compounded by applications that use values such as 00 or 99 as ``missing'' value indicators.

Unfortunately, these problems may be difficult to fix, because different applications may be written by different programmers, each of whom may use a different set of conventions and date-handling functions.

Here is a simple demonstration illustrating that MySQL doesn't have any problems with dates until the year 2030:

mysql> DROP TABLE IF EXISTS y2k;
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE y2k (date date, date_time datetime, time_stamp timestamp);
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO y2k VALUES 
    -> ("1998-12-31","1998-12-31 23:59:59",19981231235959),
    -> ("1999-01-01","1999-01-01 00:00:00",19990101000000),
    -> ("1999-09-09","1999-09-09 23:59:59",19990909235959),
    -> ("2000-01-01","2000-01-01 00:00:00",20000101000000),
    -> ("2000-02-28","2000-02-28 00:00:00",20000228000000),
    -> ("2000-02-29","2000-02-29 00:00:00",20000229000000),
    -> ("2000-03-01","2000-03-01 00:00:00",20000301000000),
    -> ("2000-12-31","2000-12-31 23:59:59",20001231235959),
    -> ("2001-01-01","2001-01-01 00:00:00",20010101000000),
    -> ("2004-12-31","2004-12-31 23:59:59",20041231235959),
    -> ("2005-01-01","2005-01-01 00:00:00",20050101000000),
    -> ("2030-01-01","2030-01-01 00:00:00",20300101000000),
    -> ("2050-01-01","2050-01-01 00:00:00",20500101000000);
Query OK, 13 rows affected (0.01 sec)
Records: 13  Duplicates: 0  Warnings: 0

mysql> SELECT * FROM y2k;
+------------+---------------------+----------------+
| date       | date_time           | time_stamp     |
+------------+---------------------+----------------+
| 1998-12-31 | 1998-12-31 23:59:59 | 19981231235959 |
| 1999-01-01 | 1999-01-01 00:00:00 | 19990101000000 |
| 1999-09-09 | 1999-09-09 23:59:59 | 19990909235959 |
| 2000-01-01 | 2000-01-01 00:00:00 | 20000101000000 |
| 2000-02-28 | 2000-02-28 00:00:00 | 20000228000000 |
| 2000-02-29 | 2000-02-29 00:00:00 | 20000229000000 |
| 2000-03-01 | 2000-03-01 00:00:00 | 20000301000000 |
| 2000-12-31 | 2000-12-31 23:59:59 | 20001231235959 |
| 2001-01-01 | 2001-01-01 00:00:00 | 20010101000000 |
| 2004-12-31 | 2004-12-31 23:59:59 | 20041231235959 |
| 2005-01-01 | 2005-01-01 00:00:00 | 20050101000000 |
| 2030-01-01 | 2030-01-01 00:00:00 | 20300101000000 |
| 2050-01-01 | 2050-01-01 00:00:00 | 00000000000000 |
+------------+---------------------+----------------+
13 rows in set (0.00 sec)

This shows that the DATE and DATETIME types will not give any problems with future dates (they handle dates until the year 9999).

The TIMESTAMP type, which is used to store the current time, has a range up to only 2030-01-01. TIMESTAMP has a range of 1970 to 2030 on 32-bit machines (signed value). On 64-bit machines it handles times up to 2106 (unsigned value).

Even though MySQL is Y2K-compliant, it is your responsibility to provide unambiguous input. See section 6.2.2.1 Y2K Issues and Date Types for MySQL's rules for dealing with ambiguous date input data (data containing 2-digit year values).

1.2 MySQL Information Sources

1.2.1 Books About MySQL

For the latest book information, with user comments, please visit http://www.mysql.com/portal/books/html/index.html.

While this manual is still the right place for up to date technical information, its primary goal is to contain everything there is to know about MySQL. It is sometimes nice to have a bound book to read in bed or while you travel. Here is a list of books about MySQL and related subjects (in English).

By purchasing a book through these hyperlinks provided herein, you are contributing to the development of MySQL.

MySQL
Available Barnes and Noble
Publisher New Riders
Author Paul DuBois
Pub Date 1st Edition December 1999
ISBN 0735709211
Pages 800
Price $49.99 US
Downloadable examples samp_db distribution
Errata are available here

Foreword by Michael ``Monty'' Widenius, MySQL Moderator.

In MySQL, Paul DuBois provides you with a comprehensive guide to one of the most popular relational database systems. Paul has contributed to the online documentation for MySQL and is an active member of the MySQL community. The principal MySQL developer, Monty Widenius, and a network of his fellow developers reviewed the manuscript, and provided Paul with the kind of insight no one else could supply.

Instead of merely giving you a general overview of MySQL, Paul teaches you how to make the most of its capabilities. Through two sample database applications that run throughout the book, he gives you solutions to problems you're sure to face. He helps you integrate MySQL efficiently with third-party tools, such as PHP and Perl, enabling you to generate dynamic Web pages through database queries. He teaches you to write programs that access MySQL databases, and also provides a comprehensive set of references to column types, operators, functions, SQL syntax, MySQL programming, C API, Perl DBI, and PHP API. MySQL simply gives you the kind of information you won't find anywhere else.

If you use MySQL, this book provides you with:

  • An introduction to MySQL and SQL.
  • Coverage of MySQL's data types and how to use them.
  • Thorough treatment of how to write client programs in C.
  • A guide to using the Perl DBI and PHP APIs for developing command-line and Web-based applications.
  • Tips on administrative issues such as user accounts, backup, crash recovery, and security.
  • Help in choosing an ISP for MySQL access.
  • A comprehensive reference for MySQL's data types, operators, functions, and SQL statements and utilities.
  • Complete reference guides for MySQL's C API, the Perl DBI API, and PHP's MySQL-related functions.


MySQL & mSQL
Available Barnes and Noble
Publisher O'Reilly
Authors Randy Jay Yarger, George Reese & Tim King
Pub Date 1st Edition July 1999
ISBN 1-56592-434-7, Order Number: 4347
Pages 506
Price $34.95

This book teaches you how to use MySQL and mSQL, two popular and robust database products that support key subsets of SQL on both Linux and Unix systems. Anyone who knows basic C, Java, Perl, or Python can write a program to interact with a database, either as a stand-alone application or through a Web page. This book takes you through the whole process, from installation and configuration to programming interfaces and basic administration. Includes plenty of tutorial material.

Sams' Teach Yourself MySQL in 21 Days
Available Barnes and Noble
Publisher Sams
Authors Mark Maslakowski and Tony Butcher
Pub Date June 2000
ISBN 0672319144
Pages 650
Price $39.99

Sams' Teach Yourself MySQL in 21 Days is for intermediate Linux users who want to move into databases. A large share of the audience is Web developers who need a database to store large amounts of information that can be retrieved via the Web.

Sams' Teach Yourself MySQL in 21 Days is a practical, step-by-step tutorial. The reader will learn to design and employ this open source database technology into his or her Web site using practical, hands-on examples to follow.

E-Commerce Solutions with MySQL
Available Barnes and Noble
Publisher Prima Communications, Inc.
Authors N/A
Pub Date January 2000
ISBN 0761524452
Pages 500
Price $39.99

No description available.

MySQL and PHP from Scratch
Available Barnes and Noble
Publisher Que
Authors N/A
Pub Date September 2000
ISBN 0789724405
Pages 550
Price $34.99

This book puts together information on installing, setting up, and troubleshooting Apache, MySQL, PHP3, and IMP into one complete volume. You also learn how each piece is part of a whole by learning, step-by-step, how to create a web-based e-mail system. Learn to run the equivalent of Active Server Pages (ASP) using PHP3, set up an e-commerce site using a database and the Apache web server, and create a data entry system (such as sales, product quality tracking, customer preferences, etc) that no installation in the PC.

Professional MySQL Programming
Available Barnes and Noble
Publisher Wrox Press, Inc.
Authors N/A
Pub Date Late 2001
ISBN 1861005164
Pages 1000
Price $49.99

No description available.

Professional Linux Programming
Available Barnes and Noble
Publisher Wrox Press, Inc.
Authors N/A
Pub Date September 2000
ISBN 1861003013
Pages 1155
Price $47.99

In this follow-up to the best-selling Beginning Linux Programming, you will learn from the authors' real-world knowledge and experience of developing software for Linux; you'll be taken through the development of a sample 'DVD Store' application, with 'theme' chapters addressing different aspects of its implementation. Meanwhile, individual ``take-a-break'' chapters cover important topics that go beyond the bounds of the central theme. All focus on the practical aspects of programming, showing how crucial it is to choose the right tools for the job, use them as they should be used, and get things right first time.

PHP and MySQL Web Development
Available Barnes and Noble
Publisher Sams
Authors Luke Welling, Laura Thomson
Pub Date March 2001
ISBN 0672317842
Pages 700
Price $49.99

PHP and MySQL Web Development introduces you to the advantages of implementing both MySQL and PHP. These advantages are detailed through the provision of both statistics and several case studies. A practical web application is developed throughout the book, providing you with the tools necessary to implement a functional online database. Each function is developed separately, allowing you the choice to incorporate only those parts that you would like to implement. Programming concepts of the PHP language are highlighted, including functions which tie MySQL support into a PHP script and advanced topics regarding table manipulation.

Books recommended by the MySQL Developers

SQL-99 Complete, Really
Available Barnes and Noble
Publisher CMP Books
Authors Peter Gulutzan, Trudy Pelzer
Pub Date April 1999
ISBN 0879305681
Pages 1104
Price $55.96

This book contains complete descriptions of the new standards for syntax, data structures, and retrieval processes of SQL databases. As an example-based reference manual, it includes all of the CLI functions, information, schema tables, and status codes, as well as a working SQL database provided on the companion disk.

C, A reference manual
Available Barnes and Noble
Publisher Prentice Hall
Authors Samuel P. Harbison, Guy L. Steele
Pub Date September 1994
ISBN 0133262243
Pages 480
Price $35.99

A new and improved revision of the bestselling C language reference. This manual introduces the notion of "Clean C", writing C code that can be compiled as a C++ program, C programming style that emphasizes correctness, portability, maintainability, and incorporates the ISO C Amendment 1 (1994) which specifies new facilities for writing portable, international programs in C.

C++ for Real Programmers
Available Barnes and Noble
Publisher Academic Press, Incorporated
Authors Jeff Alger, Jim Keogh
Pub Date February 1998
ISBN 0120499428
Pages 388
Price $39.95

C++ For Real Programmers bridges the gap between C++ as described in beginner and intermediate-level books and C++ as it is practiced by experts. Numerous valuable techniques are described, organized into three simple themes: indirection, class hierarchies, and memory management. It also provides in-depth coverage of template creation, exception handling, pointers and optimization techniques. The focus of the book is on ANSI C++ and, as such, is compiler independent.

C++ For Real Programmers is a revision of Secrets of the C++ Masters and includes a new appendix comparing C++ with Java. The book comes with a 3.5" disk for Windows with source code.

Algorithms in C
Available Barnes and Noble
Publisher Addison Wesley Longman, Inc.
Authors Robert Sedgewick
Pub Date April 1990
ISBN 0201514257
Pages 648
Price $45.75

Algorithms in C describes a variety of algorithms in a number of areas of interest, including: sorting, searching, string-processing, and geometric, graph and mathematical algorithms. The book emphasizes fundamental techniques, providing readers with the tools to confidently implement, run, and debug useful algorithms.

Multithreaded Programming with Pthreads
Available Barnes and Noble
Publisher Prentice Hall
Authors Bil Lewis, Daniel J. Berg
Pub Date October 1997
ISBN 0136807291
Pages 432
Price $34.95

Based on the best-selling Threads Primer, Multithreaded Programming with Pthreads gives you a solid understanding of Posix threads: what they are, how they work, when to use them, and how to optimize them. It retains the clarity and humor of Threads Primer, but includes expanded comparisons to Win32 and OS/2 implementations. Code examples tested on all of the major UNIX platforms are featured along with detailed explanations of how and why they use threads.

Programming the PERL DBI: Database Programming with PERL
Available Barnes and Noble
Publisher O'Reilly & Associates, Incorporated
Authors Alligator Descartes, Tim Bunce
Pub Date February 2000
ISBN 1565926994
Pages 400
Price $27.96

Programming the Perl DBI is coauthored by Alligator Descartes, one of the most active members of the DBI community, and by Tim Bunce, the inventor of DBI. For the uninitiated, the book explains the architecture of DBI and shows you how to write DBI-based programs. For the experienced DBI dabbler, this book explains DBI's nuances and the peculiarities of each individual DBD.

The book includes:

  • An introduction to DBI and its design.
  • How to construct queries and bind parameters.
  • Working with database, driver, and statement handles.
  • Debugging techniques.
  • Coverage of each existing DBD.
  • A complete reference to DBI.


1.2.2 General SQL Information and Tutorials

The following book has been recommended by several people on the MySQL mailing list:

Judith S. Bowman, Sandra L. Emerson and Marcy Darnovsky
The Practical SQL Handbook: Using Structured Query Language
Second Edition
Addison-Wesley
ISBN 0-201-62623-3
http://www.awl.com

The following book has also received some recommendations by MySQL users:

Martin Gruber
Understanding SQL
ISBN 0-89588-644-8
Publisher Sybex 510 523 8233
Alameda, CA USA

A SQL tutorial is available on the net at http://w3.one.net/~jhoffman/sqltut.htm

1.2.3 Useful MySQL-related Links

Apart from the following links, you can find and download a lot of MySQL programs, tools and APIs from the Contrib directory.

MySQL

1.2.4 Tutorials and Manuals

MySQL Myths Debunked
MySQL used in the real world.
http://www.4t2.com/mysql
Information about the German MySQL mailing list.
http://www2.rent-a-database.de/mysql/
MySQL handbook in German.
http://www.bitmover.com:8888//home/bk/mysql
Web access to the MySQL BitKeeper repository.
http://www.analysisandsolutions.com/code/mybasic.htm
Beginners MySQL Tutorial on how to install and set up MySQL on a Windows machine.
http://www.devshed.com/Server_Side/MySQL/
A lot of MySQL tutorials.
http://mysql.hitstar.com/
MySQL manual in Chinese.
http://www.linuxplanet.com/linuxplanet/tutorials/1046/1/
Setting Up a MySQL-based Web site.
http://www.hotwired.com/webmonkey/backend/tutorials/tutorial1.html
MySQL-Perl tutorial.
http://www.iserver.com/support/contrib/perl5/modules.html
Installing new Perl modules that require locally installed modules.
http://www.hotwired.com/webmonkey/databases/tutorials/tutorial4.html
PHP/MySQL Tutorial.
http://www.useractive.com/
Hands on tutorial for MySQL.

1.2.5 Porting MySQL/Using MySQL on Different Systems

http://www.entropy.ch/software/macosx/mysql/
Binary of MySQL for Mac OS X Client. Includes information of how to build and use MySQL on Mac OS X.
http://xclave.macnn.com/MySQL/
The Mac OS Xclave. Running MySQL on Mac OS X.
http://www.prnet.de/RegEx/mysql.html
MySQL for Mac OS X Server.
http://www.latencyzero.com/macosx/mysql.html
Building MySQL for Mac OS X.
http://www.essencesw.com/Software/mysqllib.html
New Client libraries for the Mac OS Classic (Macintosh).
http://www.lilback.com/macsql/
Client libraries for Mac OS Classic (Macintosh).
http://sixk.maniasys.com/index_en.html
MySQL for Amiga

1.2.6 Perl-related Links

http://dbimysql.photoflux.com/
Perl DBI with MySQL FAQ.

1.2.7 MySQL Discussion Forums

http://www.weberdev.com/
Examples using MySQL; (check Top 20)
http://futurerealm.com/forum/futureforum.htm
FutureForum Web Discussion Software.

1.2.8 Commercial Applications that Support MySQL

http://www.supportwizard.com/
SupportWizard; Interactive helpdesk on the Web (This product includes a licensed copy of MySQL.)
http://www.sonork.com/
Sonork, Instant Messenger that is not only Internet oriented. It's focused on private networks and on small to medium companies. Client is free, server is free for up to 5 seats.
http://www.stweb.org/
StWeb - Stratos Web and Application server - An easy-to-use, cross platform, Internet/Intranet development and deployment system for development of web-enabled applications. The standard version of StWeb has a native interface to MySQL database.
http://www.rightnowtech.com/
Right Now Web; Web automation for customer service.
http://www.icaap.org/Bazaar/
Bazaar; Interactive Discussion Forums with Web interface.
http://www.phonesweep.com/
PhoneSweepT is the world's first commercial Telephone Scanner. Many break-ins in recent years have come not through the Internet, but through unauthorized dial-up modems. PhoneSweep lets you find these modems by repeatedly placing phone calls to every phone number that your organization controls. PhoneSweep has a built-in expert system that can recognize more than 250 different kinds of remote-access programs, including Carbon Copy(TM), pcANYWHERE(TM), and Windows NT RAS. All information is stored in the SQL database. It then generates a comprehensive report detailing which services were discovered on which dial-up numbers in your organization.

1.2.9 SQL Clients and Report Writers

urSQL
SQL Editor and Query Utility. Custom syntax highlighting, editable results grid, exportable result-sets, basic MySQL admin functions, Etc.. For Windows.
MySQL Data Manager
MySQL Data Manager * is platform independent web client (written in perl) for MySQL server over TCP/IP.
http://ksql.sourceforge.net/
KDE MySQL client.
http://www.ecker-software.de
A Windows GUI client by David Ecker.
http://www.icaap.org/software/kiosk/
Kiosk; a MySQL client for database management. Written in Perl. Will be a part of Bazaar.
http://www.casestudio.com/
Db design tool that supports MySQL 3.23.
http://home.skif.net/~voland/zeos/eng/index.html
Zeos - A client that supports MySQL, Interbase and PostgreSQL.
http://www.geocities.com/SiliconValley/Ridge/4280/GenericReportWriter/grwhome.html
A free report writer in Java
http://www.javaframework.de
MySQLExport - Export of MySQL create statements and data in a lot of different formats (SQL, HTML, CVS, text, ZIP, GZIP...)
http://dlabs.4t2.com
M2D, a MySQL Administration client for Windows. M2D supports administration of MySQL databases, creation of new databases and tables, editing, and more.
http://dlabs.4t2.com
Dexter, a small server written in Perl which can be used as a proxy server for MySQL or as a database extender.
http://www.scibit.com/Products/Software/Utils/Mascon.asp
Mascon is a powerful Win32 GUI for administering MySQL databases.
http://www.rtlabs.com/
MacSQL Monitor. GUI for MySQL, ODBC, and JDBC databases for the Mac OS.

1.2.10 Distributions that Include MySQL

http://www.suse.com/
SuSE Linux (6.1 and above)
http://www.redhat.com/
RedHat Linux (7.0 and above)
http://distro.conectiva.com.br
Conectiva Linux (4.0 and above)

1.2.11 Web Development Tools that Support MySQL

http://www.php.net/
PHP: A server-side HTML-embedded scripting language.
http://www.midgard-project.org
The Midgard Application Server; a powerful Web development environment based on MySQL and PHP.
http://www.smartworker.org
SmartWorker is a platform for Web application development.
http://xsp.lentus.se/
XSP: e(X)tendible (S)erver (P)ages and is a HTML embedded tag language written in Java (previously known as XTAGS.)
http://www.dbServ.de/
dbServ is an extension to a web server to integrate database output into your HTML code. You may use any HTML function in your output. Only the client will stop you. It works as standalone server or as Java servlet.
http://www.chilisoft.com/
Platform independent ASP from Chili!Soft
http://www.voicenet.com/~zellert/tjFM
A JDBC driver for MySQL.
http://www.wernhart.priv.at/php/
MySQL + PHP demos.
http://www.dbwww.com/
ForwardSQL: HTML interface to manipulate MySQL databases.
http://www.daa.com.au/~james/www-sql/
WWW-SQL: Display database information.
http://www.minivend.com/minivend/
Minivend: A Web shopping cart.
http://www.heitml.com/
HeiTML: A server-side extension of HTML and a 4GL language at the same time.
http://www.metahtml.com/
Metahtml: A Dynamic Programming Language for WWW Applications.
http://www.binevolve.com/
VelocityGen for Perl and Tcl.
http://hawkeye.net/
Hawkeye Internet Server Suite.
http://www.fastflow.com/
Network Database Connection For Linux
http://www.wdbi.net/
WDBI: Web browser as a universal front end to databases which supports MySQL well.
http://www.webgroove.com/
WebGroove Script: HTML compiler and server-side scripting language.
http://www.ihtml.com/
A server-side Web site scripting language.
ftp://ftp.igc.apc.org/pub/myodbc/README
How to use MySQL with ColdFusion on Solaris.
http://calistra.com/MySQL/
Calistra's ODBC MySQL Administrator.
http://www.webmerger.com
Webmerger - This CGI tool interprets files and generates dynamic output based on a set of simple tags. Ready-to-run drivers for MySQL and PostgreSQL through ODBC.
http://phpclub.net/
PHPclub - Tips and tricks for PHP.
http://www.penguinservices.com/scripts
MySQL and Perl Scripts.
http://www.widgetchuck.com
The Widgetchuck; Web Site Tools and Gadgets
http://www.adcycle.com/
AdCycle - advertising management software.
http://sourceforge.net/projects/pwpage/
pwPage - provides an extremely fast and simple approach to the creation of database forms. That is, if a database table exists and an HTML page has been constructed using a few simple guidelines, pwPage can be immediately used for table data selections, insertions, updates, deletions and selectable table content reviewing.
http://www.omnis-software.com/products/studio/studio.html
OMNIS Studio is a rapid application development (RAD) tool.
http://www.webplus.com
talentsoft Web+ 4.6 - a powerful and comprehensive development language for use in creating web-based client/server applications without writing complicated, low-level, and time-consuming CGI programs.

1.2.12 Database Design Tools with MySQL Support

http://www.mysql.com/documentation/dezign/
"DeZign for databases" is a database development tool that uses an entity relationship diagram (ERD).

1.2.13 Web Servers with MySQL Tools

ftp://ftp.kcilink.com/pub/
mod_auth_mysql, An Apache authentication module.
http://www.roxen.com/
The Roxen Challenger Web server.

1.2.14 Extensions for Other Programs

http://www.seawood.org/msql_bind/
MySQL support for BIND (The Internet Domain Name Server).
http://www.inet-interactive.com/sendmail/
MySQL support for Sendmail and Procmail.

1.2.15 Using MySQL with Other Programs

http://www.iserver.com/support/addonhelp/database/mysql/msaccess.html
Using MySQL with Access.
http://www.iserver.com/support/contrib/perl5/modules.html
Installing new Perl modules that require locally installed modules.

1.2.16 ODBC-related Links

http://www.iodbc.org/
Popular iODBC Driver Manager (libiodbc) now available as Open Source.
http://users.ids.net/~bjepson/freeODBC/
The FreeODBC Pages.
http://genix.net/unixODBC/
The unixODBC Project goals are to develop and promote unixODBC to be the definitive standard for ODBC on the Linux platform. This is to include GUI support for KDE.
http://www.sw-soft.com/products/BtrieveODBC/
A MySQL-based ODBC driver for Btrieve.

1.2.17 API-related Links

http://www.jppp.com/
Partially implemented TDataset-compatible components for MySQL.
http://www.riverstyx.net/qpopmysql/
qpopmysql - A patch to allow POP3 authentication from a MySQL database. There's also a link to Paul Khavkine's patch for Procmail to allow any MTA to deliver to users in a MySQL database.
http://www.pbc.ottawa.on.ca
Visual Basic class generator for Active X.
http://www.essencesw.com/Software/mysqllib.html
New Client libraries for the Mac OS Classic (Macintosh).
http://www.lilback.com/macsql/
Client libraries for the Macintosh.
http://www.essencesw.com/Plugins/mysqlplug.html
Plugin for REALbasic (for Macintosh)
http://www.iis.ee.ethz.ch/~neeri/macintosh/gusi-qa.html
A library that emulates BSD sockets and pthreads on Macintosh. This can be used if you want to compile the MySQL client library on Mac. It could probably even be sued to port MySQL to Macintosh, but we don't know of anyone that has tried that.
http://www.dedecker.net/jessie/scmdb/
SCMDB - an add-on for SCM that ports the MySQL C library to scheme (SCM). With this library scheme developers can make connections to a MySQL database and use embedded SQL in their programs.

1.2.18 Other MySQL-related Links

SAT
The Small Application Toolkit (SAT) is a collection of utilities intended to simplify the development of small, multi-user, GUI based applications in a (Microsoft -or- X) Windows Client / Unix Server environment.
http://www.wix.com/mysql-hosting/
Registry of Web providers who support MySQL.
http://www.softagency.co.jp/mysql/index.en.html
Links about using MySQL in Japan/Asia.
http://abattoir.cc.ndsu.nodak.edu/~nem/mysql/udf/
MySQL UDF Registry.
http://www.open.com.au/products.html
Commercial Web defect tracking system.
http://www.stonekeep.com/pts/
PTS: Project Tracking System.
http://tomato.nvgc.vt.edu/~hroberts/mot
Job and software tracking system.
http://www.cynergi.net/exportsql/
ExportSQL: A script to export data from Access95+.
http://SAL.KachinaTech.COM/H/1/MYSQL.html
SAL (Scientific Applications on Linux) MySQL entry.
http://www.infotech-nj.com/itech/index.shtml
A consulting company which mentions MySQL in the right company.
http://www.pmpcs.com/
PMP Computer Solutions. Database developers using MySQL and mSQL.
http://www.aewa.org/
Airborne Early Warning Association.
http://www.dedserius.com/y2kmatrix/
Y2K tester.

1.2.19 SQL and Database Interfaces

http://java.sun.com/products/jdbc/
The JDBC database access API.
http://www.gagme.com/mysql
Patch for mSQL Tcl.
http://www.amsoft.ru/easysql/
EasySQL: An ODBC-like driver manager.
http://www.lightlink.com/hessling/rexxsql.html
A REXX interface to SQL databases.
http://www.mytcl.cx/
Tcl interface based on tcl-sql with many bugfixes.
http://www.binevolve.com/~tdarugar/tcl-sql/
Tcl interface.
http://www.contrib.andrew.cmu.edu/~shadow/sql.html
SQL Reference Page with a lot of interesting links.

1.2.20 Examples of MySQL Use

http://www.little6.com/about/linux/
Little6 Inc., An online contract and job finding site that is powered by MySQL, PHP3, and Linux.
http://www.delec.com/is/products/prep/examples/BookShelf/index.html
DELECis - A tool that makes it very easy to create an automatically generated table documentation. They have used MySQL as an example.
http://www.worldrecords.com
World Records - A search engine for information about music that uses MySQL and PHP.
http://www.webtechniques.com/archives/1998/01/note/
A Contact Database using MySQL and PHP.
http://modems.rosenet.net/mysql/
Web based interface and Community Calendar with PHP.
http://www.odbsoft.com/cook/sources.htm
Perl package to generate html from a SQL table structure and for generating SQL statements from an html form.
http://www.gusnet.cx/proj/telsql/
Basic telephone database using DBI/DBD.
http://tecfa.unige.ch/guides/java/staf2x/ex/jdbc/coffee-break
JDBC examples by Daniel K. Schneider.
http://www.spade.com/linux/howto/PostgreSQL-HOWTO-41.html
SQL BNF
http://www.ooc.com/
Object Oriented Concepts Inc; CORBA applications with examples in source.
http://www.pbc.ottawa.on.ca/
DBWiz; Includes an example of how to manage cursors in VB.
http://keilor.cs.umass.edu/pluribus/
Pluribus is a free search engine that learns to improve the quality of its results over time. Pluribus works by recording which pages a user prefers among those returned for a query. A user votes for a page by selecting it; Pluribus then uses that knowledge to improve the quality of the results when someone else submits the same (or similar) query. Uses PHP and MySQL.
http://www.stopbit.com/
Stopbit - A technology news site using MySQL and PHP.
http://www.linuxsupportline.com/~kalendar/
KDE based calendar manager - The calendar manager has both single user (file based) and multi-user (MySQL database) support.
http://tim.desert.net/~tim/imger/
Example of storing/retrieving images with MySQL and CGI.
http://www.penguinservices.com/scripts
Online shopping cart system.
http://www.city-gallery.com/album/
Old Photo Album - The album is a collaborative popular history of photography project that generates all pages from data stored in a MySQL database. Pages are dynamically generated through a php3 interface to the database content. Users contribute images and descriptions. Contributed images are stored on the web server to avoid storing them in the database as BLOBs. All other information is stored on the shared MySQL server.

1.2.21 General Database Links

http://www.pcslink.com/~ej/dbweb.html
Database Jump Site
http://black.hole-in-the.net/guy/webdb/
Homepage of the webdb-l (Web Databases) mailing list.
http://www.symbolstone.org/technology/perl/DBI/index.html
Perl DBI/DBD modules homepage.
http://www.student.uni-koeln.de/cygwin/
Cygwin tools. Unix on top of Windows.
http://dbasecentral.com/
dbasecentral.com; Development and distribution of powerful and easy-to-use database applications and systems.
http://www.tek-tips.com/
Tek-Tips Forums are 800+ independent peer-to-peer non-commercial support forums for Computer Professionals. Features include automatic e-mail notification of responses, a links library, and member confidentiality guaranteed.
http://www.public.asu.edu/~peterjn/btree/
B-Trees: Balanced Tree Data Structures.
http://www.fit.qut.edu.au/~maire/baobab/lecture/sld001.htm
A lecture about B-Trees.

There are also many Web pages that use MySQL. See section B Some MySQL Users. Send any additions to this list to webmaster@mysql.com. We now require that you show a MySQL logo somewhere if you wish your site to be added. It is okay to have it on a ``used tools'' page or something similar.

1.2.22 MySQL Mailing Lists

This section introduces you to the MySQL mailing lists, and gives some guidelines as to how to use them.

1.2.22.1 The MySQL Mailing Lists

To subscribe to the main MySQL mailing list, send a message to the electronic mail address mysql-subscribe@lists.mysql.com.

To unsubscribe from the main MySQL mailing list, send a message to the electronic mail address mysql-unsubscribe@lists.mysql.com.

Only the address to which you send your messages is significant. The subject line and the body of the message are ignored.

If your reply address is not valid, you can specify your address explicitly. Adding a hyphen to the subscribe or unsubscribe command word, followed by your address with the `@' character in your address replaced by a `='. For example, to subscribe your_name@host.domain, send a message to mysql-subscribe-your_name=host.domain@lists.mysql.com.

Mail to mysql-subscribe@lists.mysql.com or mysql-unsubscribe@lists.mysql.com is handled automatically by the ezmlm mailing list processor. Information about ezmlm is available at The ezmlm Website.

To post a message to the list itself, send your message to mysql@lists.mysql.com. However, please do not send mail about subscribing or unsubscribing to mysql@lists.mysql.com, because any mail sent to that address is distributed automatically to thousands of other users.

Your local site may have many subscribers to mysql@lists.mysql.com. If so, it may have a local mailing list, so that messages sent from lists.mysql.com to your site are propagated to the local list. In such cases, please contact your system administrator to be added to or dropped from the local MySQL list.

If you wish to have traffic for a mailing list go to a separate mailbox in your mail program, set up a filter based on the message headers. You can use either the List-ID: or Delivered-To: headers to identify list messages.

The following MySQL mailing lists exist:

announce-subscribe@lists.mysql.com announce
This is for announcement of new versions of MySQL and related programs. This is a low volume list all MySQL users should subscribe to.
mysql-subscribe@lists.mysql.com mysql
The main list for general MySQL discussion. Please note that some topics are better discussed on the more-specialized lists. If you post to the wrong list, you may not get an answer!
mysql-digest-subscribe@lists.mysql.com mysql-digest
The mysql list in digest form. That means you get all individual messages, sent as one large mail message once a day.
bugs-subscribe@lists.mysql.com bugs
On this list you should only post a full, repeatable bug report using the mysqlbug script (if you are running on Windows, you should include a description of the operating system and the MySQL version). Preferably, you should test the problem using the latest stable or development version of MySQL before posting! Anyone should be able to repeat the bug by just using mysql test < script on the included test case. All bugs posted on this list will be corrected or documented in the next MySQL release! If there are only small code changes involved, we will also post a patch that fixes the problem.
bugs-digest-subscribe@lists.mysql.com bugs-digest
The bugs list in digest form.
internals-subscribe@lists.mysql.com internals
A list for people who work on the MySQL code. On this list one can also discuss MySQL development and post patches.
internals-digest-subscribe@lists.mysql.com internals-digest
A digest version of the internals list.
java-subscribe@lists.mysql.com java
Discussion about MySQL and Java. Mostly about the JDBC drivers.
java-digest-subscribe@lists.mysql.com java-digest
A digest version of the java list.
win32-subscribe@lists.mysql.com win32
All things concerning MySQL on Microsoft operating systems such as Win95, Win98, NT, and Win2000.
win32-digest-subscribe@lists.mysql.com win32-digest
A digest version of the win32 list.
myodbc-subscribe@lists.mysql.com myodbc
All things about connecting to MySQL with ODBC.
myodbc-digest-subscribe@lists.mysql.com myodbc-digest
A digest version of the myodbc list.
plusplus-subscribe@lists.mysql.com plusplus
All things concerning programming with the C++ API to MySQL.
plusplus-digest-subscribe@lists.mysql.com plusplus-digest
A digest version of the plusplus list.
msql-mysql-modules-subscribe@lists.mysql.com msql-mysql-modules
A list about the Perl support in MySQL. msql-mysql-modules
msql-mysql-modules-digest-subscribe@lists.mysql.com msql-mysql-modules-digest
A digest version of the msql-mysql-modules list.

You subscribe or unsubscribe to all lists in the same way as described above. In your subscribe or unsubscribe message, just put the appropriate mailing list name rather than mysql. For example, to subscribe to or unsubscribe from the myodbc list, send a message to myodbc-subscribe@lists.mysql.com or myodbc-unsubscribe@lists.mysql.com.

If you can't get an answer for your questions from the mailing list, one option is to pay for support from MySQL AB, which will put you in direct contact with MySQL developers. See section 1.3.5 Types of Commercial Support.

The following table shows some MySQL mailing in other languages than English. Note that these are not operated by MySQL AB, so we can't guarantee the quality on these.

mysql-france-subscribe@yahoogroups.com A French mailing list
list@tinc.net A Korean mailing list
Email subscribe mysql your@email.address to this list.
mysql-de-request@lists.4t2.com A German mailing list
Email subscribe mysql-de your@email.address to this list. You can find information about this mailing list at http://www.4t2.com/mysql.
mysql-br-request@listas.linkway.com.br A Portugese mailing list
Email subscribe mysql-br your@email.address to this list.
mysql-alta@elistas.net A Spanish mailing list
Email subscribe mysql your@email.address to this list.

1.2.22.2 Asking Questions or Reporting Bugs

Before posting a bug report or question, please do the following:

If you can't find an answer in the manual or the archives, check with your local MySQL expert. If you still can't find an answer to your question, go ahead and read the next section about how to send mail to mysql@lists.mysql.com.

1.2.22.3 How to Report Bugs or Problems

Writing a good bug report takes patience, but doing it right the first time saves time for us and for you. A good bug report containing a full test case for the bug will make it very likely that we will fix it in the next release. This section will help you write your report correctly so that you don't waste your time doing things that may not help us much or at all.

We encourage everyone to use the mysqlbug script to generate a bug report (or a report about any problem), if possible. mysqlbug can be found in the `scripts' directory in the source distribution, or, for a binary distribution, in the `bin' directory under your MySQL installation directory. If you are unable to use mysqlbug, you should still include all the necessary information listed in this section.

The mysqlbug script helps you generate a report by determining much of the following information automatically, but if something important is missing, please include it with your message! Please read this section carefully and make sure that all the information described here is included in your report.

The normal place to report bugs and problems is mysql@lists.mysql.com. If you can make a test case that clearly demonstrates the bug, you should post it to the bugs@lists.mysql.com list. Note that on this list you should only post a full, repeatable bug report using the mysqlbug script. If you are running on Windows, you should include a description of the operating system and the MySQL version. Preferably, you should test the problem using the latest stable or development version of MySQL before posting! Anyone should be able to repeat the bug by just using ``mysql test < script'' on the included test case or run the shell or perl script that is included in the bug report. All bugs posted on the bugs list will be corrected or documented in the next MySQL release! If there are only small code changes involved to correct this problem, we will also post a patch that fixes the problem.

Remember that it is possible to respond to a message containing too much information, but not to one containing too little. Often people omit facts because they think they know the cause of a problem and assume that some details don't matter. A good principle is: if you are in doubt about stating something, state it! It is a thousand times faster and less troublesome to write a couple of lines more in your report than to be forced to ask again and wait for the answer because you didn't include enough information the first time.

The most common errors are that people don't indicate the version number of the MySQL distribution they are using, or don't indicate what platform they have MySQL installed on (including the platform version number). This is highly relevant information, and in 99 cases out of 100 the bug report is useless without it! Very often we get questions like, ``Why doesn't this work for me?'' then we find that the feature requested wasn't implemented in that MySQL version, or that a bug described in a report has been fixed already in newer MySQL versions. Sometimes the error is platform dependent; in such cases, it is next to impossible to fix anything without knowing the operating system and the version number of the platform.

Remember also to provide information about your compiler, if it is related to the problem. Often people find bugs in compilers and think the problem is MySQL-related. Most compilers are under development all the time and become better version by version. To determine whether or not your problem depends on your compiler, we need to know what compiler is used. Note that every compiling problem should be regarded as a bug report and reported accordingly.

It is most helpful when a good description of the problem is included in the bug report. That is, a good example of all the things you did that led to the problem and the problem itself exactly described. The best reports are those that include a full example showing how to reproduce the bug or problem. See section G.1.6 Making a test case when you experience table corruption.

If a program produces an error message, it is very important to include the message in your report! If we try to search for something from the archives using programs, it is better that the error message reported exactly matches the one that the program produces. (Even the case should be observed!) You should never try to remember what the error message was; instead, copy and paste the entire message into your report!

If you have a problem with MyODBC, you should try to generate a MyODBC trace file. See section 8.3.7 Reporting Problems with MyODBC.

Please remember that many of the people who will read your report will do so using an 80-column display. When generating reports or examples using the mysql command line tool, you should therefore use the --vertical option (or the \G statement terminator) for output that would exceed the available width for such a display (for example, with the EXPLAIN SELECT statement; see the example below).

Please include the following information in your report:

  • The version number of the MySQL distribution you are using (for example, MySQL Version 3.22.22). You can find out which version you are running by executing mysqladmin version. mysqladmin can be found in the `bin' directory under your MySQL installation directory.
  • The manufacturer and model of the machine you are working on.
  • The operating system name and version. For most operating systems, you can get this information by executing the Unix command uname -a.
  • Sometimes the amount of memory (real and virtual) is relevant. If in doubt, include these values.
  • If you are using a source distribution of MySQL, the name and version number of the compiler used is needed. If you have a binary distribution, the distribution name is needed.
  • If the problem occurs during compilation, include the exact error message(s) and also a few lines of context around the offending code in the file where the error occurred.
  • If mysqld died, you should also report the query that crashed mysqld. You can usually find this out by running mysqld with logging enabled. See section G.1.5 Using log files to find cause of errors in mysqld.
  • If any database table is related to the problem, include the output from mysqldump --no-data db_name tbl_name1 tbl_name2 .... This is very easy to do and is a powerful way to get information about any table in a database that will help us create a situation matching the one you have.
  • For speed-related bugs or problems with SELECT statements, you should always include the output of EXPLAIN SELECT ..., and at least the number of rows that the SELECT statement produces. The more information you give about your situation, the more likely it is that someone can help you! For example, the following is an example of a very good bug report (it should of course be posted with the mysqlbug script): Example run using the mysql command line tool (note the use of the \G statement terminator for statements whose output width would otherwise exceed that of an 80-column display device):
    mysql> SHOW VARIABLES;
    mysql> SHOW COLUMNS FROM ...\G
           <output from SHOW COLUMNS>
    mysql> EXPLAIN SELECT ...\G
           <output from EXPLAIN>
    mysql> FLUSH STATUS;
    mysql> SELECT ...;
           <A short version of the output from SELECT,
           including the time taken to run the query>
    mysql> SHOW STATUS;
           <output from SHOW STATUS>
    
  • If a bug or problem occurs while running mysqld, try to provide an input script that will reproduce the anomaly. This script should include any necessary source files. The more closely the script can reproduce your situation, the better. If you can make a repeatable test case, you should post this to bugs@lists.mysql.com for a high priority treatment! If you can't provide a script, you should at least include the output from mysqladmin variables extended-status processlist in your mail to provide some information of how your system is performing!
  • If you can't produce a test case in a few rows, or if the test table is too big to be mailed to the mailing list (more than 10 rows), you should dump your tables using mysqldump and create a `README' file that describes your problem. Create a compressed archive of your files using tar and gzip or zip, and use ftp to transfer the archive to ftp://support.mysql.com/pub/mysql/secret/. Then send a short description of the problem to bugs@lists.mysql.com.
  • If you think that MySQL produces a strange result from a query, include not only the result, but also your opinion of what the result should be, and an account describing the basis for your opinion.
  • When giving an example of the problem, it's better to use the variable names, table names, etc., that exist in your actual situation than to come up with new names. The problem could be related to the name of a variable or table! These cases are rare, perhaps, but it is better to be safe than sorry. After all, it should be easier for you to provide an example that uses your actual situation, and it is by all means better for us. In case you have data you don't want to show to others, you can use ftp to transfer it to ftp://support.mysql.com/pub/mysql/secret/. If the data are really top secret and you don't want to show them even to us, then go ahead and provide an example using other names, but please regard this as the last choice.
  • Include all the options given to the relevant programs, if possible. For example, indicate the options that you use when you start the mysqld daemon and that you use to run any MySQL client programs. The options to programs like mysqld and mysql, and to the configure script, are often keys to answers and are very relevant! It is never a bad idea to include them anyway! If you use any modules, such as Perl or PHP, please include the version number(s) of those as well.
  • If your question is related to the privilege system, please include the output of mysqlaccess, the output of mysqladmin reload, and all the error messages you get when trying to connect! When you test your privileges, you should first run mysqlaccess. After this, execute mysqladmin reload version and try to connect with the program that gives you trouble. mysqlaccess can be found in the `bin' directory under your MySQL installation directory.
  • If you have a patch for a bug, that is good, but don't assume the patch is all we need, or that we will use it, if you don't provide some necessary information, such as test cases showing the bug that your patch fixes. We might find problems with your patch or we might not understand it at all; if so, we can't use it. If we can't verify exactly what the patch is meant for, we won't use it. Test cases will help us here. Show that the patch will handle all the situations that may occur. If we find a borderline case (even a rare one) where the patch won't work, it may be useless.
  • Guesses about what the bug is, why it occurs, or what it depends on, are usually wrong. Even the MySQL team can't guess such things without first using a debugger to determine the real cause of a bug.
  • Indicate in your mail message that you have checked the reference manual and mail archive so others know that you have tried to solve the problem yourself.
  • If you get a parse error, please check your syntax closely! If you can't find something wrong with it, it's extremely likely that your current version of MySQL doesn't support the query you are using. If you are using the current version and the manual at http://www.mysql.com/documentation/manual.php doesn't cover the syntax you are using, MySQL doesn't support your query. In this case, your only options are to implement the syntax yourself or e-mail mysql-licensing@mysql.com and ask for an offer to implement it! If the manual covers the syntax you are using, but you have an older version of MySQL, you should check the MySQL change history to see when the syntax was implemented. In this case, you have the option of upgrading to a newer version of MySQL. See section F MySQL change history.
  • If you have a problem such that your data appears corrupt or you get errors when you access some particular table, you should first check and then try repairing your tables with myisamchk or CHECK TABLE and REPAIR TABLE. See section 4 MySQL Database Administration.
  • If you often get corrupted tables you should try to find out when and why this happens! In this case, the `mysql-data-directory/'hostname'.err' file may contain some information about what happened. See section 4.9.1 The Error Log. Please include any relevant information from this file in your bug report! Normally mysqld should NEVER crash a table if nothing killed it in the middle of an update! If you can find the cause of mysqld dying, it's much easier for us to provide you with a fix for the problem! See section A.1 How to Determine What Is Causing Problems.
  • If possible, download and install the most recent version of MySQL and check whether or not it solves your problem. All versions of MySQL are thoroughly tested and should work without problems! We believe in making everything as backward compatible as possible, and you should be able to switch MySQL versions in minutes! See section 2.2.3 Which MySQL Version to Use.

If you are a support customer, please cross-post the bug report to mysql-support@mysql.com for higher priority treatment, as well as to the appropriate mailing list to see if someone else has experienced (and perhaps solved) the problem.

For information on reporting bugs in MyODBC, see section 8.3.4 How to Report Problems with MyODBC.

For solutions to some common problems, see See section A Problems and Common Errors.

When answers are sent to you individually and not to the mailing list, it is considered good etiquette to summarize the answers and send the summary to the mailing list so that others may have the benefit of responses you received that helped you solve your problem!

1.2.22.4 Guidelines for Answering Question on the Mailing List

If you consider your answer to have broad interest, you may want to post it to the mailing list instead of replying directly to the individual who asked. Try to make your answer general enough that people other than the original poster may benefit from it. When you post to the list, please make sure that your answer is not a duplication of a previous answer.

Try to summarize the essential part of the question in your reply; don't feel obliged to quote the entire original message.

Please don't post mail messages from your browser with HTML mode turned on! Many users don't read mail with a browser!

1.3 MySQL Licensing and Support

This section describes MySQL support and licensing arrangements:

1.3.1 MySQL Licensing Policy

The formal terms of the GPL license can be found at section K GNU GENERAL PUBLIC LICENSE. Basically, our licensing policy and interpretation of the GPL is as follows:

Note that older versions of MySQL are still using a more strict license. See the documentation for that version for more information. If you need a commercial MySQL license, because the GPL license doesn't suit your application, you can buy one at https://order.mysql.com/.

For normal internal use, MySQL costs nothing. You do not have to pay us if you do not want to.

A license is required if:

  • You link a program, that is not free software, with code from the MySQL server or clients that has the GPL copyright. This happens for example when you use MySQL as an embedded server in your applications or when you add not free extensions to the MySQL server. In this case your application/code would also become GPL through the GPL license that acts as a virus. By licensing MySQL server from MySQL AB under a commercial license you will avoid this problem. See http://www.gnu.org/copyleft/gpl-faq.html.
  • You have a commercial application that ONLY works with MySQL and ships the application with the MySQL server. This is because we view this as linking even if it is done over the network.
  • You have a distribution of MySQL and you don't provide the source code for your copy of the MySQL server, as defined in the GPL license.

A license is NOT required if:

  • You do not need a license to include the client code in commercial programs. The client part of MySQL licensed with the LGPL GNU Library General Public License. The mysql command-line client includes code from the readline library that is under the GPL.
  • If your use of MySQL does not require a license, but you like MySQL and want to encourage further development, you are certainly welcome to purchase a license or MySQL support anyway.
  • If you use MySQL in a commercial context such that you profit by its use, we ask that you further the development of MySQL by purchasing some level of support. We feel that if MySQL helps your business, it is reasonable to ask that you help MySQL. (Otherwise, if you ask us support questions, you are not only using for free something into which we've put a lot a work, you're asking us to provide free support, too.)

For circumstances under which a MySQL license is required, you need a license per machine that runs the mysqld server. However, a multiple-CPU machine counts as a single machine, and there is no restriction on the number of MySQL servers that run on one machine, or on the number of clients concurrently connected to a server running on that machine!

If you have any questions as to whether or not a license is required for your particular use of MySQL, please read this again and then contact us. See section 1.3.4.2 Contact Information.

If you require a MySQL license, the easiest way to pay for it is to use the license form on MySQL's secure server at https://order.mysql.com/. Other forms of payment are discussed in section 1.3.4.1 Payment information.

1.3.2 Copyrights Used by MySQL

There are several different copyrights on the MySQL distribution:

  1. The MySQL-specific source needed to build the mysqlclient library is licensed under the LGPL and programs in the `client' directory is GPL. Each file has a header that shows which copyright is used for that file.
  2. The client library and the (GNU getopt) library are covered by the ``GNU LIBRARY GENERAL PUBLIC LICENSE.'' See section L GNU LESSER GENERAL PUBLIC LICENSE.
  3. Some parts of the source (the regexp library) are covered by a Berkeley-style copyright.
  4. All the source in the server and the (GNU readline) library is covered by the ``GNU GENERAL PUBLIC LICENSE.'' See section K GNU GENERAL PUBLIC LICENSE. This is also available as the file `COPYING' in the distributions.

One goal is that the SQL client library should be free enough that it is possible to add MySQL support into commercial products without a license. For this reason, we chose the LGPL license for the client code.

This means that you can use MySQL for free with any program that uses any of the free software licenses. MySQL is also free for any end user for his own or company usage.

However, if you use MySQL for something important to you, you may want to help secure its development by purchasing licenses or a support contract. See section 1.3.5 Types of Commercial Support.

1.3.2.1 Copyright Changes

Version 3.22 of MySQL is still using a more strict license. See the documentation for that version for more information.

1.3.3 Example Licensing Situations

This section describes some situations illustrating whether or not you must license the MySQL server. Generally these examples involve providing MySQL as an integral part of a product.

Note that a single MySQL license covers any number of CPUs and mysqld servers on a machine! There is no artificial limit on the number of clients that connect to the server in any way.

1.3.3.1 Selling Products that use MySQL

To determine whether or not you need a MySQL license when selling your application, you should ask whether the proper functioning of your application is dependent on the use of MySQL and whether you include the MySQL server with your product. There are several cases to consider:

  • Does your application require MySQL to function properly?
  • If your product requires MySQL, you need a license for any machine that runs the mysqld server. For example, if you've designed your application around MySQL, then you've really made a commercial product that requires the engine, so you need a license.
  • If your application does not require MySQL, you do not need to obtain a license. For example, if using MySQL just adds some new optional features to your product (such as adding logging to a database if MySQL is used rather than logging to a text file), it should fall within normal use, and a license would not be required.
  • In other words, you need a license if you sell a product designed specifically for use with MySQL or that requires the MySQL server to function at all. This is true whether or not you provide MySQL for your client as part of your product distribution.
  • It also depends on what you're doing for the client. Do you plan to provide your client with detailed instructions on installing MySQL with your software? Then your product may be contingent on the use of MySQL; if so, you need to buy a license. If you are simply tying into a database that you expect already to have been installed by the time your software is purchased, then you probably don't need a license.

1.3.3.2 ISP MySQL Services

Internet Service Providers (ISPs) often host MySQL servers for their customers. With the GPL license this does not require a license.

On the other hand, we do encourage people to use ISPs that have MySQL support, as this will give them the confidence that if they have some problem with their MySQL installation, their ISP will be able to solve the problem for them (in some cases with the help from the MySQL development team).

All ISPs that want to keep themselves up-to-date should subscribe to our announce mailing list so that they can be aware of fatal issues that may be relevant for their MySQL installations.

Note that if the ISP doesn't have a license for MySQL, it should give its customers at least read access to the source of the MySQL installation so that its customer can verify that it is patched correctly.

1.3.3.3 Running a Web Server Using MySQL

If you use MySQL in conjunction with a Web server on Unix, you don't have to pay for a license.

This is true even if you run a commercial Web server that uses MySQL, because you are not selling an embedded MySQL version yourself. However, in this case we would like you to purchase MySQL support, because MySQL is helping your enterprise.

1.3.4 MySQL Licensing and Support Costs

Our current license prices are shown below. To make a purchase, please visit https://order.mysql.com/.

If you pay by credit card, the currency is EURO (European Union Euro) so the prices will differ slightly.

Number of licenses Per copy
1-9 230 EURO
10-24 138 EURO
25-49 117 EURO
50-99 102 EURO
100-249 91 EURO
250-499 76 EURO
500-999 66 EURO

For high volume (OEM) purchases, please contact sales@mysql.com.

For OEM purchases, you must act as the middle-man for eventual problems or extension requests from your users. We also require that OEM customers have at least an extended e-mail support contract. Note that OEM licenses only apply for products where the user doesn't have direct access to the MySQL server (embedded system). In other words, the MySQL server should only be used with the application that was supplied you.

If you have a low-margin, high-volume product, you can always talk to us about other terms (for example, a percent of the sale price). If you do, please be informative about your product, pricing, market, and any other information that may be relevant.

A full-price license is not a support agreement and includes very minimal support. This means that we try to answer any relevant questions. If the answer is in the documentation, we will direct you to the appropriate section. If you have not purchased a license or support, we probably will not answer at all.

If you discover what we consider a real bug, we are likely to fix it in any case. But if you pay for support we will notify you about the fix status instead of just fixing it in a later release.

More comprehensive support is sold separately. Descriptions of what each level of support includes are given in section 1.3.5 Types of Commercial Support. Costs for the various types of commercial support are shown below. Support level prices are in EURO (European Union Euro). One EURO is about 1.06 USD.

Type of support Cost per year
Basic e-mail support. See section 1.3.5.1 Basic E-mail Support. EURO 200
Extended e-mail support See section 1.3.5.2 Extended E-mail Support. EURO 1000
Login support See section 1.3.5.3 Login Support. EURO 2000
Extended login support See section 1.3.5.4 Extended Login Support. EURO 5000
Telephone support See section 1.3.5.5 Telephone Support. EURO 12000

You may upgrade from any lower level of support to a higher level of support for the difference in price between the two support levels.

We do also provide telephone support (mostly emergency support but also 24/7 support). This support option doesn't however have a fixed price but is negotiated for case to case. If you are interested in this option you can email sales@mysql.com and tell us about your needs.

Note that as our sales staff is very busy, it may take some time until your request is handled. Our support staff does however always answer promptly to support questions!

1.3.4.1 Payment information

Currently we can take SWIFT payments, checks, or credit cards.

Payment should be made to:

Postgirot Bank AB
105 06 STOCKHOLM, SWEDEN

MySQL AB
BOX 6434
11382 STOCKHOLM, SWEDEN

SWIFT address: PGSI SESS
Account number: 96 77 06 - 3

Specify: license and/or support and your name and e-mail address.

In Europe and Japan you can use EuroGiro (that should be less expensive) to the same account.

If you want to pay by check, make it payable to ``MySQL Finland AB'' and mail it to the address below:

MySQL AB
BOX 6434, Torsgatan 21
11382 STOCKHOLM, SWEDEN

If you want to pay by credit card over the Internet, you can use MySQL AB's secure license form.

You can also print a copy of the license form, fill it in, and send it by fax to:

+46-8-729 69 05

If you want us to bill you, you can use the license form and write ``bill us'' in the comment field. You can also mail a message to sales@mysql.com (not mysql@lists.mysql.com!) with your company information and ask us to bill you.

1.3.4.2 Contact Information

For commercial licensing, please contact the MySQL licensing team. The much preferred method is by e-mail to licensing@mysql.com. Fax is also possible but handling of these may take much longer (Fax +46-8-729 69 05).

If you represent a business that is interested in partnering with MySQL, please send e-mail to partner@mysql.com.

For timely, precise answers to technical questions about MySQL you should order one of our support contracts. MySQL support is provided by the MySQL developers so the standard is extremely high.

If you are interested in placing a banner advertisement on our Web site, please send e-mail to advertising@mysql.com.

If you are interested in any of the jobs listed in our jobs section, please send e-mail to jobs@mysql.com.

For general discussion amongst our many users, please direct your attention to the appropriate mailing list.

For general information inquires, please send e-mail to info@mysql.com.

For questions or comments about the workings or content of the Web site, please send e-mail to webmaster@mysql.com.

1.3.5 Types of Commercial Support

The following is true of all support options:

  • The support is per year.
  • We will fix, or provide a reasonable workaround for any repeatable bug.
  • We will give a reasonable effort to find and fix any other MySQL related bug.
  • The higher level of support contract the more effort we will put into finding a solution to your problems.
  • The following is true for all support contracts except Basic email support: For non-bug related things, like helping you optimize your queries or your system, extending MySQL with new functionality, etc., we charge 200 EURO/hour, which is deducted from your support contract. In other words, if you have login support (2000 EURO), you can expect us to work up to 10 hours to help you with things like this.

1.3.5.1 Basic E-mail Support

Basic e-mail support is a very inexpensive support option and should be thought of more as a way to support our development of MySQL than as a real support option. We at MySQL do give a lot of free support in all the different MySQL lists, and the money we get from basic e-mail support is largely used to make this possible.

At this support level, the MySQL mailing lists are the preferred means of communication. Questions normally should be mailed to the primary mailing list (mysql@lists.mysql.com) or one of the other regular lists (for example, win32@lists.mysql.com for Windows-related MySQL questions), as someone else already may have experienced and solved the problem you have. See section 1.2.22.2 Asking Questions or Reporting Bugs.

However, by purchasing basic e-mail support, you also have access to the support address mysql-support@mysql.com, which is not available as part of the minimal support that you get by purchasing a MySQL license. This means that for especially critical questions, you can cross-post your message to mysql-support@mysql.com. (If the message contains sensitive data, you should post only to mysql-support@mysql.com.)

REMEMBER! to ALWAYS include your registration number and expiration date when you send a message to mysql-support@mysql.com.

Note that if you have encountered a critical, repeatable bug, and follow the rules outlined in the manual section of how to report bugs and send it to bugs@lists.mysql.com, we promise to try to fix this as soon as possible, regardless of your support level! See section 1.2.22.3 How to Report Bugs or Problems.

Basic e-mail support includes the following types of service:

  • If your question is already answered in the manual, we will inform you of the correct section in which you can find the answer. If the answer is not in the manual, we will point you in the right direction to solve your problem.
  • We guarantee a timely answer for your e-mail messages. We can't guarantee that we can solve any problem, but at least you will receive an answer if we can contact you by e-mail.
  • We will help with unexpected problems when you install MySQL from a binary distribution on supported platforms. This level of support does not cover installing MySQL from a source distribution. Supported platforms are those for which MySQL is known to work. See section 2.2.2 Operating Systems Supported by MySQL.
  • We will help you with bugs and missing features. Any bugs that are found are fixed for the next MySQL release. If the bug is critical for you, we will mail you a patch for it as soon the bug is fixed. Critical bugs always have the highest priority for us, and we ensure that they are fixed as soon as possible.
  • Your suggestions for the further development of MySQL will be taken into consideration. By taking email support you have already helped the further development of MySQL. If you want to have more input, upgrade to a higher level of support.
  • If you want us to help optimize your system, you must upgrade to a higher level of support.

1.3.5.2 Extended E-mail Support

Extended e-mail support includes everything in basic e-mail support with these additions:

  • Your e-mail will be dealt with before mail from basic e-mail support users and non-registered users.
  • Your suggestions for the further development of MySQL will receive strong consideration. Simple extensions that suit the basic goals of MySQL are implemented in a matter of days. By taking extended e-mail support you have already helped the further development of MySQL.
  • Typical situations that are covered by extended e-mail support are:
    • We will answer and (within reason) solve questions that relate to possible bugs in MySQL. As soon as the bug is found and corrected, we will mail a patch for it.
    • We will help with unexpected problems when you install MySQL from a source or binary distribution on supported platforms.
    • We will answer questions about missing features and offer hints how to work around them.
    • We will provide hints on optimizing mysqld for your situation.
  • You are allowed to influence the priority of items on the MySQL TODO List. See section 1.6 MySQL and the future (The TODO). This will ensure that the features you really need will be implemented sooner than they might be otherwise.

1.3.5.3 Login Support

Login support includes everything in extended e-mail support with these additions:

  • Your e-mail will be dealt with even before e-mail from extended e-mail support users.
  • Your suggestions for the further development of MySQL will be taken into very high consideration. Realistic extensions that can be implemented in a couple of hours and that suit the basic goals of MySQL will be implemented as soon as possible.
  • If you have a very specific problem, we can try to log in on your system to solve the problem ``in place.''
  • Like any database vendor, we can't guarantee that we can rescue any data from crashed tables, but if the worst happens, we will help you rescue as much as possible. MySQL has proven itself very reliable, but anything is possible due to circumstances beyond our control (for example, if your system crashes or someone kills the server by executing a kill -9 command).
  • We will provide hints on optimizing your system and your queries.
  • You are allowed to call a MySQL developer (in moderation) and discuss your MySQL-related problems. This option is however only to be used as a last result during an emergency after we have failed to grasp the total problem with email. To make efficient use of our time we need to first get all facts about the problem, before talking on phone, to be able to work as efficiently as possible on solving the problem.

1.3.5.4 Extended Login Support

Extended login support includes everything in login support with these additions:

  • Your e-mail has the highest possible priority.
  • We will actively examine your system and help you optimize it and your queries. We may also optimize and/or extend MySQL to better suit your needs.
  • You may also request special extensions just for you. For example:
    mysql> select MY_FUNC(col1,col2) from table;
    
  • We will provide a binary distribution of all important MySQL releases for your system, as long as we can get an account on a similar system. In the worst case, we may require access to your system to be able to create a binary distribution.
  • If you can provide accommodations and pay for traveler fares, you can even get a MySQL developer to visit you and offer you help with your troubles. Extended login support entitles you to one personal encounter per year, but we are always very flexible towards our customers! If the visit takes 16 hours or more, the first 8 hours is without charge. For the hours above 8 hours, you will be charged with a rate that is at least 20 % less than our standard rates.

1.3.5.5 Telephone Support

Telephone support includes everything in extended login support with these additions:

  • We will provide you with a dynamic web page showing the current list of MySQL developers that you can phone when you have a critical problem.
  • For non critical problem, you can request a MySQL developer to phone back within 48 hours to discuss MySQL related issues.

1.3.5.6 Support for other table handlers

To get support for BDB tables, InnoDB tables you have to pay an additional 30% on the standard support price for each of the table handlers you would like to have support for.

We at MySQL AB will help you create a proper bug report for the table handler and submit it to the developers for the specific table handler. We will also do our best to ensure that you will get a timely answer or solution from the developers of the table handler.

Even if we are quite confident that we can solve most problems within a timely manner, we can't guarantee a quick solution for any problems you can get with the different table handlers. We will however do our best to help you get the problem solved.

1.4 How Standards-compatible Is MySQL?

This section describes how MySQL relates to the ANSI SQL standards. MySQL has many extensions to the ANSI SQL standards, and here you will find out what they are, and how to use them. You will also find information about functionality missing from MySQL, and how to work around some differences.

1.4.1 MySQL Extensions to ANSI SQL92

MySQL 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 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 '!', the syntax will only be executed if the MySQL version is equal to or newer than the used version number:

CREATE /*!32302 TEMPORARY */ TABLE (a int);

The above means that if you have Version 3.23.02 or newer, then MySQL will use the TEMPORARY keyword.

MySQL extensions are listed below:

  • The field types MEDIUMINT, SET, ENUM, and the different BLOB and TEXT types.
  • The field attributes AUTO_INCREMENT, BINARY, NULL, UNSIGNED, and ZEROFILL.
  • All string comparisons are case insensitive by default, with sort ordering determined by the current character set (ISO-8859-1 Latin1 by default). If you don't like this, you should declare your columns with the BINARY attribute or use the BINARY cast, which causes comparisons to be done according to the ASCII order used on the MySQL server host.
  • MySQL 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:
    • Database names and table names are case sensitive in MySQL on operating systems that have case-sensitive filenames (like most Unix systems). See section 6.1.3 Case Sensitivity in Names.
    • Database, table, index, column, or alias names may begin with a digit (but may not consist solely of digits).
    • You can use standard system commands to backup, rename, move, delete, and copy tables. For example, to rename a table, rename the `.MYD', `.MYI', and `.frm' files to which the table corresponds.
  • In SQL statements, you can access tables from different databases with the db_name.tbl_name syntax. Some SQL servers provide the same functionality but call this User space. MySQL doesn't support tablespaces as in: create table ralph.my_table...IN my_tablespace.
  • LIKE is allowed on numeric columns.
  • Use of INTO OUTFILE and STRAIGHT_JOIN in a SELECT statement. See section 6.4.1 SELECT Syntax.
  • The SQL_SMALL_RESULT option in a SELECT statement.
  • EXPLAIN SELECT to get a description on how tables are joined.
  • Use of index names, indexes on a prefix of a field, and use of INDEX or KEY in a CREATE TABLE statement. See section 6.5.3 CREATE TABLE Syntax.
  • Use of TEMPORARY or IF NOT EXISTS with CREATE TABLE.
  • Use of COUNT(DISTINCT list) where 'list' is more than one element.
  • Use of CHANGE col_name, DROP col_name, or DROP INDEX, IGNORE or RENAME in an ALTER TABLE statement. See section 6.5.4 ALTER TABLE Syntax.
  • Use of RENAME TABLE. See section 6.5.5 RENAME TABLE Syntax.
  • Use of multiple ADD, ALTER, DROP, or CHANGE clauses in an ALTER TABLE statement.
  • Use of DROP TABLE with the keywords IF EXISTS.
  • You can drop multiple tables with a single DROP TABLE statement.
  • The LIMIT clause of the DELETE statement.
  • The DELAYED clause of the INSERT and REPLACE statements.
  • The LOW_PRIORITY clause of the INSERT, REPLACE, DELETE, and UPDATE statements.
  • Use of LOAD DATA INFILE. In many cases, this syntax is compatible with Oracle's LOAD DATA INFILE. See section 6.4.8 LOAD DATA INFILE Syntax.
  • The ANALYZE TABLE, CHECK TABLE, OPTIMIZE TABLE, and REPAIR TABLE statements.
  • The SHOW statement. See section 4.5.5 SHOW Syntax.
  • Strings may be enclosed by either `"' or `'', not just by `''.
  • Use of the escape `\' character.
  • The SET OPTION statement. See section 5.5.6 SET Syntax.
  • You don't need to name all selected columns in the GROUP BY part. This gives better performance for some very specific, but quite normal queries. See section M.3 Functions for Use with GROUP BY Clauses.
  • One can specify ASC and DESC with GROUP BY.
  • To make it easier for users who come from other SQL environments, MySQL supports aliases for many functions. For example, all string functions support both ANSI SQL syntax and ODBC syntax.
  • MySQL understands the || and && operators to mean logical OR and AND, as in the C programming language. In MySQL, || and OR are synonyms, as are && and AND. Because of this nice syntax, MySQL doesn't support the ANSI SQL || 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.
  • CREATE DATABASE or DROP DATABASE. See section 6.5.1 CREATE DATABASE Syntax.
  • The % 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.
  • The =, <>, <= ,<, >=,>, <<, >>, <=>, 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;
    
  • The LAST_INSERT_ID() function. See section 8.4.3.126 mysql_insert_id().
  • The REGEXP and NOT REGEXP extended regular expression operators.
  • CONCAT() or CHAR() with one argument or more than two arguments. (In MySQL, these functions can take any number of arguments.)
  • The BIT_COUNT(), CASE, ELT(), FROM_DAYS(), FORMAT(), IF(), PASSWORD(), ENCRYPT(), md5(), ENCODE(), DECODE(), PERIOD_ADD(), PERIOD_DIFF(), TO_DAYS(), or WEEKDAY() functions.
  • Use of TRIM() to trim substrings. ANSI SQL only supports removal of single characters.
  • The GROUP BY functions STD(), BIT_OR(), and BIT_AND().
  • Use of REPLACE instead of DELETE + INSERT. See section 6.4.7 REPLACE Syntax.
  • The FLUSH, RESET and DO statements.
  • The possibility to set variables in a statement with :=:
    SELECT @a:=SUM(total),@b=COUNT(*),@a/@b AS avg FROM test_table;
    SELECT @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
    

1.4.2 MySQL Differences Compared to ANSI SQL92

We try to make MySQL follow the ANSI SQL standard and the ODBC SQL standard, but in some cases MySQL does some things differently:

1.4.3 Running MySQL in ANSI Mode

If you start mysqld with the --ansi option, the following behavior of MySQL changes:

  • || is string concatenation instead of OR.
  • You can have any number of spaces between a function name and the `('. This forces all function names to be treated as reserved words.
  • `"' will be an identifier quote character (like the MySQL ``' quote character) and not a string quote character.
  • REAL will be a synonym for FLOAT instead of a synonym of DOUBLE.
  • The default transaction isolation level is SERIALIZABLE. See section 6.7.3 SET TRANSACTION Syntax.

This is the same as using --sql-mode=REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,SERIALIZE,ONLY_FULL_GROUP_BY.

1.4.4 Functionality Missing from MySQL

The following functionality is missing in the current version of MySQL. For a prioritized list indicating when new extensions may be added to MySQL, you should consult the online MySQL TODO list. That is the latest version of the TODO list in this manual. See section 1.6 MySQL and the future (The TODO).

1.4.4.1 Sub-selects

MySQL currently only supports sub selects of the form INSERT ... SELECT ... and REPLACE ... SELECT .... You can however use the function IN() in other contexts.

In many cases you can rewrite the query without a sub-select:

SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);

This can be re-written as:

SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id;

The queries:

SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2 where table1.id=table2.id);

Can be rewritten as:

SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id where table2.id IS NULL

For more complicated subqueries you can often create temporary tables to hold the subquery. In some cases, however this option will not work. The most frequently encountered of these cases arises with DELETE statements, for which standard SQL does not support joins (except in sub-selects). For this situation there are two options available until subqueries are supported by MySQL.

The first option is to use a procedural programming language (such as Perl or PHP) to submit a SELECT query to obtain the primary keys for the records to be deleted, and then use these values to construct the DELETE statement (DELETE FROM ... WHERE ... IN (key1, key2, ...)).

The second option is to use interactive SQL to contruct a set of DELETE statements automatically, using the MySQL extension CONCAT() (in lieu of the standard || operator). For example:

SELECT CONCAT('DELETE FROM tab1 WHERE pkid = ', tab1.pkid, ';')
  FROM tab1, tab2
 WHERE tab1.col1 = tab2.col2;

You can place this query in a script file and redirect input from it to the mysql command-line interpreter, piping its output back to a second instance of the interpreter:

prompt> mysql --skip-column-names mydb < myscript.sql | mysql mydb

MySQL 4.0 supports multi-table deletes that can be used to efficiently delete rows based on information from one table or even from many tables at the same time.

1.4.4.2 SELECT INTO TABLE

MySQL doesn't yet support the Oracle SQL extension: SELECT ... INTO TABLE .... MySQL supports instead the ANSI SQL syntax INSERT INTO ... SELECT ..., which is basically the same thing. See section 6.4.2.1 INSERT ... SELECT Syntax.

INSERT INTO tblTemp2 (fldID) SELECT tblTemp1.fldOrder_ID FROM tblTemp1 WHERE
tblTemp1.fldOrder_ID > 100;

Alternatively, you can use SELECT INTO OUTFILE... or CREATE TABLE ... SELECT to solve your problem.

1.4.4.3 Transactions

As MySQL does nowadays support transactions, the following discussion is only valid if you are only using the non-transaction-safe table types. See section 6.7.1 BEGIN/COMMIT/ROLLBACK Syntax.

The question is often asked, by the curious and the critical, ``Why is MySQL not a transactional database?'' or ``Why does MySQL not support transactions?''

MySQL has made a conscious decision to support another paradigm for data integrity, ``atomic operations.'' It is our thinking and experience that atomic operations offer equal or even better integrity with much better performance. We, nonetheless, appreciate and understand the transactional database paradigm and plan, within the next few releases, to introduce transaction-safe tables on a per table basis. We will be giving our users the possibility to decide if they need the speed of atomic operations or if they need to use transactional features in their applications.

How does one use the features of MySQL to maintain rigorous integrity and how do these features compare with the transactional paradigm?

First, in the transactional paradigm, if your applications are written in a way that is dependent on the calling of ``rollback'' instead of ``commit'' in critical situations, then transactions are more convenient. Moreover, transactions ensure that unfinished updates or corrupting activities are not committed to the database; the server is given the opportunity to do an automatic rollback and your database is saved.

MySQL, in almost all cases, allows you to solve for potential problems by including simple checks before updates and by running simple scripts that check the databases for inconsistencies and automatically repair or warn if such occurs. Note that just by using the MySQL log or even adding one extra log, one can normally fix tables perfectly with no data integrity loss.

Moreover, fatal transactional updates can be rewritten to be atomic. In fact,we will go so far as to say that all integrity problems that transactions solve can be done with LOCK TABLES or atomic updates, ensuring that you never will get an automatic abort from the database, which is a common problem with transactional databases.

Not even transactions can prevent all loss if the server goes down. In such cases even a transactional system can lose data. The difference between different systems lies in just how small the time-lap is where they could lose data. No system is 100% secure, only ``secure enough.'' Even Oracle, reputed to be the safest of transactional databases, is reported to sometimes lose data in such situations.

To be safe with MySQL, you only need to have backups and have the update logging turned on. With this you can recover from any situation that you could with any transactional database. It is, of course, always good to have backups, independent of which database you use.

The transactional paradigm has its benefits and its drawbacks. Many users and application developers depend on the ease with which they can code around problems where an abort appears to be, or is necessary, and they may have to do a little more work with MySQL to either think differently or write more. If you are new to the atomic operations paradigm, or more familiar or more comfortable with transactions, do not jump to the conclusion that MySQL has not addressed these issues. Reliability and integrity are foremost in our minds. Recent estimates indicate that there are more than 1,000,000 mysqld servers currently running, many of which are in production environments. We hear very, very seldom from our users that they have lost any data, and in almost all of those cases user error is involved. This is, in our opinion, the best proof of MySQL's stability and reliability.

Lastly, in situations where integrity is of highest importance, MySQL's current features allow for transaction-level or better reliability and integrity. If you lock tables with LOCK TABLES, all updates will stall until any integrity checks are made. If you only obtain a read lock (as opposed to a write lock), then reads and inserts are still allowed to happen. The new inserted records will not be seen by any of the clients that have a READ lock until they release their read locks. With INSERT DELAYED you can queue inserts into a local queue, until the locks are released, without having the client wait for the insert to complete. See section 6.4.3 INSERT DELAYED syntax.

``Atomic,'' in the sense that we mean it, is nothing magical. It only means that you can be sure that while each specific update is running, no other user can interfere with it, and there will never be an automatic rollback (which can happen on transaction based systems if you are not very careful). MySQL also guarantees that there will not be any dirty reads. You can find some example of how to write atomic updates in the commit-rollback section. See section 1.4.6 How to Cope Without COMMIT/ROLLBACK.

We have thought quite a bit about integrity and performance, and we believe that our atomic operations paradigm allows for both high reliability and extremely high performance, on the order of three to five times the speed of the fastest and most optimally tuned of transactional databases. We didn't leave out transactions because they are hard to do. The main reason we went with atomic operations as opposed to transactions is that by doing this we could apply many speed optimizations that would not otherwise have been possible.

Many of our users who have speed foremost in their minds are not at all concerned about transactions. For them transactions are not an issue. For those of our users who are concerned with or have wondered about transactions vis-a-vis MySQL, there is a ``MySQL way'' as we have outlined above. For those where safety is more important than speed, we recommend them to use the BDB, or InnoDB tables for all their critical data. See section 7 MySQL Table Types.

One final note: We are currently working on a safe replication schema that we believe to be better than any commercial replication system we know of. This system will work most reliably under the atomic operations, non-transactional, paradigm. Stay tuned.

1.4.4.4 Stored Procedures and Triggers

A stored procedure is a set of SQL commands that can be compiled and stored in the server. Once this has been done, clients don't need to keep reissuing the entire query but can refer to the stored procedure. This provides better performance because the query has to be parsed only once, and less information needs to be sent between the server and the client. You can also raise the conceptual level by having libraries of functions in the server.

A trigger is a stored procedure that is invoked when a particular event occurs. For example, you can install a stored procedure that is triggered each time a record is deleted from a transaction table and that automatically deletes the corresponding customer from a customer table when all his transactions are deleted.

The planned update language will be able to handle stored procedures, but without triggers. Triggers usually slow down everything, even queries for which they are not needed.

To see when MySQL might get stored procedures, see section 1.6 MySQL and the future (The TODO).

1.4.4.5 Foreign Keys

Note that foreign keys in SQL are not used to join tables, but are used mostly for checking referential integrity (foreign key constraints). If you want to get results from multiple tables from a SELECT statement, you do this by joining tables:

SELECT * from table1,table2 where table1.id = table2.id;

See section 6.4.1.1 JOIN Syntax. See section 3.5.6 Using Foreign Keys.

The FOREIGN KEY syntax in MySQL exists only for compatibility with other SQL vendors' CREATE TABLE commands; it doesn't do anything. The FOREIGN KEY syntax without ON DELETE ... is mostly used for documentation purposes. Some ODBC applications may use this to produce automatic WHERE clauses, but this is usually easy to override. FOREIGN KEY is sometimes used as a constraint check, but this check is unnecessary in practice if rows are inserted into the tables in the right order. MySQL only supports these clauses because some applications require them to exist (regardless of whether or not they work).

In MySQL, you can work around the problem of ON DELETE ... not being implemented by adding the appropriate DELETE statement to an application when you delete records from a table that has a foreign key. In practice this is as quick (in some cases quicker) and much more portable than using foreign keys.

In the near future we will extend the FOREIGN KEY implementation so that at least the information will be saved in the table specification file and may be retrieved by mysqldump and ODBC. At a later stage we will implement the foreign key constraints for application that can't easily be coded to avoid them.

1.4.4.6 Reasons NOT to Use Foreign Keys constraints

There are so many problems with foreign key constraints that we don't know where to start:

  • Foreign key constraints make life very complicated, because the foreign key definitions must be stored in a database and implementing them would destroy the whole ``nice approach'' of using files that can be moved, copied, and removed.
  • The speed impact is terrible for INSERT and UPDATE statements, and in this case almost all FOREIGN KEY constraint checks are useless because you usually insert records in the right tables in the right order, anyway.
  • There is also a need to hold locks on many more tables when updating one table, because the side effects can cascade through the entire database. It's MUCH faster to delete records from one table first and subsequently delete them from the other tables.
  • You can no longer restore a table by doing a full delete from the table and then restoring all records (from a new source or from a backup).
  • If you use foreign key constraints you can't dump and restore tables unless you do so in a very specific order.
  • It's very easy to do ``allowed'' circular definitions that make the tables impossible to re-create each table with a single create statement, even if the definition works and is usable.
  • It's very easy to overlook FOREIGN KEY ... ON DELETE rules when one codes an application. It's not unusual that one loses a lot of important information just because a wrong or misused ON DELETE rule.

The only nice aspect of FOREIGN KEY is that it gives ODBC and some other client programs the ability to see how a table is connected and to use this to show connection diagrams and to help in building applications.

MySQL will soon store FOREIGN KEY definitions so that a client can ask for and receive an answer about how the original connection was made. The current `.frm' file format does not have any place for it. At a later stage we will implement the foreign key constraints for application that can't easily be coded to avoid them.

1.4.4.7 Views

MySQL doesn't yet support views, but we plan to implement these to about 4.1.

Views are mostly useful for letting users access a set of relations as one table (in read-only mode). Many SQL databases don't allow one to update any rows in a view, but you have to do the updates in the separate tables.

As MySQL is mostly used in applications and on web system where the application writer has full control on the database usage, most of our users haven't regarded views to be very important. (At least no one has been interested enough in this to be prepared to finance the implementation of views).

One doesn't need views in MySQL to restrict access to columns as MySQL has a very sophisticated privilege system. See section 4.2 General Security Issues and the MySQL Access Privilege System.

1.4.4.8 `--' as the Start of a Comment

Some other SQL databases use `--' to start comments. MySQL has `#' as the start comment character, even if the mysql command-line tool removes all lines that start with `--'. You can also use the C comment style /* this is a comment */ with MySQL. See section 6.1.5 Comment Syntax.

MySQL Version 3.23.3 and above supports the `--' comment style only if the comment is followed by a space. This is because this degenerate comment style has caused many problems with automatically generated SQL queries that have used something like the following code, where we automatically insert the value of the payment for !payment!:

UPDATE tbl_name SET credit=credit-!payment!

What do you think will happen when the value of payment is negative?

Because 1--1 is legal in SQL, we think it is terrible that `--' means start comment.

In MySQL Version 3.23 you can, however, use: 1-- This is a comment

The following discussion only concerns you if you are running a MySQL version earlier than Version 3.23:

If you have a SQL program in a text file that contains `--' comments you should use:

shell> replace " --" " #" < text-file-with-funny-comments.sql \
         | mysql database

instead of the usual:

shell> mysql database < text-file-with-funny-comments.sql

You can also edit the command file ``in place'' to change the `--' comments to `#' comments:

shell> replace " --" " #" -- text-file-with-funny-comments.sql

Change them back with this command:

shell> replace " #" " --" -- text-file-with-funny-comments.sql

1.4.5 What Standards Does MySQL Follow?

Entry level SQL92. ODBC levels 0-2.

1.4.6 How to Cope Without COMMIT/ROLLBACK

The following mostly applies only for ISAM, MyISAM, and HEAP tables. If you only use transaction-safe tables (BDB, or InnoDB tables) in an an update, you can do COMMIT and ROLLBACK also with MySQL. See section 6.7.1 BEGIN/COMMIT/ROLLBACK Syntax.

The problem with handling COMMIT-ROLLBACK efficiently with the above table types would require a completely different table layout than MySQL uses today. The table type would also need extra threads that do automatic cleanups on the tables, and the disk usage would be much higher. This would make these table types about 2-4 times slower than they are today.

For the moment, we prefer implementing the SQL server language (something like stored procedures). With this you would very seldom really need COMMIT-ROLLBACK. This would also give much better performance.

Loops that need transactions normally can be coded with the help of LOCK TABLES, and you don't need cursors when you can update records on the fly.

We at TcX had a greater need for a real fast database than a 100% general database. Whenever we find a way to implement these features without any speed loss, we will probably do it. For the moment, there are many more important things to do. Check the TODO for how we prioritize things at the moment. (Customers with higher levels of support can alter this, so things may be reprioritized.)

The current problem is actually ROLLBACK. Without ROLLBACK, you can do any kind of COMMIT action with LOCK TABLES. To support ROLLBACK with the above table types, MySQL would have to be changed to store all old records that were updated and revert everything back to the starting point if ROLLBACK was issued. For simple cases, this isn't that hard to do (the current isamlog could be used for this purpose), but it would be much more difficult to implement ROLLBACK for ALTER/DROP/CREATE TABLE.

To avoid using ROLLBACK, you can use the following strategy:

  1. Use LOCK TABLES ... to lock all the tables you want to access.
  2. Test conditions.
  3. Update if everything is okay.
  4. Use UNLOCK TABLES to release your locks.

This is usually a much faster method than using transactions with possible ROLLBACKs, although not always. The only situation this solution doesn't handle is when someone kills the threads in the middle of an update. In this case, all locks will be released but some of the updates may not have been executed.

You can also use functions to update records in a single operation. You can get a very efficient application by using the following techniques:

  • Modify fields relative to their current value.
  • Update only those fields that actually have changed.

For example, when we are doing updates to some customer information, we update only the customer data that has changed and test only that none of the changed data, or data that depend on the changed data, has changed compared to the original row. The test for changed data is done with the WHERE clause in the UPDATE statement. If the record wasn't updated, we give the client a message: "Some of the data you have changed have been changed by another user". Then we show the old row versus the new row in a window, so the user can decide which version of the customer record he should use.

This gives us something that is similar to column locking but is actually even better, because we only update some of the columns, using values that are relative to their current values. This means that typical UPDATE statements look something like these:

UPDATE tablename SET pay_back=pay_back+'relative change';

UPDATE customer
  SET
    customer_date='current_date',
    address='new address',
    phone='new phone',
    money_he_owes_us=money_he_owes_us+'new_money'
  WHERE
    customer_id=id AND address='old address' AND phone='old phone';

As you can see, this is very efficient and works even if another client has changed the values in the pay_back or money_he_owes_us columns.

In many cases, users have wanted ROLLBACK and/or LOCK TABLES for the purpose of managing unique identifiers for some tables. This can be handled much more efficiently by using an AUTO_INCREMENT column and either the SQL function LAST_INSERT_ID() or the C API function mysql_insert_id(). See section 8.4.3.126 mysql_insert_id().

At MySQL AB, we have never had any need for row-level locking because we have always been able to code around it. Some cases really need row locking, but they are very few. If you want row-level locking, you can use a flag column in the table and do something like this:

UPDATE tbl_name SET row_flag=1 WHERE id=ID;

MySQL returns 1 for the number of affected rows if the row was found and row_flag wasn't already 1 in the original row.

You can think of it as MySQL changed the above query to:

UPDATE tbl_name SET row_flag=1 WHERE id=ID and row_flag <> 1;

1.4.7 Known errors and design deficiencies in MySQL

The following problems are known and have a very high priority to get fixed:

  • ANALYZE TABLE on a BDB table may in some case make the table unusable until one has restarted mysqld. When this happens you will see errors like the following in the MySQL error file:
    001207 22:07:56  bdb:  log_flush: LSN past current end-of-log
    
  • Don't execute ALTER TABLE on a BDB table on which you are running not completed multi-statement transactions. (The transaction will probably be ignored).
  • ANALYZE TABLE, OPTIMIZE TABLE and REPAIR TABLE may cause problems on tables for which you are using INSERT DELAYED.
  • Doing a LOCK TABLE .. and FLUSH TABLES .. doesn't guarantee that there isn't a half-finished transaction in progress on the table.
  • BDB tables are a bit slow to open. If you have many BDB tables in a database, it will take a long time to use the mysql client on the database if you are not using the -A option or if you are using rehash. This is especially notable when you have a big table cache.
  • Th current replication protocol cannot deal with LOAD DATA INFILE and line terminator characters of more than 1 character.

The following problems are known and will be fixed in due time:

  • For the moment MATCH only works with SELECT statements.
  • When using SET CHARACTER SET, one can't use translated characters in database, table and column names.
  • DELETE FROM merge_table used without a WHERE will only clear the mapping for the table, not delete everything in the mapped tables
  • You cannot build in another directory when using MIT-pthreads. Because this requires changes to MIT-pthreads, we are not likely to fix this.
  • BLOB values can't ``reliably'' be used in GROUP BY or ORDER BY or DISTINCT. Only the first max_sort_length bytes (default 1024) are used when comparing BLOBbs in these cases. This can be changed with the -O max_sort_length option to mysqld. A workaround for most cases is to use a substring: SELECT DISTINCT LEFT(blob,2048) FROM tbl_name.
  • Calculation is done with BIGINT or DOUBLE (both are normally 64 bits long). It depends on the function which precision one gets. The general rule is that bit functions are done with BIGINT precision, IF, and ELT() with BIGINT or DOUBLE precision and the rest with DOUBLE precision. One should try to avoid using bigger unsigned long long values than 63 bits (9223372036854775807) for anything else than bit fields!
  • All string columns, except BLOB and TEXT columns, automatically have all trailing spaces removed when retrieved. For CHAR types this is okay, and may be regarded as a feature according to ANSI SQL92. The bug is that in MySQL, VARCHAR columns are treated the same way.
  • You can only have up to 255 ENUM and SET columns in one table.
  • safe_mysqld re-directs all messages from mysqld to the mysqld log. One problem with this is that if you execute mysqladmin refresh to close and reopen the log, stdout and stderr are still redirected to the old log. If you use --log extensively, you should edit safe_mysqld to log to `'hostname'.err' instead of `'hostname'.log' so you can easily reclaim the space for the old log by deleting the old one and executing mysqladmin refresh.
  • In the UPDATE statement, columns are updated from left to right. If you refer to an updated column, you will get the updated value instead of the original value. For example:
    mysql> UPDATE tbl_name SET KEY=KEY+1,KEY=KEY+1;
    
    This will update KEY with 2 instead of with 1.
  • You can't use temporary tables more than once in the same query. For example, the following doesn't work.
    select * from temporary_table, temporary_table as t2;
    
  • RENAME doesn't work with TEMPORARY tables.
  • The optimizer may handle DISTINCT differently if you are using 'hidden' columns in a join or not. In a join, hidden columns are counted as part of the result (even if they are not shown) while in normal queries hidden columns doesn't participate in the DISTINCT comparison. We will probably change this in the future to never compare the hidden columns when executing DISTINCT An example of this is:
    SELECT DISTINCT mp3id FROM band_downloads WHERE userid = 9 ORDER BY id
    DESC;
    
    and
    SELECT DISTINCT band_downloads.mp3id, FROM band_downloads,band_mp3
    WHERE band_downloads.userid = 9 AND band_mp3.id = band_downloads.mp3id
    ORDER BY band_downloads.id DESC;
    
    In the second case you may in MySQL 3.23.x get two identical rows in the result set (because the hidden 'id' column may differ). Note that the this only happens for queries where you don't have the ORDER BY columns in the result, something that is you are not allowed to do in ANSI SQL.
  • Because MySQL allows you to work with table types that doesn't support transactions (and thus can't rollback data) some things behaves a little different in MySQL than in other SQL servers: (This is just to ensure that MySQL never need to do a rollback for a SQL command). This may be a little awkward at times as column Because MySQL allows you to work with table types that don't support transactions, and thus can't rollback data, some things behave a little differently in MySQL than in other SQL servers. This is just to ensure that MySQL never need to do a rollback for a SQL command. This may be a little awkward at times as column values must be checked in the application, but this will actually give you a nice speed increase as it allows MySQL to do some optimizations that otherwise would be very hard to do. If you set a column to an incorrect value, MySQL will, instead of doing a rollback, store the best possible value in the column:
    • If you try to store a value outside the range in a numerical column, MySQL will instead store the smallest or biggest possible value in the column.
    • If you try to store a string that doesn't start with a number into a numerical column, MySQL will store 0 into it.
    • If you try to store NULL into a column that doesn't take NULL values, MySQL will store 0 or '' (empty string) in it instead. (This behavior can, however, be changed with the -DDONT_USE_DEFAULT_FIELDS compile option).
    • MySQL allows you to store some wrong date values into DATE and DATETIME columns. (Like 2000-02-31 or 2000-02-00). If the date is totally wrong, MySQL will store the special 0000-00-00 date value in the column.
    • If you set an enum to an unsupported value, it will be set to the error value 'empty string', with numeric value 0.
  • If you execute a PROCEDURE on a query that returns an empty set, in some cases the PROCEDURE will not transform the columns.
  • Creation of a table of type MERGE doesn't check if the underlying tables are of compatible types.
  • MySQL can't yet handle NaN, -Inf and Inf values in double. Using these will cause problems when trying to export and import data. We should as an intermediate solution change NaN to NULL (if possible) and -Inf and Inf to the Minimum respective maximum possible double value.
  • LIMIT on negative numbers are treated as big positive numbers.
  • If you use ALTER TABLE to first add an UNIQUE index to a table used in a MERGE table and then use ALTER TABLE to add a normal index on the MERGE table, the key order will be different for the tables if there was an old not-unique key in the table. This is because ALTER TABLE puts UNIQUE keys before normal keys to be able to detect duplicate keys as early as possible.

The following are known bugs in earlier versions of MySQL:

  • You can get a hung thread if you do a DROP TABLE on a table that is one among many tables that is locked with LOCK TABLES.
  • In the following case you can get a core dump:
    • Delayed insert handler has pending inserts to a table.
    • LOCK table with WRITE
    • FLUSH TABLES
  • Before MySQL Version 3.23.2 an UPDATE that updated a key with a WHERE on the same key may have failed because the key was used to search for records and the same row may have been found multiple times:
    UPDATE tbl_name SET KEY=KEY+1 WHERE KEY > 100;
    
    A workaround is to use:
    mysql> UPDATE tbl_name SET KEY=KEY+1 WHERE KEY+0 > 100;
    
    This will work because MySQL will not use index on expressions in the WHERE clause.
  • Before MySQL Version 3.23, all numeric types where treated as fixed-point fields. That means you had to specify how many decimals a floating-point field shall have. All results were returned with the correct number of decimals.

For platform-specific bugs, see the sections about compiling and porting.

1.5 How MySQL Compares to Other Databases

This section compares MySQL to other popular databases.

This section has been written by the MySQL developers, so it should be read with that in mind. There are no factual errors contained in this section that we know of. If you find something which you believe to be an error, please contact us about it at docs@mysql.com.

For a list of all supported limits, functions, and types, see the crash-me Web page at http://www.mysql.com/information/crash-me.php.

1.5.1 How MySQL Compares to mSQL

Performance
For a true comparison of speed, consult the growing MySQL benchmark suite. See section 5.1.4 The MySQL Benchmark Suite. Because there is no thread creation overhead, a small parser, few features, and simple security, mSQL should be quicker at:
  • Tests that perform repeated connects and disconnects, running a very simple query during each connection.
  • INSERT operations into very simple tables with few columns and keys.
  • CREATE TABLE and DROP TABLE.
  • SELECT on something that isn't an index. (A table scan is very easy.)
Because these operations are so simple, it is hard to be better at them when you have a higher startup overhead. After the connection is established, MySQL should perform much better. On the other hand, MySQL is much faster than mSQL (and most other SQL implementations) on the following:
  • Complex SELECT operations.
  • Retrieving large results (MySQL has a better, faster, and safer protocol).
  • Tables with variable-length strings, because MySQL has more efficient handling and can have indexes on VARCHAR columns.
  • Handling tables with many columns.
  • Handling tables with large record lengths.
  • SELECT with many expressions.
  • SELECT on large tables.
  • Handling many connections at the same time. MySQL is fully multi-threaded. Each connection has its own thread, which means that no thread has to wait for another (unless a thread is modifying a table another thread wants to access). In mSQL, once one connection is established, all others must wait until the first has finished, regardless of whether the connection is running a query that is short or long. When the first connection terminates, the next can be served, while all the others wait again, etc.
  • Joins. mSQL can become pathologically slow if you change the order of tables in a SELECT. In the benchmark suite, a time more than 15000 times slower than MySQL was seen. This is due to mSQL's lack of a join optimizer to order tables in the optimal order. However, if you put the tables in exactly the right order in mSQL2 and the WHERE is simple and uses index columns, the join will be relatively fast! See section 5.1.4 The MySQL Benchmark Suite.
  • ORDER BY and GROUP BY.
  • DISTINCT.
  • Using TEXT or BLOB columns.
SQL Features
  • GROUP BY and HAVING. mSQL does not support GROUP BY at all. MySQL supports a full GROUP BY with both HAVING and the following functions: COUNT(), AVG(), MIN(), MAX(), SUM(), and STD(). COUNT(*) is optimized to return very quickly if the SELECT retrieves from one table, no other columns are retrieved, and there is no WHERE clause. MIN() and MAX() may take string arguments.
  • INSERT and UPDATE with calculations. MySQL can do calculations in an INSERT or UPDATE. For example:
    mysql> UPDATE SET x=x*10+y WHERE x<20;
    
  • Aliasing. MySQL has column aliasing.
  • Qualifying column names. In MySQL, if a column name is unique among the tables used in a query, you do not have to use the full qualifier.
  • SELECT with functions. MySQL has many functions (too many to list here; see section 6.3 Functions for Use in SELECT and WHERE Clauses).
Disk Space Efficiency
That is, how small can you make your tables? MySQL has very precise types, so you can create tables that take very little space. An example of a useful MySQL datatype is the MEDIUMINT that is 3 bytes long. If you have 100,000,000 records, saving even one byte per record is very important. mSQL2 has a more limited set of column types, so it is more difficult to get small tables.
Stability
This is harder to judge objectively. For a discussion of MySQL stability, see section 1.1.7 How Stable Is MySQL?. We have no experience with mSQL stability, so we cannot say anything about that.
Price
Another important issue is the license. MySQL has a more flexible license than mSQL, and is also less expensive than mSQL. Whichever product you choose to use, remember to at least consider paying for a license or e-mail support. (You are required to get a license if you include MySQL with a product that you sell, of course.)
Perl Interfaces
MySQL has basically the same interfaces to Perl as mSQL with some added features.
JDBC (Java)
MySQL currently has a lot of different JDBC drivers:
  • The mm driver: A type 4 JDBC driver by Mark Matthews mmatthew@ecn.purdue.edu. This is released under the LGPL.
  • The Resin driver. This is a commercial JDBC driver released under open source. http://www.caucho.com/projects/jdbc-mysql/index.xtp
  • The gwe driver: A Java interface by GWE technologies (not supported anymore).
  • The jms driver: An improved gwe driver by Xiaokun Kelvin ZHU X.Zhu@brad.ac.uk (not supported anymore).
  • The twz driver: A type 4 JDBC driver by Terrence W. Zellers zellert@voicenet.com. This is commercial but is free for private and educational use (not supported anymore).
The recommended driver is the mm driver. The Resin driver may also be good (at least the benchmarks looks good), but we haven't received that much information about this yet. We know that mSQL has a JDBC driver, but we have too little experience with it to compare.
Rate of Development
MySQL has a very small team of developers, but we are quite used to coding C and C++ very rapidly. Because threads, functions, GROUP BY, and so on are still not implemented in mSQL, it has a lot of catching up to do. To get some perspective on this, you can view the mSQL `HISTORY' file for the last year and compare it with the News section of the MySQL Reference Manual (see section F MySQL change history). It should be pretty obvious which one has developed most rapidly.
Utility Programs
Both mSQL and MySQL have many interesting third-party tools. Because it is very easy to port upward (from mSQL to MySQL), almost all the interesting applications that are available for mSQL are also available for MySQL. MySQL comes with a simple msql2mysql program that fixes differences in spelling between mSQL and MySQL for the most-used C API functions. For example, it changes instances of msqlConnect() to mysql_connect(). Converting a client program from mSQL to MySQL usually takes a couple of minutes.

1.5.1.1 How to Convert mSQL Tools for MySQL

According to our experience, it would just take a few hours to convert tools such as msql-tcl and msqljava that use the mSQL C API so that they work with the MySQL C API.

The conversion procedure is:

  1. Run the shell script msql2mysql on the source. This requires the replace program, which is distributed with MySQL.
  2. Compile.
  3. Fix all compiler errors.

Differences between the mSQL C API and the MySQL C API are:

  • MySQL uses a MYSQL structure as a connection type (mSQL uses an int).
  • mysql_connect() takes a pointer to a MYSQL structure as a parameter. It is easy to define one globally or to use malloc() to get one. mysql_connect() also takes two parameters for specifying the user and password. You may set these to NULL, NULL for default use.
  • mysql_error() takes the MYSQL structure as a parameter. Just add the parameter to your old msql_error() code if you are porting old code.
  • MySQL returns an error number and a text error message for all errors. mSQL returns only a text error message.
  • Some incompatibilities exist as a result of MySQL supporting multiple connections to the server from the same process.

1.5.1.2 How mSQL and MySQL Client/Server Communications Protocols Differ

There are enough differences that it is impossible (or at least not easy) to support both.

The most significant ways in which the MySQL protocol differs from the mSQL protocol are listed below:

  • A message buffer may contain many result rows.
  • The message buffers are dynamically enlarged if the query or the result is bigger than the current buffer, up to a configurable server and client limit.
  • All packets are numbered to catch duplicated or missing packets.
  • All column values are sent in ASCII. The lengths of columns and rows are sent in packed binary coding (1, 2, or 3 bytes).
  • MySQL can read in the result unbuffered (without having to store the full set in the client).
  • If a single read/write takes more than 30 seconds, the server closes the connection.
  • If a connection is idle for 8 hours, the server closes the connection.

1.5.1.3 How mSQL 2.0 SQL Syntax Differs from MySQL

Column types

MySQL
Has the following additional types (among others; see section 6.5.3 CREATE TABLE Syntax):
  • ENUM type for one of a set of strings.
  • SET type for many of a set of strings.
  • BIGINT type for 64-bit integers.
MySQL also supports the following additional type attributes:
  • UNSIGNED option for integer columns.
  • ZEROFILL option for integer columns.
  • AUTO_INCREMENT option for integer columns that are a PRIMARY KEY. See section 8.4.3.126 mysql_insert_id().
  • DEFAULT value for all columns.
mSQL2
mSQL column types correspond to the MySQL types shown below:
mSQL type Corresponding MySQL type
CHAR(len) CHAR(len)
TEXT(len) TEXT(len). len is the maximal length. And LIKE works.
INT INT. With many more options!
REAL REAL. Or FLOAT. Both 4- and 8-byte versions are available.
UINT INT UNSIGNED
DATE DATE. Uses ANSI SQL format rather than mSQL's own format.
TIME TIME
MONEY DECIMAL(12,2). A fixed-point value with two decimals.

Index Creation

MySQL
Indexes may be specified at table creation time with the CREATE TABLE statement.
mSQL
Indexes must be created after the table has been created, with separate CREATE INDEX statements.

To Insert a Unique Identifier into a Table

MySQL
Use AUTO_INCREMENT as a column type specifier. See section 8.4.3.126 mysql_insert_id().
mSQL
Create a SEQUENCE on a table and select the _seq column.

To Obtain a Unique Identifier for a Row

MySQL
Add a PRIMARY KEY or UNIQUE key to the table and use this. New in Version 3.23.11: If the PRIMARY or UNIQUE key consists of only one column and this is of type integer, one can also refer to it as _rowid.
mSQL
Use the _rowid column. Observe that _rowid may change over time depending on many factors.

To Get the Time a Column Was Last Modified

MySQL
Add a TIMESTAMP column to the table. This column is automatically set to the current date and time for INSERT or UPDATE statements if you don't give the column a value or if you give it a NULL value.
mSQL
Use the _timestamp column.

NULL Value Comparisons

MySQL
MySQL follows ANSI SQL, and a comparison with NULL is always NULL.
mSQL
In mSQL, NULL = NULL is TRUE. You must change =NULL to IS NULL and <>NULL to IS NOT NULL when porting old code from mSQL to MySQL.

String Comparisons

MySQL
Normally, string comparisons are performed in case-independent fashion with the sort order determined by the current character set (ISO-8859-1 Latin1 by default). If you don't like this, declare your columns with the BINARY attribute, which causes comparisons to be done according to the ASCII order used on the MySQL server host.
mSQL
All string comparisons are performed in case-sensitive fashion with sorting in ASCII order.

Case-insensitive Searching

MySQL
LIKE is a case-insensitive or case-sensitive operator, depending on the columns involved. If possible, MySQL uses indexes if the LIKE argument doesn't start with a wild-card character.
mSQL
Use CLIKE.

Handling of Trailing Spaces

MySQL
Strips all spaces at the end of CHAR and VARCHAR columns. Use a TEXT column if this behavior is not desired.
mSQL
Retains trailing space.

WHERE Clauses

MySQL
MySQL correctly prioritizes everything (AND is evaluated before OR). To get mSQL behavior in MySQL, use parentheses (as shown in an example below).
mSQL
Evaluates everything from left to right. This means that some logical calculations with more than three arguments cannot be expressed in any way. It also means you must change some queries when you upgrade to MySQL. You do this easily by adding parentheses. Suppose you have the following mSQL query:
mysql> SELECT * FROM table WHERE a=1 AND b=2 OR a=3 AND b=4;
To make MySQL evaluate this the way that mSQL would, you must add parentheses:
mysql> SELECT * FROM table WHERE (a=1 AND (b=2 OR (a=3 AND (b=4))));

Access Control

MySQL
Has tables to store grant (permission) options per user, host, and database. See section 4.2.5 How the Privilege System Works.
mSQL
Has a file `mSQL.acl' in which you can grant read/write privileges for users.

1.5.2 How MySQL Compares to PostgreSQL

When reading the following, please note that both products are continually evolving. We at MySQL AB and the PostgreSQL developers are both working on making our respective database as good as possible, so we are both a serious choice to any commercial database.

The following comparison is made by us at MySQL AB. We have tried to be as accurate and fair as possible, but because we don't have a full knowledge of all PostgreSQL features while we know MySQL througly, we may have got some things wrong. We will however correct these when they come to our attention.

We would first like to note that PostgreSQL and MySQL are both widely used products, but with different design goals, even if we are both striving to be ANSI SQL compatible. This means that for some applications MySQL is more suited, while for others PostgreSQL is more suited. When choosing which database to use, you should first check if the database's feature set satisfies your application. If you need raw speed, MySQL is probably your best choice. If you need some of the extra features that only PostgreSQL can offer, you should use PostgreSQL.

1.5.2.1 MySQL and PostgreSQL development strategies

When adding things to MySQL we take pride to do an optimal, definite solution. The code should be so good that we shouldn't have any need to change it in the foreseeable future. We also do not like to sacrifice speed for features but instead will do our utmost to find a solution that will give maximal throughput. This means that development will take a little longer, but the end result will be well worth this. This kind of development is only possible because all server code are checked by one of a few (currently two) persons before it's included in the MySQL server.

We at MySQL AB believe in frequent releases to be able to push out new features quickly to our users. Because of this we do a new small release about every three weeks, and a major branch every year. All releases are throughly tested with our testing tools on a lot of different platforms.

PostgreSQL is based on a kernel with lots of contributors. In this setup it makes sense to prioritize adding a lot of new features, instead of implementing them optimally, because one can always optimize things later if there arises a need for this.

Another big difference between MySQL and PostgreSQL is that nearly all of the code in the MySQL server are coded by developers that are employed by MySQL AB and are still working on the server code. The exceptions are the transaction engines, and the regexp library.

This is in sharp contrast to the PostgreSQL code where the majority of the code is coded by a big group of people with different backgrounds. It was only recently that the PostgreSQL developers announced that their current developer group had finally had time to take a look at all the code in the current PostgreSQL release.

Both of the above development methods has it's own merits and drawbacks. We here at MySQL AB think of course that our model is better because our model gives better code consistency, more optimal and reusable code, and in our opinion, fewer bugs. Because we are the authors of the MySQL server code, we are better able to coordinate new features and releases.

1.5.2.2 Featurewise Comparison of MySQL and PostgreSQL

On the crash-me page you can find a list of those database constructs and limits that one can detect automatically with a program. Note however that a lot of the numerical limits may be changed with startup options for respective database. The above web page is however extremely useful when you want to ensure that your applications works with many different databases or when you want to convert your application from one datbase to another.

MySQL offers the following advantages over PostgreSQL:

  • MySQL is generally much faster than PostgreSQL. See section 1.5.2.3 Benchmarking MySQL and PostgreSQL.
  • MySQL has a much larger user base than PostgreSQL, therefor the code is more tested and has historically been more stable than PostgreSQL. MySQL is the much more used in production environments than PostgreSQL, mostly thanks to that MySQL AB, formerly TCX DataKonsult AB, has provided top quality commercial support for MySQL from the day it was released, whereas until recently PostgreSQL was unsupported.
  • MySQL works better on Windows than PostgreSQL does. MySQL runs as a native Windows application (a service on NT/Win2000/WinXP), while PostgreSQL is run under the cygwin emulation. We have heard that PostgreSQL is not yet that stable on Windows but we haven't been able to verify this ourselves.
  • MySQL has more APIs to other languages and is supported by more existing programs than PostgreSQL. See section D Contributed Programs.
  • MySQL works on 24/7 heavy duty systems. In most circumstances you never have to run any cleanups on MySQL. PostgreSQL doesn't yet support 24/7 systems because you have to run VACUUM() once in a while to reclaim space from UPDATE and DELETE commands and to perform statistics analyzes that are critical to get good performance with PostgreSQL. VACUUM() is also needed after adding a lot of new rows to a table. On a busy system with lots of changes, VACUUM() must be run very frequently, in the worst cases even many times a day. During the VACUUM() run, which may take hours if the database is big, the database is from a production standpoint, practically dead. The PostgreSQL team has fixing this on their TODO, but we assume that this is not an easy thing to fix permanently.
  • A working, tested replication feature used by sites like:
  • Included in the MySQL distribution are two different testing suites, `mysql-test-run' and crash-me, as well as a benchmark suite. The test system is actively updated with code to test each new feature and almost all repeatable bugs that have come to our attention. We test MySQL with these on a lot of platforms before every release. These tests are more sophisticated than anything we have seen from PostgreSQL, and they ensures that the MySQL is kept to a high standard.
  • There are far more books in print about MySQL than about PostgreSQL. O'Reilly, Sams, Que, and New Riders are all major publishers with books about MySQL. All MySQL features are also documented in the MySQL on-line manual, because when a new feature is implemented, the MySQL developers are required to document it before it's included in the source.
  • MySQL supports more of the standard ODBC functions than PostgreSQL.
  • MySQL has a much more sophisticated ALTER TABLE.
  • MySQL has support for tables without transactions for applications that need all speed they can get. The tables may be memory based, HEAP tables or disk based MyISAM. See section 7 MySQL Table Types.
  • MySQL has support for two different table handlers that support transactions, BerkeleyDB and InnoDB. Because every transaction engine performs differently under different conditions, this gives the application writer more options to find an optimal solution for his or her setup. See section 7 MySQL Table Types.
  • MERGE tables gives you a unique way to instantly make a view over a set of identical tables and use these as one. This is perfect for systems where you have log files that you order for example by month. See section 7.2 MERGE Tables.
  • The option to compress read-only tables, but still have direct access to the rows in the table, gives you better performance by minimizing disk reads. This is very useful when you are archiving things. See section 4.7.4 myisampack, The MySQL Compressed Read-only Table Generator.
  • MySQL has internal support for fulltext search. See section 6.8 MySQL Full-text Search.
  • You can access many databases from the same connection (depending of course on your privileges).
  • MySQL is coded from the start to be multi-threaded while PostgreSQL uses processes. Context switching and access to common storage areas is much faster between threads than between separate processes, this gives MySQL a big speed advantage in multi-user applications and also makes it easier for MySQL to take full advantage of symmetric multiprocessor (SMP) systems.
  • MySQL has a much more sophisticated privilege system than PostgreSQL. While PostgreSQL only supports INSERT, SELECT, and UPDATE/DELETE grants per user on a database or a table, MySQL allows you to define a full set of different privileges on database, table and column level. MySQL also allows you to specify the privilege on host and user combinations. See section 4.3.1 GRANT and REVOKE Syntax.
  • MySQL supports a compressed client/server protocol which improves performance over slow links.
  • MySQL employs a ``table handler'' concept, and is the only relational database we know of built around this concept. This allows different low-level table types to be swapped into the SQL engine, and each table type can be optimized for different performance characteristics.
  • All MySQL table types (except InnoDB) are implemented as files (one table per file), which makes it really easy to backup, move, delete and even symlink databases and tables, even when the server is down.
  • Tools to repair and optimize MyISAM tables (the most common MySQL table type). A repair tool is only needed when a physical corruption of a data file happens, usually from a hardware failure. It allows a majority of the data to be recovered.
  • Upgrading MySQL is painless. When you are upgrading MySQL, you don't need to dump/restore your data, as you have to do with most PostgreSQL upgrades.

Drawbacks with MySQL compared to PostgreSQL:

  • The transaction support in MySQL is not yet as well tested as PostgreSQL's system.
  • Because MySQL uses threads, which are not yet flawless on many OSes, one must either use binaries from http://www.mysql.com/downloads, or carefully follow our instructions on http://www.mysql.com/doc/I/n/Installing_source.html to get an optimal binary that works in all cases.
  • Table locking, as used by the non-transactional MyISAM tables, is in many cases faster than page locks, row locks or versioning. The drawback however is that if one doesn't take into account how table locks work, a single long-running query can block a table for updates for a long time. This can usable be avoided when designing the application. If not, one can always switch the trouble table to use one of the transactional table types. See section 5.3.2 Table Locking Issues.
  • With UDF (user defined functions) one can extend MySQL with both normal SQL functions and aggregates, but this is not yet as easy or as flexible as in PostgreSQL. See section 9.1 Adding New Functions to MySQL.
  • Updates and deletes that run over multiple tables is harder to do in MySQL. This will, hoever, be fixed in MySQL 4.0 with multi-table DELETE and multi-table UPDATE and in MySQL 4.1 with subselects.

PostgreSQL currently offers the following advantages over MySQL:

Note that because we know the MySQL road map, we have included in the following table the version when MySQL should support this feature. Unfortunately we couldn't do this for previous comparison, because we don't know the PostgreSQL roadmap.

Feature MySQL version
Subselects 4.1
Foreign keys 4.0 and 4.1
Views 4.2
Stored procedures 4.1
Extensible type system Not planned
Unions 4.0
Full join 4.0 or 4.1
Triggers 4.1
Constrainst 4.1
Cursors 4.1 or 4.2
Extensible index types like R-trees R-trees are planned for 4.2
Inherited tables Not planned

Other reasons to use PostgreSQL:

  • Standard usage in PostgreSQL is closer to ANSI SQL in some cases.
  • One can speed up PostgreSQL by coding things as stored procedures.
  • PostgreSQL has a bigger team of developers that contribute to the server.

Drawbacks with PostgreSQL compared to MySQL:

  • VACUUM() makes PostgreSQL hard to use in a 24/7 environment.
  • Only transactional tables.
  • Much slower INSERT, DELETE, and UPDATE.

For a complete list of drawbacks, you should also examine the first table in this section.

1.5.2.3 Benchmarking MySQL and PostgreSQL

The only open source benchmark that we know of that can be used to benchmark MySQL and PostgreSQL (and other databases) is our own. It can be found at http://www.mysql.com/information/benchmarks.html.

We have many times asked the PostgreSQL developers and some PostgreSQL users to help us extend this benchmark to make it the definitive benchmark for databases, but unfortunately we haven't gotten any feedback for this.

We the MySQL developers have, because of this, spent a lot of hours to get maximum performance from PostgreSQL for the benchmarks, but because we don't know PostgreSQL intimately, we are sure that there are things that we have missed. We have on the benchmark page documented exactly how we did run the benchmark so that it should be easy for anyone to repeat and verify our results.

The benchmarks are usually run with and without the --fast option. When run with --fast we are trying to use every trick the server can do to get the code to execute as fast as possible. The idea is that the normal run should show how the server would work in a default setup and the --fast run shows how the server would do if the application developer would use extensions in the server to make his application run faster.

When running with PostgreSQL and --fast we do a VACUUM() after every major table UPDATE and DROP TABLE to make the database in perfect shape for the following SELECTs. The time for VACUUM() is measured separately.

When running with PostgreSQL 7.1.1 we could, however, not run with --fast because during the INSERT test, the postmaster (the PostgreSQL deamon) died and the database was so corrupted that it was impossible to restart postmaster. After this happened twice, we decided to postpone the --fast test until next PostgreSQL release. The details about the machine we run the benchmark can be found on the benchmark page.

Before going to the other benchmarks we know of, we would like to give some background on benchmarks:

It's very easy to write a test that shows ANY database to be best database in the world, by just restricting the test to something the database is very good at and not test anything that the database is not good at. If one after this publishes the result with a single figure, things are even easier.

This would be like us measuring the speed of MySQL compared to PostgreSQL by looking at the summary time of the MySQL benchmarks on our web page. Based on this MySQL would be more than 40 times faster than PostgreSQL, something that is of course not true. We could make things even worse by just taking the test where PostgreSQL performs worst and claim that MySQL is more than 2000 times faster than PostgreSQL.

The case is that MySQL does a lot of optimizations that PostgreSQL doesn't do. This is of course also true the other way around. An SQL optimizer is a very complex thing, and a company could spend years on just making the optimizer faster and faster.

When looking at the benchmark results you should look for things that you do in your application and just use these results to decide which database would be best suited for your application. The benchmark results also shows things a particular database is not good at and should give you a notion about things to avoid and what you may have to do in other ways.

We know of two benchmark tests that claims that PostgreSQL performs better than MySQL. These both where multi-user tests, a test that we here at MySQL AB haven't had time to write and include in the benchmark suite, mainly because it's a big task to do this in a manner that is fair against all databases.

One is the benchmark paid for by Great Bridge, which you can read about at: http://www.greatbridge.com/about/press.php?content_id=4.

This is the probably worst benchmark we have ever seen anyone conduct. This was not only tuned to only test what PostgreSQL is absolutely best at, it was also totally unfair against every other database involved in the test.

NOTE: We know that not even some of the main PostgreSQL developers did like the way Great Bridge conducted the benchmark, so we don't blame them for the way the benchmark was made.

This benchmark has been condemned in a lot of postings and newsgroups so we will here just shortly repeat some things that where wrong with it.

  • The tests were run with an expensive commercial tool, that makes it impossible for an open source company like us to verify the benchmarks, or even check how the benchmarks were really done. The tool is not even a true benchmark tool, but an application/setup testing tool. To refer this as a ``standard'' benchmark tool is to stretch the truth a long way.
  • Great Bridge admitted that they had optimized the PostgreSQL database (with VACUUM() before the test) and tuned the startup for the tests, something they hadn't done for any of the other databases involved. To say ``This process optimizes indexes and frees up disk space a bit. The optimized indexes boost performance by some margin.'' Our benchmarks clearly indicate that the difference in running a lot of selects on a database with and without VACUUM() can easily differ by a factor of ten.
  • The test results were also strange. The AS3AP test documentation mentions that the test does ``selections, simple joins, projections, aggregates, one-tuple updates, and bulk updates''. PostgreSQL is good at doing SELECTs and JOINs (especially after a VACUUM()), but doesn't perform as well on INSERTs or UPDATEs. The benchmarks seem to indicate that only SELECTs were done (or very few updates). This could easily explain they good results for PostgreSQL in this test. The bad results for MySQL will be obvious a bit down in this document.
  • They did run the so-called benchmark from a Windows machine against a Linux machine over ODBC, a setup that no normal database user would ever do when running a heavy multi-user application. This tested more the ODBC driver and the Windows protocol used between the clients than the database itself.
  • When running the database against Oracle and MS-SQL (Great Bridge has indirectly indicated that the databases they used in the test), they didn't use the native protocol but instead ODBC. Anyone that has ever used Oracle knows that all real application uses the native interface instead of ODBC. Doing a test through ODBC and claiming that the results had anything to do with using the database in a real-world situation can't be regarded as fair. They should have done two tests with and without ODBC to provide the right facts (after having got experts to tune all involved databases of course).
  • They refer to the TPC-C tests, but they don't mention anywhere that the test they did was not a true TPC-C test and they were not even allowed to call it a TPC-C test. A TPC-C test can only be conducted by the rules approved by the TPC Council (http://www.tpc.org). Great Bridge didn't do that. By doing this they have both violated the TPC trademark and miscredited their own benchmarks. The rules set by the TPC Council are very strict to ensure that no one can produce false results or make unprovable statements. Apparently Great Bridge wasn't interested in doing this.
  • After the first test, we contacted Great Bridge and mentioned to them some of the obvious mistakes they had done with MySQL:
    • Running with a debug version of our ODBC driver
    • Running on a Linux system that wasn't optimized for threads
    • Using an old MySQL version when there was a recommended newer one available
    • Not starting MySQL with the right options for heavy multi-user use (the default installation of MySQL is tuned for minimal resource use).
    Great Bridge did run a new test, with our optimized ODBC driver and with better startup options for MySQL, but refused to either use our updated glibc library or our standard binary (used by 80% of our users), which was statically linked with a fixed glibc library. According to what we know, Great Bridge did nothing to ensure that the other databases were set up correctly to run well in their test environment. We are sure however that they didn't contact Oracle or Microsoft to ask for their advice in this matter ;)
  • The benchmark was paid for by Great Bridge, and they decided to publish only partial, chosen results (instead of publishing it all).

Tim Perdue, a long time PostgreSQL fan and a reluctant MySQL user published a comparison on phpbuider.

When we became aware of the comparison, we phoned Tim Perdue about this because there were a lot of strange things in his results. For example, he claimed that MySQL had a problem with five users in his tests, when we know that there are users with similar machines as his that are using MySQL with 2000 simultaneous connections doing 400 queries per second. (In this case the limit was the web bandwidth, not the database.)

It sounded like he was using a Linux kernel that either had some problems with many threads, such as kernels before 2.4, which had a problem with many threads on multi-CPU machines. We have documented in this manual how to fix this and Tim should be aware of this problem.

The other possible problem could have been an old glibc library and that Tim didn't use a MySQL binary from our site, which is linked with a corrected glibc library, but had compiled a version of his own with. In any of the above cases, the symptom would have been exactly what Tim had measured.

We asked Tim if we could get access to his data so that we could repeat the benchmark and if he could check the MySQL version on the machine to find out what was wrong and he promised to come back to us about this. He has not done that yet.

Because of this we can't put any trust in this benchmark either :(

Over time things also changes and the above benchmarks are not that relevant anymore. MySQL now have a couple of different table handlers with different speed/concurrency tradeoffs. See section 7 MySQL Table Types. It would be interesting to see how the above tests would run with the different transactional table types in MySQL. PostgreSQL has of course also got new features since the test was made. As the above test are not publicly available there is no way for us to know how the database would preform in the same tests today.

Conclusion:

The only benchmarks that exist today that anyone can download and run against MySQL and PostgreSQL is the MySQL benchmarks. We here at MySQL believe that open source databases should be tested with open source tools! This is the only way to ensure that no one does tests that nobody can reproduce and use this to claim that a database is better than another. Without knowing all the facts it's impossible to answer the claims of the tester.

The thing we find strange is that every test we have seen about PostgreSQL, that is impossible to reproduce, claims that PostgreSQL is better in most cases while our tests, which anyone can reproduce, clearly shows otherwise. With this we don't want to say that PostgreSQL isn't good at many things (it is!) or that it isn't faster than MySQL under certain conditions. We would just like to see a fair test where they are very good so that we could get some friendly competition going!

For more information about our benchmarks suite See section 5.1.4 The MySQL Benchmark Suite.

We are working on an even better benchmark suite, including multi user tests, and a better documentation of what the individual tests really do and how to add more tests to the suite.

1.6 MySQL and the future (The TODO)

This appendix lists the features that we plan to implement in MySQL.

Everything in this list is approximately in the order it will be done. If you want to affect the priority order, please register a license or support us and tell us what you want to have done more quickly. See section 1.3 MySQL Licensing and Support.

The plan is that we in the future will support the full ANSI SQL99 standard, but with a lot of useful extensions. The challenge is to do this without sacrifying the speed or compromise the code.

1.6.1 Things that should be in 4.0

We plan to make MySQL Version 4.0 a ``quick'' release where we only add some new stuff to enable others to help us with developing new features into Version 4.1. The MySQL 4.0 version should only take us about a month to make after which we want to stabilize it and start working on Version 4.1. Version 4.0 should have the following new features:

The news section for 4.0 includes a list of the features we have already implemented in the 4.0 tree. See section F.1 Changes in release 4.0.x (Development; Alpha).

  • New table definition file format (.frm files) This will enable us to not run out of bits when adding more table options. One will still be able to use the old .frm file format with 4.0. All newly created tables will, however, use the new format. The new file format will enable us to add new column types, more options for keys and FOREIGN KEY support.
  • mysqld as a library. This will have the same interface as the standard MySQL client (with an extra function to just set up startup parameters) but will be faster (no TCP/IP or socket overhead), smaller and much easier to use for embedded products. One will be able to define at link time if one wants to use the client/server model or a stand-alone application just by defining which library to link with. The mysqld will support all standard MySQL features and one can use it in a threaded client to run different queries in each thread.
  • Replication should work with RAND() and user variables @var.
  • Online backup with very low performance penalty. The online backup will make it easy to add a new replication slave without taking down the master.
  • DELETE FROM table_name will return the number of deleted rows. For fast execution one should use TRUNCATE table_name.
  • Allow DELETE on MyISAM tables to use the record cache. To do this, we need to update the threads record cache when we update the .MYD file.
  • Better replication.
  • More functions for full-text search. See section 6.8.3 New Features of Full-text Search to Appear in MySQL 4.0.
  • Character set casts and syntax for handling multiple character sets.
  • Allow users to change startup options without taking down the server.
  • Help for all commands from the client.
  • Secure connections (with SSL).
  • Extend the optimizer to be able to optimize some ORDER BY key_name DESC queries.
  • SHOW COLUMNS FROM table_name (used by mysql client to allow expansions of column names) should not open the table, but only the definition file. This will require less memory and be much faster.
  • New key cache
  • When using SET CHARACTER SET we should translate the whole query at once and not only strings. This will enable users to use the translated characters in database, table and column names.
  • Add a portable interface over gethostbyaddr_r() so that we can change ip_to_hostname() to not block other threads while doing DNS lookups.
  • Add record_in_range() method to MERGE tables to be able to choose the right index when there is many to choose from. We should also extend the info interface to get the key distribution for each index, of analyze is run on all sub tables.
  • SET SQL_DEFAULT_TABLE_TYPE=[MyISAM | INNODB | BDB | HEAP].

1.6.2 Things that must be done in the real near future

  • Fail safe replication.
  • Subqueries. select id from t where grp in (select grp from g where u > 100)
  • Derived tables.
    select a.col1, b.col2 from (select max(col1) as col1 from root_table ) a,
    other_table b where a.col1=b.col1
    
    This could be done by automatically creating temporary tables for the derived tables for the duration of the query.
  • Add PREPARE of statements and sending of parameters to mysqld.
  • Extend the server/client protocol to support warnings.
  • Add options to the server/protocol protocol to get progress notes for long running commands.
  • Add database and real table name (in case of alias) to the MYSQL_FIELD structure.
  • Don't allow more than a defined number of threads to run MyISAM recover at the same time.
  • Change INSERT ... SELECT to optionally use concurrent inserts.
  • Implement RENAME DATABASE. To make this safe for all table handlers, it should work as follows:
    • Create the new database.
    • For every table do a rename of the table to another database, as we do with the RENAME command.
    • Drop the old database.
  • Return the original field types() when doing SELECT MIN(column) ... GROUP BY.
  • Multiple result sets.
  • Change the protocol to allow binary transfer of values. To do this efficiently, we need to add an API to allow binding of variables.
  • Make it possible to specify long_query_time with a granularity in microseconds.
  • Add a configurable prompt to the mysql command line client, with options like database in use, time and date...
  • Add range checking to MERGE tables.
  • Link the myisampack code into the server.
  • Port of MySQL to BeOS.
  • Port of the MySQL clients to LynxOS.
  • Add a temporary key buffer cache during INSERT/DELETE/UPDATE so that we can gracefully recover if the index file gets full.
  • If you perform an ALTER TABLE on a table that is symlinked to another disk, create temporary tables on this disk.
  • Implement a DATE/DATETIME type that handles time zone information properly, so that dealing with dates in different time zones is easier.
  • FreeBSD and MIT-pthreads; Do sleeping threads take CPU?
  • Check if locked threads take any CPU.
  • Fix configure so that one can compile all libraries (like MyISAM) without threads.
  • Add an option to periodically flush key pages for tables with delayed keys if they haven't been used in a while.
  • Allow join on key parts (optimization issue).
  • INSERT SQL_CONCURRENT and mysqld --concurrent-insert to do a concurrent insert at the end of the file if the file is read-locked.
  • Remember FOREIGN key definitions in the `.frm' file.
  • Cascading DELETE
  • Server side cursors.
  • Check if lockd works with modern Linux kernels; If not, we have to fix lockd! To test this, start mysqld with --enable-locking and run the different fork* test suits. They shouldn't give any errors if lockd works.
  • Allow SQL variables in LIMIT, like in LIMIT @a,@b.
  • Allow update of variables in UPDATE statements. For example: UPDATE TABLE foo SET @a=a+b,a=@a, b=@a+c
  • Change when user variables are updated so that one can use them with GROUP BY, as in the following example: SELECT id, @a:=count(*), sum(sum_col)/@a FROM table_name GROUP BY id.
  • Don't add automatic DEFAULT values to columns. Give an error when using an INSERT that doesn't contain a column that doesn't have a DEFAULT.
  • Caching of queries and results. This should be done as a separated module that examines each query and if this is query is in the cache the cached result should be returned. When one updates a table one should remove as few queries as possible from the cache. This should give a big speed bost on machines with much RAM where queries are often repeated (like WWW applications). One idea would be to only cache queries of type: SELECT CACHED ...
  • Fix `libmysql.c' to allow two mysql_query() commands in a row without reading results or give a nice error message when one does this.
  • Optimize BIT type to take 1 bit (now BIT takes 1 char).
  • Check why MIT-pthreads ctime() doesn't work on some FreeBSD systems.
  • Add an IMAGE option to LOAD DATA INFILE to not update TIMESTAMP and AUTO_INCREMENT fields.
  • Added LOAD DATE INFILE.. UPDATE syntax.
    • For tables with primary keys, if the data contains the primary key, entries matching that primary key are updated from the remainder of the columns. However, columns MISSING from the incoming data feed are not touched.
    • For tables tables with primary keys that are missing some part of the key in the incoming data stream, or that have no primary key, the feed is treated as a LOAD DATA INFILE ... REPLACE INTO is now.
  • Make LOAD DATA INFILE understand syntax like:
    LOAD DATA INFILE 'file_name.txt' INTO TABLE tbl_name
    TEXT_FIELDS (text_field1, text_field2, text_field3)
    SET table_field1=concatenate(text_field1, text_field2), table_field3=23
    IGNORE text_field3
    
    This can be used to skip over extra columns in the text file, or update columns
    based on expressions of the read data...
    
  • LOAD DATA INFILE 'file_name' INTO TABLE 'table_name' ERRORS TO err_table_name This would cause any errors and warnings to be logged into the err_table_name table. That table would have a structure like:
    line_number    - line number in data file
    error_message  - the error/warning message
    and maybe
    data_line      - the line from the data file
    
  • Add true VARCHAR support (There is already support for this in MyISAM).
  • Automatic output from mysql to netscape.
  • LOCK DATABASES. (with various options)
  • Change sort to allocate memory in ``hunks'' to get better memory utilization.
  • DECIMAL and NUMERIC types can't read exponential numbers; Field_decimal::store(const char *from,uint len) must be recoded to fix this.
  • Functions: ADD_TO_SET(value,set) and REMOVE_FROM_SET(value,set)
  • Add use of t1 JOIN t2 ON ... and t1 JOIN t2 USING ... Currently, you can only use this syntax with LEFT JOIN.
  • Add full support for unsigned long long type.
  • Many more variables for show status. Counts for: INSERT/DELETE/UPDATE statements. Records reads and updated. Selects on 1 table and selects with joins. Mean number of tables in select. Number of ORDER BY and GROUP BY queries.
  • If you abort mysql in the middle of a query, you should open another connection and kill the old running query. Alternatively, an attempt should be made to detect this in the server.
  • Add a handler interface for table information so you can use it as a system table. This would be a bit slow if you requested information about all tables, but very flexible. SHOW INFO FROM tbl_name for basic table information should be implemented.
  • Add support for UNICODE.
  • NATURAL JOIN and UNION JOIN
  • Allow select a from crash_me left join crash_me2 using (a); In this case a is assumed to come from the crash_me table.
  • Fix that ON and USING works with the JOIN join type.
  • Oracle like CONNECT BY PRIOR ... to search hierarchy structures.
  • mysqladmin copy database new-database. -- Requires COPY command to be added to mysqld
  • Processlist should show number of queries/thread.
  • SHOW HOSTS for printing information about the hostname cache.
  • DELETE and REPLACE options to the UPDATE statement (this will delete rows when one gets a duplicate key error while updating).
  • Change the format of DATETIME to store fractions of seconds.
  • Add all missing ANSI92 and ODBC 3.0 types.
  • Change table names from empty strings to NULL for calculated columns.
  • Don't use 'Item_copy_string' on numerical values to avoid number->string->number conversion in case of: SELECT COUNT(*)*(id+0) FROM table_name GROUP BY id
  • Make it possible to use the new GNU regexp library instead of the current one (The GNU library should be much faster than the old one).
  • Change that ALTER TABLE doesn't abort clients that executes INSERT DELAYED.
  • Fix that when columns referenced in an UPDATE clause contains the old values before the update started.
  • myisamchk, REPAIR and OPTIMIZE TABLE should be able to handle cases where the data and/or index files are symbolic links.
  • Add simulation of pread()/pwrite() on Windows to enable concurrent inserts.
  • A logfile analyzer that could parsed out information about which tables are hit most often, how often multi-table joins are executed, etc. It should help users identify areas or table design that could be optimized to execute much more efficient queries.
  • Add SUM(DISTINCT)
  • Add ANY(),EVERY() and SOME() group functions. In ANSI SQL these only works on boolean columns, but we can extend these to work on any columns/expressions by applying: value == 0 -> FALSE and value <> 0 -> TRUE.
  • Fix that the type for MAX(column) is the same as the column type.
    create table t1 (a DATE);
    insert into t1 values (now());
    create table t2 select max(a) from t1;
    show columns from t2;
    
  • Come up with a nice syntax for a statement that will UPDATE the row if it exists and INSERT a new row if the row didn't exist. (Like REPLACE works with INSERT / DELETE)

1.6.3 Things that have to be done sometime

  • Implement function: get_changed_tables(timeout,table1,table2,...)
  • Atomic multi-table updates, eg update items,month set items.price=month.price where items.id=month.id;;
  • Change reading through tables to use memmap when possible. Now only compressed tables use memmap.
  • Add a new privilege 'Show_priv' for SHOW commands.
  • Make the automatic timestamp code nicer. Add timestamps to the update log with SET TIMESTAMP=#;
  • Use read/write mutex in some places to get more speed.
  • Full foreign key support. One probably wants to implement a procedural language first.
  • Simple views (first on one table, later on any expression).
  • Automatically close some tables if a table, temporary table or temporary files gets error 23 (not enough open files).
  • When one finds a field=#, change all occurrences of field to #. Now this is only done for some simple cases.
  • Change all const expressions with calculated expressions if possible.
  • Optimize key = expression. At the moment only key = field or key = constant are optimized.
  • Join some of the copy functions for nicer code.
  • Change `sql_yacc.yy' to an inline parser to reduce its size and get better error messages (5 days).
  • Change the parser to use only one rule per different number of arguments in function.
  • Use of full calculation names in the order part. (For ACCESS97)
  • UNION, MINUS, INTERSECT and FULL OUTER JOIN. (Currently only LEFT OUTER JOIN is supported)
  • Allow UNIQUE on fields that can be NULL.
  • SQL_OPTION MAX_SELECT_TIME=# to put a time limit on a query.
  • Make the update log to a database.
  • Negative LIMIT to retrieve data from the end.
  • Alarm around client connect/read/write functions.
  • Please note the changes to safe_mysqld: according to FSSTND (which Debian tries to follow) PID files should go into `/var/run/<progname>.pid' and log files into `/var/log'. It would be nice if you could put the "DATADIR" in the first declaration of "pidfile" and "log", so the placement of these files can be changed with a single statement.
  • Allow a client to request logging.
  • Add use of zlib() for gzip-ed files to LOAD DATA INFILE.
  • Fix sorting and grouping of BLOB columns (partly solved now).
  • Stored procedures. This is currently not regarded to be very important as stored procedures are not very standardized yet. Another problem is that true stored procedures make it much harder for the optimizer and in many cases the result is slower than before We will, on the other hand, add a simple (atomic) update language that can be used to write loops and such in the MySQL server.
  • Change to use semaphores when counting threads. One should first implement a semaphore library to MIT-pthreads.
  • Don't assign a new AUTO_INCREMENT value when one sets a column to 0. Use NULL instead.
  • Add full support for JOIN with parentheses.
  • As an alternative for one thread / connection manage a pool of threads to handle the queries.
  • Allow one to get more than one lock with GET_LOCK. When doing this, one must also handle the possible deadlocks this change will introduce.

Time is given according to amount of work, not real time.

1.6.4 Some things we don't have any plans to do

  • Nothing; In the long run we plan to be fully ANSI 92 / ANSI 99 compliant.


Go to the first, previous, next, last section, table of contents.