Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-testing > by-pkgid > b1e2421f2416edfc24c5845fbc1c5a2e > files > 96

mysql-doc-5.0.51a-8mdv2008.1.x86_64.rpm

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Chapter 1. General Information</title><link rel="stylesheet" href="mysql-html.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.69.1"><link rel="start" href="index.html" title="MySQL 5.0 Reference Manual"><link rel="up" href="index.html" title="MySQL 5.0 Reference Manual"><link rel="prev" href="preface.html" title="Preface"><link rel="next" href="installing.html" title="Chapter 2. Installing and Upgrading MySQL"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 1. General Information</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="preface.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="installing.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="introduction"></a>Chapter 1. General Information</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="introduction.html#manual-info">1.1. About This Manual</a></span></dt><dt><span class="section"><a href="introduction.html#manual-conventions">1.2. Conventions Used in This Manual</a></span></dt><dt><span class="section"><a href="introduction.html#what-is-mysql-ab">1.3. Overview of MySQL AB</a></span></dt><dt><span class="section"><a href="introduction.html#what-is">1.4. Overview of the MySQL Database Management System</a></span></dt><dd><dl><dt><span class="section"><a href="introduction.html#what-is-mysql">1.4.1. What is MySQL?</a></span></dt><dt><span class="section"><a href="introduction.html#history">1.4.2. History of MySQL</a></span></dt><dt><span class="section"><a href="introduction.html#features">1.4.3. The Main Features of MySQL</a></span></dt></dl></dd><dt><span class="section"><a href="introduction.html#roadmap">1.5. MySQL Development Roadmap</a></span></dt><dd><dl><dt><span class="section"><a href="introduction.html#mysql-nutshell">1.5.1. What's New in MySQL 5.0</a></span></dt></dl></dd><dt><span class="section"><a href="introduction.html#information-sources">1.6. MySQL Information Sources</a></span></dt><dd><dl><dt><span class="section"><a href="introduction.html#mailing-lists">1.6.1. MySQL Mailing Lists</a></span></dt><dt><span class="section"><a href="introduction.html#forums">1.6.2. MySQL Community Support at the MySQL Forums</a></span></dt><dt><span class="section"><a href="introduction.html#irc">1.6.3. MySQL Community Support on Internet Relay Chat (IRC)</a></span></dt><dt><span class="section"><a href="introduction.html#mysql-enterprise-information">1.6.4. MySQL Enterprise</a></span></dt></dl></dd><dt><span class="section"><a href="introduction.html#bug-reports">1.7. How to Report Bugs or Problems</a></span></dt><dt><span class="section"><a href="introduction.html#compatibility">1.8. MySQL Standards Compliance</a></span></dt><dd><dl><dt><span class="section"><a href="introduction.html#standards">1.8.1. What Standards MySQL Follows</a></span></dt><dt><span class="section"><a href="introduction.html#sql-mode">1.8.2. Selecting SQL Modes</a></span></dt><dt><span class="section"><a href="introduction.html#ansi-mode">1.8.3. Running MySQL in ANSI Mode</a></span></dt><dt><span class="section"><a href="introduction.html#extensions-to-ansi">1.8.4. MySQL Extensions to Standard SQL</a></span></dt><dt><span class="section"><a href="introduction.html#differences-from-ansi">1.8.5. MySQL Differences from Standard SQL</a></span></dt><dt><span class="section"><a href="introduction.html#constraints">1.8.6. How MySQL Deals with Constraints</a></span></dt></dl></dd></dl></div><a class="indexterm" name="id2481666"></a><a class="indexterm" name="id2481675"></a><p>
    The MySQL® software delivers a very fast, multi-threaded,
    multi-user, and robust SQL (Structured Query Language) database
    server. MySQL Server is intended for mission-critical, heavy-load
    production systems as well as for embedding into mass-deployed
    software. MySQL is a registered trademark of MySQL AB.
  </p><p>
    The MySQL software is Dual Licensed. Users can choose to use the
    MySQL software as an Open Source product under the terms of the GNU
    General Public License (<a href="http://www.fsf.org/licenses/" target="_top">http://www.fsf.org/licenses/</a>)
    or can purchase a standard commercial license from MySQL AB. See
    <a href="http://www.mysql.com/company/legal/licensing/" target="_top">http://www.mysql.com/company/legal/licensing/</a> for
    more information on our licensing policies.
  </p><p>
    The following list describes some sections of particular interest in
    this manual:
  </p><div class="itemizedlist"><ul type="disc"><li><p>
        For a discussion about the capabilities of the MySQL Database
        Server, see <a href="introduction.html#features" title="1.4.3. The Main Features of MySQL">Section 1.4.3, “The Main Features of MySQL”</a>.
      </p></li><li><p>
        For future plans, see <a href="introduction.html#roadmap" title="1.5. MySQL Development Roadmap">Section 1.5, “MySQL Development Roadmap”</a>.
      </p></li><li><p>
        For installation instructions, see <a href="installing.html" title="Chapter 2. Installing and Upgrading MySQL">Chapter 2, <i>Installing and Upgrading MySQL</i></a>.
        For information about upgrading MySQL, see
        <a href="installing.html#upgrade" title="2.4.17. Upgrading MySQL">Section 2.4.17, “Upgrading MySQL”</a>.
      </p></li><li><p>
        For a tutorial introduction to the MySQL Database Server, see
        <a href="tutorial.html" title="Chapter 3. Tutorial">Chapter 3, <i>Tutorial</i></a>.
      </p></li><li><p>
        For information about configuring and administering MySQL
        Server, see <a href="server-administration.html" title="Chapter 5. MySQL Server Administration">Chapter 5, <i>MySQL Server Administration</i></a>.
      </p></li><li><p>
        For information about setting up replication servers, see
        <a href="replication.html" title="Chapter 15. Replication">Chapter 15, <i>Replication</i></a>.
      </p></li><li><p>
        For answers to a number of questions that are often asked
        concerning the MySQL Database Server and its capabilities, see
        <a href="faqs.html" title="Appendix A. MySQL 5.0 Frequently Asked Questions">Appendix A, <i>MySQL 5.0 Frequently Asked Questions</i></a>.
      </p></li><li><p>
        For a list of currently known bugs and misfeatures, see
        <a href="error-handling.html#bugs" title="B.1.8. Known Issues in MySQL">Section B.1.8, “Known Issues in MySQL”</a>.
      </p></li><li><p>
        For a list of all the contributors to this project, see
        <a href="credits.html" title="Appendix G. Credits">Appendix G, <i>Credits</i></a>.
      </p></li><li><p>
        For a history of new features and bugfixes, see
        <a href="news.html" title="Appendix E. MySQL Change History">Appendix E, <i>MySQL Change History</i></a>.
      </p></li><li><p>
        For tips on porting the MySQL Database Software to new
        architectures or operating systems, see
        <a href="http://forge.mysql.com/wiki/MySQL_Internals_Porting" target="_top">MySQL
        Internals: Porting</a>.
      </p></li><li><p>
        For benchmarking information, see the
        <code class="filename">sql-bench</code> benchmarking directory in your
        MySQL distribution.
      </p></li></ul></div><div class="important" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Important</h3><p></p></div><p>
    To report errors (often called “<span class="quote">bugs</span>”), please use the
    instructions at <a href="introduction.html#bug-reports" title="1.7. How to Report Bugs or Problems">Section 1.7, “How to Report Bugs or Problems”</a>.
  </p><p>
    If you have found a sensitive security bug in MySQL Server, please
    let us know immediately by sending an email message to
    <code class="email">&lt;<a href="mailto:security@mysql.com">security@mysql.com</a>&gt;</code>.
  </p><a class="indexterm" name="id2481904"></a><a class="indexterm" name="id2481915"></a><a class="indexterm" name="id2481927"></a><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="manual-info"></a>1.1. About This Manual</h2></div></div></div><a class="indexterm" name="id2481942"></a><a class="indexterm" name="id2481951"></a><p>
      This is the Reference Manual for the MySQL Database System,
      version 5.0, through release 5.0.54. It is
      not intended for use with older versions of the MySQL software due
      to the many functional and other differences between MySQL
      5.0 and previous versions. If you are using a version
      4.1 release of the MySQL software, please refer to
      the
      <a href="http://dev.mysql.com/doc/refman/4.1/en/" target="_top"><em class="citetitle">MySQL 3.23, 4.0, 4.1 Reference Manual</em></a>,
      which covers the 3.23, 4.0, and 4.1 series of MySQL software
      releases. Differences between minor versions of MySQL
      5.0 are noted in the present text with reference to
      release numbers (5.0.<em class="replaceable"><code>x</code></em>).
    </p><p>
      Because this manual serves as a reference, it does not provide
      general instruction on SQL or relational database concepts. It
      also does not teach you how to use your operating system or
      command-line interpreter.
    </p><p>
      The MySQL Database Software is under constant development, and the
      Reference Manual is updated frequently as well. The most recent
      version of the manual is available online in searchable form at
      <a href="http://dev.mysql.com/doc/" target="_top">http://dev.mysql.com/doc/</a>. Other formats also are available
      there, including HTML, PDF, and Windows CHM versions.
    </p><a class="indexterm" name="id2482013"></a><a class="indexterm" name="id2482025"></a><p>
      The Reference Manual source files are written in DocBook XML
      format. The HTML version and other formats are produced
      automatically, primarily using the DocBook XSL stylesheets. For
      information about DocBook, see <a href="http://docbook.org/" target="_top">http://docbook.org/</a>
    </p><p>
      The DocBook XML sources of this manual are available from
      <a href="http://dev.mysql.com/tech-resources/sources.html" target="_top">http://dev.mysql.com/tech-resources/sources.html</a>.
      You can check out a copy of the documentation repository with this
      command:
    </p><pre class="programlisting">svn checkout http://svn.mysql.com/svnpublic/mysqldoc/
</pre><p>
      If you have questions about using MySQL, you can ask them using
      our mailing lists or forums. See <a href="introduction.html#mailing-lists" title="1.6.1. MySQL Mailing Lists">Section 1.6.1, “MySQL Mailing Lists”</a>,
      and <a href="introduction.html#forums" title="1.6.2. MySQL Community Support at the MySQL Forums">Section 1.6.2, “MySQL Community Support at the MySQL Forums”</a>. If you have suggestions concerning
      additions or corrections to the manual itself, please send them to
      the documentation team at <code class="email">&lt;<a href="mailto:docs@mysql.com">docs@mysql.com</a>&gt;</code>.
    </p><p>
      This manual was originally written by David Axmark and Michael
      “<span class="quote">Monty</span>” Widenius. It is maintained by the MySQL
      Documentation Team, consisting of Paul DuBois, Stefan Hinz, Jon
      Stephens, Martin MC Brown, and Peter Lavin. For the many other
      contributors, see <a href="credits.html" title="Appendix G. Credits">Appendix G, <i>Credits</i></a>.
    </p><p>
      The copyright to this manual is owned by the Swedish company MySQL
      AB. MySQL® and the MySQL logo are registered trademarks of
      MySQL AB. Other trademarks and registered trademarks referred to
      in this manual are the property of their respective owners, and
      are used for identification purposes only.
    </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="manual-conventions"></a>1.2. Conventions Used in This Manual</h2></div></div></div><p>
    This manual uses certain typographical conventions:
  </p><a class="indexterm" name="id2482133"></a><a class="indexterm" name="id2482145"></a><a class="indexterm" name="id2482154"></a><div class="itemizedlist"><ul type="disc"><li><p>
        <code class="literal">Text in this style</code> is used for SQL
        statements; database, table, and column names; program listings
        and source code; and environment variables. Example: “<span class="quote">To
        reload the grant tables, use the <code class="literal">FLUSH
        PRIVILEGES</code> statement.</span>”
      </p></li><li><p>
        <strong class="userinput"><code>Text in this style</code></strong> indicates input that
        you type in examples.
      </p></li><li><p>
        <span><strong class="command">Text in this style</strong></span> indicates the names of
        executable programs and scripts, examples being
        <span><strong class="command">mysql</strong></span> (the MySQL command line client program)
        and <span><strong class="command">mysqld</strong></span> (the MySQL server executable).
      </p></li><li><p>
        <em class="replaceable"><code>Text in this style</code></em> is used for
        variable input for which you should substitute a value of your
        own choosing.
      </p></li><li><p>
        Filenames and directory names are written like this: “<span class="quote">The
        global <code class="filename">my.cnf</code> file is located in the
        <code class="filename">/etc</code> directory.</span>”
      </p></li><li><p>
        Character sequences are written like this: “<span class="quote">To specify a
        wildcard, use the ‘<span class="quote"><code class="literal">%</code></span>’
        character.</span>”
      </p></li><li><p>
        <span class="emphasis"><em>Text in this style</em></span> is used for emphasis.
      </p></li><li><p>
        <span class="bold"><strong>Text in this style</strong></span> is used in
        table headings and to convey especially strong emphasis.
      </p></li></ul></div><p>
    When commands are shown that are meant to be executed from within a
    particular program, the prompt shown preceding the command indicates
    which command to use. For example, <code class="literal">shell&gt;</code>
    indicates a command that you execute from your login shell, and
    <code class="literal">mysql&gt;</code> indicates a statement that you execute
    from the <span><strong class="command">mysql</strong></span> client program:
  </p><pre class="programlisting">shell&gt; <strong class="userinput"><code>type a shell command here</code></strong>
mysql&gt; <strong class="userinput"><code>type a mysql statement here</code></strong>
</pre><p>
    The “<span class="quote">shell</span>” is your command interpreter. On Unix, this
    is typically a program such as <span><strong class="command">sh</strong></span>,
    <span><strong class="command">csh</strong></span>, or <span><strong class="command">bash</strong></span>. On Windows, the
    equivalent program is <span><strong class="command">command.com</strong></span> or
    <span><strong class="command">cmd.exe</strong></span>, typically run in a console window.
  </p><p>
    When you enter a command or statement shown in an example, do not
    type the prompt shown in the example.
  </p><p>
    Database, table, and column names must often be substituted into
    statements. To indicate that such substitution is necessary, this
    manual uses <em class="replaceable"><code>db_name</code></em>,
    <em class="replaceable"><code>tbl_name</code></em>, and
    <em class="replaceable"><code>col_name</code></em>. For example, you might see a
    statement like this:
  </p><pre class="programlisting">mysql&gt; <strong class="userinput"><code>SELECT <em class="replaceable"><code>col_name</code></em> FROM <em class="replaceable"><code>db_name</code></em>.<em class="replaceable"><code>tbl_name</code></em>;</code></strong>
</pre><p>
    This means that if you were to enter a similar statement, you would
    supply your own database, table, and column names, perhaps like
    this:
  </p><pre class="programlisting">mysql&gt; <strong class="userinput"><code>SELECT author_name FROM biblio_db.author_list;</code></strong>
</pre><p>
    SQL keywords are not case sensitive and may be written in any
    lettercase. This manual uses uppercase.
  </p><p>
    In syntax descriptions, square brackets
    (“<span class="quote"><code class="literal">[</code></span>” and
    “<span class="quote"><code class="literal">]</code></span>”) indicate optional words or
    clauses. For example, in the following statement, <code class="literal">IF
    EXISTS</code> is optional:
  </p><pre class="programlisting">DROP TABLE [IF EXISTS] <em class="replaceable"><code>tbl_name</code></em>
</pre><p>
    When a syntax element consists of a number of alternatives, the
    alternatives are separated by vertical bars
    (“<span class="quote"><code class="literal">|</code></span>”). When one member from a set of
    choices <span class="emphasis"><em>may</em></span> be chosen, the alternatives are
    listed within square brackets (“<span class="quote"><code class="literal">[</code></span>”
    and “<span class="quote"><code class="literal">]</code></span>”):
  </p><pre class="programlisting">TRIM([[BOTH | LEADING | TRAILING] [<em class="replaceable"><code>remstr</code></em>] FROM] <em class="replaceable"><code>str</code></em>)
</pre><p>
    When one member from a set of choices <span class="emphasis"><em>must</em></span> be
    chosen, the alternatives are listed within braces
    (“<span class="quote"><code class="literal">{</code></span>” and
    “<span class="quote"><code class="literal">}</code></span>”):
  </p><pre class="programlisting">{DESCRIBE | DESC} <em class="replaceable"><code>tbl_name</code></em> [<em class="replaceable"><code>col_name</code></em> | <em class="replaceable"><code>wild</code></em>]
</pre><p>
    An ellipsis (<code class="literal">...</code>) indicates the omission of a
    section of a statement, typically to provide a shorter version of
    more complex syntax. For example, <code class="literal">SELECT ... INTO
    OUTFILE</code> is shorthand for the form of
    <code class="literal">SELECT</code> statement that has an <code class="literal">INTO
    OUTFILE</code> clause following other parts of the statement.
  </p><p>
    An ellipsis can also indicate that the preceding syntax element of a
    statement may be repeated. In the following example, multiple
    <em class="replaceable"><code>reset_option</code></em> values may be given, with
    each of those after the first preceded by commas:
  </p><pre class="programlisting">RESET <em class="replaceable"><code>reset_option</code></em> [,<em class="replaceable"><code>reset_option</code></em>] ...
</pre><p>
    Commands for setting shell variables are shown using Bourne shell
    syntax. For example, the sequence to set the <code class="literal">CC</code>
    environment variable and run the <span><strong class="command">configure</strong></span>
    command looks like this in Bourne shell syntax:
  </p><pre class="programlisting">shell&gt; <strong class="userinput"><code>CC=gcc ./configure</code></strong>
</pre><a class="indexterm" name="id2482654"></a><a class="indexterm" name="id2482663"></a><p>
    If you are using <span><strong class="command">csh</strong></span> or <span><strong class="command">tcsh</strong></span>,
    you must issue commands somewhat differently:
  </p><pre class="programlisting">shell&gt; <strong class="userinput"><code>setenv CC gcc</code></strong>
shell&gt; <strong class="userinput"><code>./configure</code></strong>
</pre></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="what-is-mysql-ab"></a>1.3. Overview of MySQL AB</h2></div></div></div><a class="indexterm" name="id2482716"></a><p>
    MySQL AB is the company of the MySQL founders and main developers.
    MySQL AB was originally established in Sweden by David Axmark, Allan
    Larsson, and Michael “<span class="quote">Monty</span>” Widenius.
  </p><p>
    We are dedicated to developing the MySQL database software and
    promoting it to new users. MySQL AB owns the copyright to the MySQL
    source code, the MySQL logo and (registered) trademark, and this
    manual. See <a href="introduction.html#what-is" title="1.4. Overview of the MySQL Database Management System">Section 1.4, “Overview of the MySQL Database Management System”</a>.
  </p><p>
    The MySQL core values show our dedication to MySQL and Open Source.
  </p><p>
    These core values direct how MySQL AB works with the MySQL server
    software:
  </p><div class="itemizedlist"><ul type="disc"><li><p>
        To be the best and the most widely used database in the world
      </p></li><li><p>
        To be available and affordable by all
      </p></li><li><p>
        To be easy to use
      </p></li><li><p>
        To be continuously improved while remaining fast and safe
      </p></li><li><p>
        To be fun to use and improve
      </p></li><li><p>
        To be free from bugs
      </p></li></ul></div><p>
    These are the core values of the company MySQL AB and its employees:
  </p><div class="itemizedlist"><ul type="disc"><li><p>
        We subscribe to the Open Source philosophy and support the Open
        Source community
      </p></li><li><p>
        We aim to be good citizens
      </p></li><li><p>
        We prefer partners that share our values and mindset
      </p></li><li><p>
        We answer email and provide support
      </p></li><li><p>
        We are a virtual company, networking with others
      </p></li><li><p>
        We work against software patents
      </p></li></ul></div><p>
    The MySQL Web site (<a href="http://www.mysql.com/" target="_top">http://www.mysql.com/</a>) provides
    the latest information about MySQL and MySQL AB.
  </p><p>
    By the way, the “<span class="quote">AB</span>” part of the company name is the
    acronym for the Swedish “<span class="quote">aktiebolag,</span>” or “<span class="quote">stock
    company.</span>” It translates to “<span class="quote">MySQL, Inc.</span>” In
    fact, MySQL, Inc. and MySQL GmbH are examples of MySQL AB
    subsidiaries. They are located in the United States and Germany,
    respectively.
  </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="what-is"></a>1.4. Overview of the MySQL Database Management System</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="introduction.html#what-is-mysql">1.4.1. What is MySQL?</a></span></dt><dt><span class="section"><a href="introduction.html#history">1.4.2. History of MySQL</a></span></dt><dt><span class="section"><a href="introduction.html#features">1.4.3. The Main Features of MySQL</a></span></dt></dl></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="what-is-mysql"></a>1.4.1. What is MySQL?</h3></div></div></div><a class="indexterm" name="id2482910"></a><a class="indexterm" name="id2482922"></a><p>
      MySQL, the most popular Open Source SQL database management
      system, is developed, distributed, and supported by MySQL AB.
      MySQL AB is a commercial company, founded by the MySQL developers.
      It is a second generation Open Source company that unites Open
      Source values and methodology with a successful business model.
    </p><p>
      The MySQL Web site (<a href="http://www.mysql.com/" target="_top">http://www.mysql.com/</a>) provides
      the latest information about MySQL software and MySQL AB.
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          MySQL is a database management system.
        </p><p>
          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 Server.
          Since computers are very good at handling large amounts of
          data, database management systems play a central role in
          computing, as standalone utilities, or as parts of other
          applications.
        </p></li><li><p>
          MySQL is a relational database management system.
        </p><p>
          <a class="indexterm" name="id2482995"></a>

          A relational database stores data in separate tables rather
          than putting all the data in one big storeroom. This adds
          speed and flexibility. The SQL part of “<span class="quote">MySQL</span>”
          stands for “<span class="quote">Structured Query Language.</span>” SQL is
          the most common standardized language used to access databases
          and is defined by the ANSI/ISO SQL Standard. The SQL standard
          has been evolving since 1986 and several versions exist. In
          this manual, “<span class="quote">SQL-92</span>” refers to the standard
          released in 1992, “<span class="quote">SQL:1999</span>” refers to the
          standard released in 1999, and “<span class="quote">SQL:2003</span>” refers
          to the current version of the standard. We use the phrase
          “<span class="quote">the SQL standard</span>” to mean the current version of
          the SQL Standard at any time.
        </p></li><li><p>
          MySQL software is Open Source.
        </p><p>
          <a class="indexterm" name="id2483288"></a>

          <a class="indexterm" name="id2483300"></a>

          <a class="indexterm" name="id2483311"></a>

          <a class="indexterm" name="id2483323"></a>

          Open Source means that it is possible for anyone to use and
          modify the software. Anybody can download the MySQL software
          from the Internet and use it without paying anything. If you
          wish, you may study the source code and change it to suit your
          needs. The MySQL software uses the GPL (GNU General Public
          License), <a href="http://www.fsf.org/licenses/" target="_top">http://www.fsf.org/licenses/</a>, 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 code into a commercial application, you
          can buy a commercially licensed version from us. See the MySQL
          Licensing Overview for more information
          (<a href="http://www.mysql.com/company/legal/licensing/" target="_top">http://www.mysql.com/company/legal/licensing/</a>).
        </p></li><li><p>
          The MySQL Database Server is very fast, reliable, and easy to
          use.
        </p><p>
          If that is what you are looking for, you should give it a try.
          MySQL Server also has a practical set of features developed in
          close cooperation with our users. You can find a performance
          comparison of MySQL Server with other database managers on our
          benchmark page. See <a href="optimization.html#mysql-benchmarks" title="6.1.4. The MySQL Benchmark Suite">Section 6.1.4, “The MySQL Benchmark Suite”</a>.
        </p><p>
          MySQL Server was originally developed to handle large
          databases much faster than existing solutions and has been
          successfully used in highly demanding production environments
          for several years. Although under constant development, MySQL
          Server today offers a rich and useful set of functions. Its
          connectivity, speed, and security make MySQL Server highly
          suited for accessing databases on the Internet.
        </p></li><li><p>
          MySQL Server works in client/server or embedded systems.
        </p><p>
          The MySQL Database Software 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 a wide range of
          application programming interfaces (APIs).
        </p><p>
          We also provide MySQL Server as an embedded multi-threaded
          library that you can link into your application to get a
          smaller, faster, easier-to-manage standalone product.
        </p></li><li><p>
          A large amount of contributed MySQL software is available.
        </p><p>
          It is very likely that your favorite application or language
          supports the MySQL Database Server.
        </p></li></ul></div><a class="indexterm" name="id2483426"></a><a class="indexterm" name="id2483437"></a><a class="indexterm" name="id2483449"></a><p>
      The official way to pronounce “<span class="quote">MySQL</span>” is “<span class="quote">My
      Ess Que Ell</span>” (not “<span class="quote">my sequel</span>”), but we don't
      mind if you pronounce it as “<span class="quote">my sequel</span>” or in some
      other localized way.
    </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="history"></a>1.4.2. History of MySQL</h3></div></div></div><a class="indexterm" name="id2483484"></a><a class="indexterm" name="id2483493"></a><a class="indexterm" name="id2483501"></a><a class="indexterm" name="id2483510"></a><a class="indexterm" name="id2483521"></a><a class="indexterm" name="id2483530"></a><p>
      We started out with the intention of using the
      <code class="literal">mSQL</code> database system to connect to our tables
      using our own fast low-level (ISAM) routines. However, after some
      testing, we came to the conclusion that <code class="literal">mSQL</code>
      was not fast enough or flexible enough for our needs. This
      resulted in a new SQL interface to our database but with almost
      the same API interface as <code class="literal">mSQL</code>. This API was
      designed to allow third-party code that was written for use with
      <code class="literal">mSQL</code> to be ported easily for use with MySQL.
    </p><p>
      MySQL is named after co-founder Monty Widenius's daughter, My.
    </p><p>
      The name of the MySQL Dolphin (our logo) is “<span class="quote">Sakila,</span>”
      which was chosen by the founders of MySQL AB from a huge list of
      names suggested by users in our “<span class="quote">Name the Dolphin</span>”
      contest. The winning name was submitted by Ambrose Twebaze, an
      Open Source software developer from Swaziland, Africa. According
      to Ambrose, the feminine name Sakila has its roots in SiSwati, the
      local language of Swaziland. Sakila is also the name of a town in
      Arusha, Tanzania, near Ambrose's country of origin, Uganda.
    </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="features"></a>1.4.3. The Main Features of MySQL</h3></div></div></div><a class="indexterm" name="id2483603"></a><a class="indexterm" name="id2483612"></a><p>
      This section describes some of the important characteristics of
      the MySQL Database Software. See also <a href="introduction.html#roadmap" title="1.5. MySQL Development Roadmap">Section 1.5, “MySQL Development Roadmap”</a>,
      for more information about current and upcoming features. In most
      respects, it applies to all versions of MySQL. For information
      about features as they are introduced into MySQL on a
      series-specific basis, see the “<span class="quote">In a Nutshell</span>”
      section of the appropriate Manual:
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          MySQL 4.0 and 4.1:
          <a href="http://dev.mysql.com/doc/refman/4.1/en/mysql-4-0-nutshell.html" target="_top">MySQL
          4.0 in a Nutshell</a>, and
          <a href="http://dev.mysql.com/doc/refman/4.1/en/mysql-nutshell.html" target="_top">MySQL
          4.1 in a Nutshell</a>.
        </p></li><li><p>
          MySQL 5.0:
          <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-nutshell.html" target="_top">MySQL
          5.0 in a Nutshell</a>.
        </p></li><li><p>
          MySQL 5.1:
          <a href="http://dev.mysql.com/doc/refman/5.1/en/mysql-nutshell.html" target="_top">MySQL
          5.1 in a Nutshell</a>.
        </p></li></ul></div><p>
      Internals and Portability:
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          Written in C and C++.
        </p></li><li><p>
          Tested with a broad range of different compilers.
        </p></li><li><p>
          Works on many different platforms. See
          <a href="installing.html#which-os" title="2.4.2. Operating Systems Supported by MySQL Community Server">Section 2.4.2, “Operating Systems Supported by MySQL Community Server”</a>.
        </p></li><li><p>
          Uses GNU Automake, Autoconf, and Libtool for portability.
        </p></li><li><p>
          The MySQL Server design is multi-layered with independent
          modules.
        </p></li><li><p>
          Fully multi-threaded using kernel threads. It can easily use
          multiple CPUs if they are available.
        </p></li><li><p>
          Provides transactional and non-transactional storage engines.
        </p></li><li><p>
          Uses very fast B-tree disk tables (<code class="literal">MyISAM</code>)
          with index compression.
        </p></li><li><p>
          Relatively easy to add other storage engines. This is useful
          if you want to provide an SQL interface for an in-house
          database.
        </p></li><li><p>
          A very fast thread-based memory allocation system.
        </p></li><li><p>
          Very fast joins using an optimized one-sweep multi-join.
        </p></li><li><p>
          In-memory hash tables, which are used as temporary tables.
        </p></li><li><p>
          SQL functions are implemented using a highly optimized class
          library and should be as fast as possible. Usually there is no
          memory allocation at all after query initialization.
        </p></li><li><p>
          The MySQL code is tested with Purify (a commercial memory
          leakage detector) as well as with Valgrind, a GPL tool
          (<a href="http://developer.kde.org/~sewardj/" target="_top">http://developer.kde.org/~sewardj/</a>).
        </p></li><li><p>
          The server is available as a separate program for use in a
          client/server networked environment. It is also available as a
          library that can be embedded (linked) into standalone
          applications. Such applications can be used in isolation or in
          environments where no network is available.
        </p></li></ul></div><p>
      Data Types:
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          Many data types: signed/unsigned integers 1, 2, 3, 4, and 8
          bytes long, <code class="literal">FLOAT</code>,
          <code class="literal">DOUBLE</code>, <code class="literal">CHAR</code>,
          <code class="literal">VARCHAR</code>, <code class="literal">TEXT</code>,
          <code class="literal">BLOB</code>, <code class="literal">DATE</code>,
          <code class="literal">TIME</code>, <code class="literal">DATETIME</code>,
          <code class="literal">TIMESTAMP</code>, <code class="literal">YEAR</code>,
          <code class="literal">SET</code>, <code class="literal">ENUM</code>, and OpenGIS
          spatial types. See <a href="data-types.html" title="Chapter 10. Data Types">Chapter 10, <i>Data Types</i></a>.
        </p></li><li><p>
          Fixed-length and variable-length records.
        </p></li></ul></div><p>
      Statements and Functions:
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          Full operator and function support in the
          <code class="literal">SELECT</code> list and <code class="literal">WHERE</code>
          clause of queries. For example:
        </p><pre class="programlisting">mysql&gt; <strong class="userinput"><code>SELECT CONCAT(first_name, ' ', last_name)</code></strong>
    -&gt; <strong class="userinput"><code>FROM citizen</code></strong>
    -&gt; <strong class="userinput"><code>WHERE income/dependents &gt; 10000 AND age &gt; 30;</code></strong>
</pre></li><li><p>
          Full support for SQL <code class="literal">GROUP BY</code> and
          <code class="literal">ORDER BY</code> clauses. Support for group
          functions (<a href="functions.html#function_count"><code class="literal">COUNT()</code></a>,
          <a href="functions.html#function_count"><code class="literal">COUNT(DISTINCT ...)</code></a>,
          <a href="functions.html#function_avg"><code class="literal">AVG()</code></a>,
          <a href="functions.html#function_std"><code class="literal">STD()</code></a>,
          <a href="functions.html#function_sum"><code class="literal">SUM()</code></a>,
          <a href="functions.html#function_max"><code class="literal">MAX()</code></a>,
          <a href="functions.html#function_min"><code class="literal">MIN()</code></a>, and
          <a href="functions.html#function_group-concat"><code class="literal">GROUP_CONCAT()</code></a>).
        </p></li><li><p>
          Support for <code class="literal">LEFT OUTER JOIN</code> and
          <code class="literal">RIGHT OUTER JOIN</code> with both standard SQL and
          ODBC syntax.
        </p></li><li><p>
          Support for aliases on tables and columns as required by
          standard SQL.
        </p></li><li><p>
          <code class="literal">DELETE</code>, <code class="literal">INSERT</code>,
          <code class="literal">REPLACE</code>, and <code class="literal">UPDATE</code>
          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.
        </p></li><li><p>
          The MySQL-specific <code class="literal">SHOW</code> statement can be
          used to retrieve information about databases, storage engines,
          tables, and indexes. MySQL 5.0 adds support for the
          <code class="literal">INFORMATION_SCHEMA</code> database, implemented
          according to standard SQL.
        </p></li><li><p>
          The <code class="literal">EXPLAIN</code> statement can be used to
          determine how the optimizer resolves a query.
        </p></li><li><p>
          Function names do not clash with table or column names. For
          example, <code class="literal">ABS</code> is a valid column name. The
          only restriction is that for a function call, no spaces are
          allowed between the function name and the
          “<span class="quote"><code class="literal">(</code></span>” that follows it. See
          <a href="language-structure.html#reserved-words" title="8.3. Reserved Words">Section 8.3, “Reserved Words”</a>.
        </p></li><li><p>
          You can refer to tables from different databases in the same
          statement.
        </p></li></ul></div><p>
      Security:
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          A privilege and password system that is very flexible and
          secure, and that allows host-based verification.
        </p></li><li><p>
          Passwords are secure because all password traffic is encrypted
          when you connect to a server.
        </p></li></ul></div><p>
      Scalability and Limits:
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          Handles large databases. We use MySQL Server with databases
          that contain 50 million records. We also know of users who use
          MySQL Server with 60,000 tables and about 5,000,000,000 rows.
        </p></li><li><p>
          Up to 64 indexes per table are allowed (32 before MySQL
          4.1.2). Each index may consist of 1 to 16 columns or parts of
          columns. The maximum index width is 1000 bytes (767 for
          <code class="literal">InnoDB</code>); before MySQL 4.1.2, the limit is
          500 bytes. An index may use a prefix of a column for
          <code class="literal">CHAR</code>, <code class="literal">VARCHAR</code>,
          <code class="literal">BLOB</code>, or <code class="literal">TEXT</code> column
          types.
        </p></li></ul></div><p>
      Connectivity:
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          Clients can connect to MySQL Server using several protocols:
        </p><div class="itemizedlist"><ul type="circle"><li><p>
              Clients can connect using TCP/IP sockets on any platform.
            </p></li><li><p>
              On Windows systems in the NT family (NT, 2000, XP, 2003,
              or Vista), clients can connect using named pipes if the
              server is started with the
              <code class="option">--enable-named-pipe</code> option. In MySQL 4.1
              and higher, Windows servers also support shared-memory
              connections if started with the
              <code class="option">--shared-memory</code> option. Clients can
              connect through shared memory by using the
              <code class="option">--protocol=memory</code> option.
            </p></li><li><p>
              On Unix systems, clients can connect using Unix domain
              socket files.
            </p></li></ul></div></li><li><p>
          MySQL client programs can be written in many languages. A
          client library written in C is available for clients written
          in C or C++, or for any language that provides C bindings.
        </p></li><li><p>
          APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and
          Tcl are available, allowing MySQL clients to be written in
          many languages. See <a href="apis.html" title="Chapter 23. APIs and Libraries">Chapter 23, <i>APIs and Libraries</i></a>.
        </p></li><li><p>
          The Connector/ODBC (MyODBC) interface provides MySQL support
          for client programs that use ODBC (Open Database Connectivity)
          connections. For example, you can use MS Access to connect to
          your MySQL server. Clients can be run on Windows or Unix.
          MyODBC source is available. All ODBC 2.5 functions are
          supported, as are many others. See
          <a href="connectors.html" title="Chapter 24. Connectors">Chapter 24, <i>Connectors</i></a>.
        </p></li><li><p>
          The Connector/J interface provides MySQL support for Java
          client programs that use JDBC connections. Clients can be run
          on Windows or Unix. Connector/J source is available. See
          <a href="connectors.html" title="Chapter 24. Connectors">Chapter 24, <i>Connectors</i></a>.
        </p></li><li><p>
          MySQL Connector/NET enables developers to easily create .NET
          applications that require secure, high-performance data
          connectivity with MySQL. It implements the required ADO.NET
          interfaces and integrates into ADO.NET aware tools. Developers
          can build applications using their choice of .NET languages.
          MySQL Connector/NET is a fully managed ADO.NET driver written
          in 100% pure C#. See <a href="connectors.html" title="Chapter 24. Connectors">Chapter 24, <i>Connectors</i></a>.
        </p></li></ul></div><p>
      Localization:
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          The server can provide error messages to clients in many
          languages. See <a href="internationalization-localization.html#error-message-language" title="9.3. Setting the Error Message Language">Section 9.3, “Setting the Error Message Language”</a>.
        </p></li><li><p>
          Full support for several different character sets, including
          <code class="literal">latin1</code> (cp1252), <code class="literal">german</code>,
          <code class="literal">big5</code>, <code class="literal">ujis</code>, and more.
          For example, the Scandinavian characters
          “<span class="quote"><code class="literal">å</code></span>”,
          “<span class="quote"><code class="literal">ä</code></span>” and
          “<span class="quote"><code class="literal">ö</code></span>” are allowed in table and
          column names. Unicode support is available as of MySQL 4.1.
        </p></li><li><p>
          All data is saved in the chosen character set.
        </p></li><li><p>
          Sorting and comparisons are done according to the chosen
          character set and collation (using <code class="literal">latin1</code>
          and Swedish collation by default). It is possible to change
          this when the MySQL server is started. To see an example of
          very advanced sorting, look at the Czech sorting code. MySQL
          Server supports many different character sets that can be
          specified at compile time and runtime.
        </p></li><li><p>
          As of MySQL 4.1, the server time zone can be changed
          dynamically, and individual clients can specify their own time
          zone. <a href="internationalization-localization.html#time-zone-support" title="9.9. MySQL Server Time Zone Support">Section 9.9, “MySQL Server Time Zone Support”</a>.
        </p></li></ul></div><p class="mnmas"><b>MySQL Enterprise</b>
        For assistance in getting optimal performance from your MySQL
        server subscribe to MySQL Enterprise. For more information see
        <a href="http://www.mysql.com/products/enterprise/" target="_top">http://www.mysql.com/products/enterprise/</a>.
      </p><p>
      Clients and Tools:
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          MySQL AB provides several client and utility programs. These
          include both command-line programs such as
          <span><strong class="command">mysqldump</strong></span> and
          <span><strong class="command">mysqladmin</strong></span>, and graphical programs such as
          MySQL Administrator and MySQL Query Browser.
        </p></li><li><p>
          MySQL Server has built-in support for SQL statements to check,
          optimize, and repair tables. These statements are available
          from the command line through the
          <span><strong class="command">mysqlcheck</strong></span> client. MySQL also includes
          <span><strong class="command">myisamchk</strong></span>, a very fast command-line utility
          for performing these operations on <code class="literal">MyISAM</code>
          tables. See <a href="client-utility-programs.html" title="Chapter 7. Client and Utility Programs">Chapter 7, <i>Client and Utility Programs</i></a>.
        </p></li><li><p>
          MySQL programs can be invoked with the <code class="option">--help</code>
          or <code class="option">-?</code> option to obtain online assistance.
        </p></li></ul></div></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="roadmap"></a>1.5. MySQL Development Roadmap</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="introduction.html#mysql-nutshell">1.5.1. What's New in MySQL 5.0</a></span></dt></dl></div><p>
      This section describes the general MySQL development roadmap,
      including major features implemented in or planned for various
      MySQL releases. The following sections provide information for
      each release series.
    </p><p>
      The current production release series is MySQL 5.0, which was
      declared stable for production use as of MySQL 5.0.15, released in
      October 2005. The previous production release series was MySQL
      4.1, which was declared stable for production use as of MySQL
      4.1.7, released in October 2004. “<span class="quote">Production status</span>”
      means that future 5.0 and 4.1 development is limited only to
      bugfixes. For the older MySQL 4.0 and 3.23 series, only critical
      bugfixes are made.
    </p><p>
      Active MySQL development currently is taking place in the MySQL
      5.0 and 5.1 release series, and new features are being added only
      to the latter.
    </p><p>
      Before upgrading from one release series to the next, please see
      the notes in <a href="installing.html#upgrade" title="2.4.17. Upgrading MySQL">Section 2.4.17, “Upgrading MySQL”</a>.
    </p><p>
      The most requested features and the versions in which they were
      implemented or are scheduled for implementation are summarized in
      the following table:
    </p><div class="informaltable"><table border="1"><colgroup><col><col></colgroup><tbody><tr><td><span class="bold"><strong>Feature</strong></span></td><td><span class="bold"><strong>MySQL Series</strong></span></td></tr><tr><td>Unions</td><td>4.0</td></tr><tr><td>Subqueries</td><td>4.1</td></tr><tr><td>R-trees</td><td>4.1 (for the <code class="literal">MyISAM</code> storage engine)</td></tr><tr><td>Stored procedures</td><td>5.0</td></tr><tr><td>Views</td><td>5.0</td></tr><tr><td>Cursors</td><td>5.0</td></tr><tr><td>XA transactions</td><td>5.0</td></tr><tr><td>Triggers</td><td>5.0 and 5.1</td></tr><tr><td>Event scheduler</td><td>5.1</td></tr><tr><td>Partitioning</td><td>5.1</td></tr><tr><td>Pluggable storage engine API</td><td>5.1</td></tr><tr><td>Plugin API</td><td>5.1</td></tr><tr><td>Row-based replication</td><td>5.1</td></tr><tr><td>Server log tables</td><td>5.1</td></tr><tr><td>Foreign keys</td><td>6.x (implemented in 3.23 for <code class="literal">InnoDB</code>)</td></tr></tbody></table></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="mysql-nutshell"></a>1.5.1. What's New in MySQL 5.0</h3></div></div></div><p>
        The following features are implemented in MySQL 5.0.
      </p><div class="itemizedlist"><ul type="disc"><li><p>
            <span class="bold"><strong><code class="literal">BIT</code> Data
            Type</strong></span>: Can be used to store numbers in binary
            notation. See <a href="data-types.html#numeric-type-overview" title="10.1.1. Overview of Numeric Types">Section 10.1.1, “Overview of Numeric Types”</a>.
          </p></li><li><p>
            <span class="bold"><strong>Cursors</strong></span>: Elementary support
            for server-side cursors. For information about using cursors
            within stored routines, see <a href="stored-procedures.html#cursors" title="18.2.9. Cursors">Section 18.2.9, “Cursors”</a>. For
            information about using cursors from within the C API, see
            <a href="apis.html#mysql-stmt-attr-set" title="23.2.7.3. mysql_stmt_attr_set()">Section 23.2.7.3, “<code class="literal">mysql_stmt_attr_set()</code>”</a>.
          </p></li><li><p>
            <span class="bold"><strong>Information Schema</strong></span>: The
            introduction of the <code class="literal">INFORMATION_SCHEMA</code>
            database in MySQL 5.0 provided a standards-compliant means
            for accessing the MySQL Server's metadata; that is, data
            about the databases (schemas) on the server and the objects
            which they contain. See
            <a href="information-schema.html" title="Chapter 21. INFORMATION_SCHEMA Tables">Chapter 21, <i><code class="literal">INFORMATION_SCHEMA</code> Tables</i></a>.
          </p></li><li><p>
            <span class="bold"><strong>Instance Manager</strong></span>: Can be
            used to start and stop the MySQL Server, even from a remote
            host. See <a href="server-administration.html#instance-manager" title="5.4. mysqlmanager — The MySQL Instance Manager">Section 5.4, “<span><strong class="command">mysqlmanager</strong></span> — The MySQL Instance Manager”</a>.
          </p></li><li><p>
            <span class="bold"><strong>Precision Math</strong></span>: MySQL 5.0
            introduced stricter criteria for acceptance or rejection of
            data, and implemented a new library for fixed-point
            arithmetic. These contributed to a much higher degree of
            accuracy for mathematical operations and greater control
            over invalid values. See <a href="precision-math.html" title="Chapter 22. Precision Math">Chapter 22, <i>Precision Math</i></a>.
          </p></li><li><p>
            <span class="bold"><strong>Storage Engines</strong></span>: Storage
            engines added in MySQL 5.0 include
            <code class="literal">ARCHIVE</code> and <code class="literal">FEDERATED</code>.
            See <a href="storage-engines.html#archive-storage-engine" title="13.8. The ARCHIVE Storage Engine">Section 13.8, “The <code class="literal">ARCHIVE</code> Storage Engine”</a>, and
            <a href="storage-engines.html#federated-storage-engine" title="13.7. The FEDERATED Storage Engine">Section 13.7, “The <code class="literal">FEDERATED</code> Storage Engine”</a>.
          </p></li><li><p>
            <span class="bold"><strong>Stored Routines</strong></span>: Support
            for named stored procedures and stored functions was
            implemented in MySQL 5.0. See
            <a href="stored-procedures.html" title="Chapter 18. Stored Procedures and Functions">Chapter 18, <i>Stored Procedures and Functions</i></a>.
          </p></li><li><p>
            <span class="bold"><strong>Strict Mode and Standard Error
            Handling</strong></span>: MySQL 5.0 added a strict mode where by
            it follows standard SQL in a number of ways in which it did
            not previously. Support for standard SQLSTATE error messages
            was also implemented. See <a href="server-administration.html#server-sql-mode" title="5.2.6. SQL Modes">Section 5.2.6, “SQL Modes”</a>.
          </p></li><li><p>
            <span class="bold"><strong>Triggers</strong></span>: MySQL 5.0 added
            limited support for triggers. See
            <a href="triggers.html" title="Chapter 19. Triggers">Chapter 19, <i>Triggers</i></a>, and
            <a href="introduction.html#ansi-diff-triggers" title="1.8.5.3. Stored Routines and Triggers">Section 1.8.5.3, “Stored Routines and Triggers”</a>.
          </p></li><li><p>
            <span class="bold"><strong><code class="literal">VARCHAR</code> Data
            Type</strong></span>: The effective maximum length of a
            <code class="literal">VARCHAR</code> column was increased to 65,535
            bytes, and stripping of trailing whitespace was eliminated.
            (The actual maximum length of a <code class="literal">VARCHAR</code>
            is determined by the maximum row size and the character set
            you use. The maximum <span class="emphasis"><em>effective</em></span> column
            length is subject to a row size of 65,535 bytes, which is
            shared among all columns.) See
            <a href="data-types.html#string-types" title="10.4. String Types">Section 10.4, “String Types”</a>.
          </p></li><li><p>
            <span class="bold"><strong>Views</strong></span>: MySQL 5.0 added
            support for named, updatable views. See
            <a href="views.html" title="Chapter 20. Views">Chapter 20, <i>Views</i></a>, and
            <a href="introduction.html#ansi-diff-views" title="1.8.5.5. Views">Section 1.8.5.5, “Views”</a>.
          </p></li><li><p>
            <span class="bold"><strong>XA Transactions</strong></span>: See
            <a href="sql-syntax.html#xa" title="12.4.7. XA Transactions">Section 12.4.7, “XA Transactions”</a>.
          </p><p class="mnmas"><b>MySQL Enterprise</b>
              For assistance in maximizing your usage of the many new
              features of MySQL, subscribe to MySQL Enterprise. For more
              information see
              <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>.
            </p></li><li><p>
            <span class="bold"><strong>Performance enhancements</strong></span>: A
            number of improvements were made in MySQL 5.0 to improve the
            speed of certain types of queries and in the handling of
            certain types. These include:
          </p><div class="itemizedlist"><ul type="circle"><li><p>
                MySQL 5.0 introduces a new “<span class="quote">greedy</span>”
                optimizer which can greatly reduce the time required to
                arrive at a query execution plan. This is particularly
                noticeable where several tables are to be joined and no
                good join keys can otherwise be found. Without the
                greedy optimizer, the complexity of the search for an
                execution plan is calculated as
                <code class="literal"><em class="replaceable"><code>N</code></em>!</code>, where
                <em class="replaceable"><code>N</code></em> is the number of tables to
                be joined. The greedy optimizer reduces this to
                <code class="literal"><em class="replaceable"><code>N</code></em>!/(<em class="replaceable"><code>D</code></em>-1)!</code>,
                where <em class="replaceable"><code>D</code></em> is the depth of the
                search. Although the greedy optimizer does not guarantee
                the best possible of all execution plans (this is
                currently being worked on), it can reduce the time spent
                arriving at an execution plan for a join involving a
                great many tables — 30, 40, or more — by a
                factor of as much as 1,000. This should eliminate most
                if not all situations where users thought that the
                optimizer had hung when trying to perform joins across
                many tables.
              </p></li><li><p>
                Use of the <em class="firstterm">Index Merge</em> method to
                obtain better optimization of
                <a href="functions.html#operator_and"><code class="literal">AND</code></a> and
                <a href="functions.html#operator_or"><code class="literal">OR</code></a> relations over
                different keys. (Previously, these were optimized only
                where both relations in the <code class="literal">WHERE</code>
                clause involved the same key.) This also applies to
                other one-to-one comparison operators
                (<code class="literal">&gt;</code>, <code class="literal">&lt;</code>, and
                so on), including <code class="literal">=</code> and the
                <code class="literal">IN</code> operator. This means that MySQL
                can use multiple indexes in retrieving results for
                conditions such as <code class="literal">WHERE key1 &gt; 4 OR key2
                &lt; 7</code> and even combinations of conditions
                such as <code class="literal">WHERE (key1 &gt; 4 OR key2 &lt; 7) AND
                (key3 &gt;= 10 OR key4 = 1)</code>. See
                <a href="optimization.html#index-merge-optimization" title="6.2.6. Index Merge Optimization">Section 6.2.6, “Index Merge Optimization”</a>.
              </p></li><li><p>
                A new equality detector finds and optimizes
                “<span class="quote">hidden</span>” equalities in joins. For example,
                a <code class="literal">WHERE</code> clause such as
              </p><pre class="programlisting">t1.c1=t2.c2 AND t2.c2=t3.c3 AND t1.c1 &lt; 5
</pre><p>
                implies these other conditions
              </p><pre class="programlisting">t1.c1=t3.c3 AND t2.c2 &lt; 5 AND t3.c3 &lt; 5
</pre><p>
                These optimizations can be applied with any combination
                of <a href="functions.html#operator_and"><code class="literal">AND</code></a> and
                <a href="functions.html#operator_or"><code class="literal">OR</code></a> operators. See
                <a href="optimization.html#nested-joins" title="6.2.9. Nested Join Optimization">Section 6.2.9, “Nested Join Optimization”</a>, and
                <a href="optimization.html#outer-join-simplification" title="6.2.10. Outer Join Simplification">Section 6.2.10, “Outer Join Simplification”</a>.
              </p></li><li><p>
                Optimization of <code class="literal">NOT IN</code> and
                <code class="literal">NOT BETWEEN</code> relations, reducing or
                eliminating table scans for queries making use of them
                by mean of range analysis. The performance of MySQL with
                regard to these relations now matches its performance
                with regard to <code class="literal">IN</code> and
                <code class="literal">BETWEEN</code>.
              </p></li><li><p>
                The <code class="literal">VARCHAR</code> data type as implemented
                in MySQL 5.0 is more efficient than in previous
                versions, due to the elimination of the old (and
                nonstandard) removal of trailing spaces during
                retrieval.
              </p></li><li><p>
                The addition of a true <code class="literal">BIT</code> column
                type; this type is much more efficient for storage and
                retrieval of Boolean values than the workarounds
                required in MySQL in versions previous to 5.0.
              </p></li><li><p>
                <span class="bold"><strong>Performance Improvements in the
                <code class="literal">InnoDB</code> Storage Engine</strong></span>:
              </p><div class="itemizedlist"><ul type="square"><li><p>
                    New compact storage format which can save up to 20%
                    of the disk space required in previous
                    MySQL/<code class="literal">InnoDB</code> versions.
                  </p></li><li><p>
                    Faster recovery from a failed or aborted
                    <code class="literal">ALTER TABLE</code>.
                  </p></li><li><p>
                    Faster implementation of
                    <code class="literal">TRUNCATE</code>.
                  </p></li></ul></div><p>
                (See <a href="storage-engines.html#innodb" title="13.2. The InnoDB Storage Engine">Section 13.2, “The <code class="literal">InnoDB</code> Storage Engine”</a>.)
              </p></li><li><p>
                <span class="bold"><strong>Performance Improvements in the
                <code class="literal">NDBCluster</code> Storage Engine</strong></span>:
              </p><div class="itemizedlist"><ul type="square"><li><p>
                    Faster handling of queries that use
                    <code class="literal">IN</code> and
                    <code class="literal">BETWEEN</code>.
                  </p></li><li><p>
                    <span class="bold"><strong>Condition pushdown</strong></span>:
                    In cases involving the comparison of an unindexed
                    column with a constant, this condition is
                    “<span class="quote">pushed down</span>” to the cluster where it
                    is evaluated in all partitions simultaneously,
                    eliminating the need to send non-matching records
                    over the network. This can make such queries 10 to
                    100 times faster than in MySQL 4.1 Cluster.
                  </p><p>
                    See <a href="optimization.html#explain" title="6.2.1. Optimizing Queries with EXPLAIN">Section 6.2.1, “Optimizing Queries with <code class="literal">EXPLAIN</code>”</a>, for more information.
                  </p></li></ul></div><p>
                (See <a href="mysql-cluster.html" title="Chapter 16. MySQL Cluster">Chapter 16, <i>MySQL Cluster</i></a>.)
              </p></li></ul></div></li></ul></div><p>
        For those wishing to take a look at the bleeding edge of MySQL
        development, we make our BitKeeper repository for MySQL publicly
        available. See <a href="installing.html#installing-source-tree" title="2.4.15.3. Installing from the Development Source Tree">Section 2.4.15.3, “Installing from the Development Source Tree”</a>.
      </p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="information-sources"></a>1.6. MySQL Information Sources</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="introduction.html#mailing-lists">1.6.1. MySQL Mailing Lists</a></span></dt><dt><span class="section"><a href="introduction.html#forums">1.6.2. MySQL Community Support at the MySQL Forums</a></span></dt><dt><span class="section"><a href="introduction.html#irc">1.6.3. MySQL Community Support on Internet Relay Chat (IRC)</a></span></dt><dt><span class="section"><a href="introduction.html#mysql-enterprise-information">1.6.4. MySQL Enterprise</a></span></dt></dl></div><p>
    This section lists sources of additional information that you may
    find helpful, such as the MySQL mailing lists and user forums, and
    Internet Relay Chat.
  </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="mailing-lists"></a>1.6.1. MySQL Mailing Lists</h3></div></div></div><div class="toc"><dl><dt><span class="section"><a href="introduction.html#mailing-list-use">1.6.1.1. Guidelines for Using the Mailing Lists</a></span></dt></dl></div><a class="indexterm" name="id2485768"></a><a class="indexterm" name="id2485777"></a><a class="indexterm" name="id2485786"></a><a class="indexterm" name="id2485795"></a><p>
      This section introduces the MySQL mailing lists and provides
      guidelines as to how the lists should be used. When you subscribe
      to a mailing list, you receive all postings to the list as email
      messages. You can also send your own questions and answers to the
      list.
    </p><p>
      To subscribe to or unsubscribe from any of the mailing lists
      described in this section, visit
      <a href="http://lists.mysql.com/" target="_top">http://lists.mysql.com/</a>. For most of them, you can
      select the regular version of the list where you get individual
      messages, or a digest version where you get one large message per
      day.
    </p><p>
      Please <span class="emphasis"><em>do not</em></span> send messages about subscribing
      or unsubscribing to any of the mailing lists, because such
      messages are distributed automatically to thousands of other
      users.
    </p><p>
      Your local site may have many subscribers to a MySQL mailing list.
      If so, the site may have a local mailing list, so that messages
      sent from <code class="literal">lists.mysql.com</code> 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.
    </p><p>
      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 <code class="literal">List-ID:</code> or
      <code class="literal">Delivered-To:</code> headers to identify list
      messages.
    </p><p>
      The MySQL mailing lists are as follows:
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          <code class="literal">announce</code>
        </p><p>
          This list is for announcements of new versions of MySQL and
          related programs. This is a low-volume list to which all MySQL
          users should subscribe.
        </p></li><li><p>
          <code class="literal">mysql</code>
        </p><p>
          This is 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.
        </p></li><li><p>
          <code class="literal">bugs</code>
        </p><p>
          This list is for people who want to stay informed about issues
          reported since the last release of MySQL or who want to be
          actively involved in the process of bug hunting and fixing.
          See <a href="introduction.html#bug-reports" title="1.7. How to Report Bugs or Problems">Section 1.7, “How to Report Bugs or Problems”</a>.
        </p></li><li><p>
          <code class="literal">internals</code>
        </p><p>
          This list is for people who work on the MySQL code. This is
          also the forum for discussions on MySQL development and for
          posting patches.
        </p></li><li><p>
          <code class="literal">mysqldoc</code>
        </p><p>
          This list is for people who work on the MySQL documentation:
          people from MySQL AB, translators, and other community
          members.
        </p></li><li><p>
          <code class="literal">benchmarks</code>
        </p><p>
          This list is for anyone interested in performance issues.
          Discussions concentrate on database performance (not limited
          to MySQL), but also include broader categories such as
          performance of the kernel, filesystem, disk system, and so on.
        </p></li><li><p>
          <code class="literal">packagers</code>
        </p><p>
          This list is for discussions on packaging and distributing
          MySQL. This is the forum used by distribution maintainers to
          exchange ideas on packaging MySQL and on ensuring that MySQL
          looks and feels as similar as possible on all supported
          platforms and operating systems.
        </p></li><li><p>
          <code class="literal">java</code>
        </p><p>
          This list is for discussions about the MySQL server and Java.
          It is mostly used to discuss JDBC drivers such as MySQL
          Connector/J.
        </p></li><li><p>
          <code class="literal">win32</code>
        </p><p>
          This list is for all topics concerning the MySQL software on
          Microsoft operating systems, such as Windows 9x, Me, NT, 2000,
          XP, and 2003.
        </p></li><li><p>
          <code class="literal">myodbc</code>
        </p><p>
          This list is for all topics concerning connecting to the MySQL
          server with ODBC.
        </p></li><li><p>
          <code class="literal">gui-tools</code>
        </p><p>
          This list is for all topics concerning MySQL graphical user
          interface tools such as <code class="literal">MySQL Administrator</code>
          and <code class="literal">MySQL Query Browser</code>.
        </p></li><li><p>
          <code class="literal">cluster</code>
        </p><p>
          This list is for discussion of MySQL Cluster.
        </p></li><li><p>
          <code class="literal">dotnet</code>
        </p><p>
          This list is for discussion of the MySQL server and the .NET
          platform. It is mostly related to MySQL Connector/Net.
        </p></li><li><p>
          <code class="literal">plusplus</code>
        </p><p>
          This list is for all topics concerning programming with the
          C++ API for MySQL.
        </p></li><li><p>
          <code class="literal">perl</code>
        </p><p>
          This list is for all topics concerning Perl support for MySQL
          with <code class="literal">DBD::mysql</code>.
        </p></li></ul></div><p>
      If you're unable to get an answer to your questions from a MySQL
      mailing list or forum, one option is to purchase support from
      MySQL AB. This puts you in direct contact with MySQL developers.
    </p><p>
      The following table shows some MySQL mailing lists in languages
      other than English. These lists are not operated by MySQL AB.
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          <code class="literal"><code class="email">&lt;<a href="mailto:mysql-france-subscribe@yahoogroups.com">mysql-france-subscribe@yahoogroups.com</a>&gt;</code></code>
        </p><p>
          A French mailing list.
        </p></li><li><p>
          <code class="literal"><code class="email">&lt;<a href="mailto:list@tinc.net">list@tinc.net</a>&gt;</code></code>
        </p><p>
          A Korean mailing list. To subscribe, email <code class="literal">subscribe
          mysql your@email.address</code> to this list.
        </p></li><li><p>
          <code class="literal"><code class="email">&lt;<a href="mailto:mysql-de-request@lists.4t2.com">mysql-de-request@lists.4t2.com</a>&gt;</code></code>
        </p><p>
          A German mailing list. To subscribe, email <code class="literal">subscribe
          mysql-de your@email.address</code> to this list. You can
          find information about this mailing list at
          <a href="http://www.4t2.com/mysql/" target="_top">http://www.4t2.com/mysql/</a>.
        </p></li><li><p>
          <code class="literal"><code class="email">&lt;<a href="mailto:mysql-br-request@listas.linkway.com.br">mysql-br-request@listas.linkway.com.br</a>&gt;</code></code>
        </p><p>
          A Portuguese mailing list. To subscribe, email
          <code class="literal">subscribe mysql-br your@email.address</code> to
          this list.
        </p></li><li><p>
          <code class="literal"><code class="email">&lt;<a href="mailto:mysql-alta@elistas.net">mysql-alta@elistas.net</a>&gt;</code></code>
        </p><p>
          A Spanish mailing list. To subscribe, email <code class="literal">subscribe
          mysql your@email.address</code> to this list.
        </p></li></ul></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="mailing-list-use"></a>1.6.1.1. Guidelines for Using the Mailing Lists</h4></div></div></div><a class="indexterm" name="id2486326"></a><a class="indexterm" name="id2486335"></a><a class="indexterm" name="id2486347"></a><a class="indexterm" name="id2486360"></a><p>
        Please don't post mail messages from your browser with HTML mode
        turned on. Many users don't read mail with a browser.
      </p><p>
        When you answer a question sent to a mailing list, if you
        consider your answer to have broad interest, you may want to
        post it to the 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.
      </p><p>
        Try to summarize the essential part of the question in your
        reply. Don't feel obliged to quote the entire original message.
      </p><p>
        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.
      </p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="forums"></a>1.6.2. MySQL Community Support at the MySQL Forums</h3></div></div></div><a class="indexterm" name="id2486414"></a><p>
      The forums at <a href="http://forums.mysql.com" target="_top">http://forums.mysql.com</a> are an
      important community resource. Many forums are available, grouped
      into these general categories:
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          Migration
        </p></li><li><p>
          MySQL Usage
        </p></li><li><p>
          MySQL Connectors
        </p></li><li><p>
          Programming Languages
        </p></li><li><p>
          Tools
        </p></li><li><p>
          3rd-Party Applications
        </p></li><li><p>
          Storage Engines
        </p></li><li><p>
          MySQL Technology
        </p></li><li><p>
          SQL Standards
        </p></li><li><p>
          Business
        </p></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="irc"></a>1.6.3. MySQL Community Support on Internet Relay Chat (IRC)</h3></div></div></div><a class="indexterm" name="id2486517"></a><a class="indexterm" name="id2486526"></a><p>
      In addition to the various MySQL mailing lists and forums, you can
      find experienced community people on Internet Relay Chat (IRC).
      These are the best networks/channels currently known to us:
    </p><p>
      <span class="bold"><strong>freenode</strong></span> (see
      <a href="http://www.freenode.net/" target="_top">http://www.freenode.net/</a> for servers)
    </p><div class="itemizedlist"><ul type="disc"><li><p>
          <code class="literal">#mysql</code> is primarily for MySQL questions,
          but other database and general SQL questions are welcome.
          Questions about PHP, Perl, or C in combination with MySQL are
          also common.
        </p></li></ul></div><p>
      If you are looking for IRC client software to connect to an IRC
      network, take a look at <code class="literal">xChat</code>
      (<a href="http://www.xchat.org/" target="_top">http://www.xchat.org/</a>). X-Chat (GPL licensed) is
      available for Unix as well as for Windows platforms (a free
      Windows build of X-Chat is available at
      <a href="http://www.silverex.org/download/" target="_top">http://www.silverex.org/download/</a>).
    </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="mysql-enterprise-information"></a>1.6.4. MySQL Enterprise</h3></div></div></div><p>
      MySQL AB offers technical support in the form of MySQL Enterprise.
      For organizations that rely on the MySQL DBMS for
      business-critical production applications, MySQL Enterprise is a
      commercial subscription offering which includes:

      </p><div class="itemizedlist"><ul type="disc"><li><p>
            MySQL Enterprise Server
          </p></li><li><p>
            MySQL Enterprise Monitor
          </p></li><li><p>
            Monthly Rapid Updates and Quarterly Service Packs
          </p></li><li><p>
            MySQL Knowledge Base
          </p></li><li><p>
            24x7 Technical and Consultative Support
          </p></li></ul></div><p>

      MySQL Enterprise is available in multiple tiers, giving you the
      flexibility to choose the level of service that best matches your
      needs. For more information see
      <a href="http://www.mysql.com/products/enterprise/" target="_top">MySQL Enterprise</a>.
    </p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="bug-reports"></a>1.7. How to Report Bugs or Problems</h2></div></div></div><a class="indexterm" name="id2486680"></a><a class="indexterm" name="id2486692"></a><a class="indexterm" name="id2486705"></a><a class="indexterm" name="id2486717"></a><a class="indexterm" name="id2486730"></a><a class="indexterm" name="id2486742"></a><a class="indexterm" name="id2486754"></a><a class="indexterm" name="id2486767"></a><a class="indexterm" name="id2486779"></a><a class="indexterm" name="id2486792"></a><a class="indexterm" name="id2486801"></a><p>
    Before posting a bug report about a problem, please try to verify
    that it is a bug and that it has not been reported already:
  </p><div class="itemizedlist"><ul type="disc"><li><p>
        Start by searching the MySQL online manual at
        <a href="http://dev.mysql.com/doc/" target="_top">http://dev.mysql.com/doc/</a>. We try to keep the manual up to
        date by updating it frequently with solutions to newly found
        problems. The change history
        (<a href="http://dev.mysql.com/doc/mysql/en/news.html" target="_top">http://dev.mysql.com/doc/mysql/en/news.html</a>) can be
        particularly useful since it is quite possible that a newer
        version contains a solution to your problem.
      </p></li><li><p>
        If you get a parse error for a SQL statement, please check your
        syntax closely. If you can't find something wrong with it, it's
        extremely likely that your current version of MySQL Server
        doesn't support the syntax you are using. If you are using the
        current version and the manual doesn't cover the syntax that you
        are using, MySQL Server doesn't support your statement. In this
        case, your options are to implement the syntax yourself or email
        <code class="email">&lt;<a href="mailto:licensing@mysql.com">licensing@mysql.com</a>&gt;</code> and ask for an offer to
        implement it.
      </p><p>
        If the manual covers the syntax you are using, but you have an
        older version of MySQL Server, 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
        Server.
      </p></li><li><p>
        For solutions to some common problems, see
        <a href="error-handling.html#problems" title="B.1. Problems and Common Errors">Section B.1, “Problems and Common Errors”</a>.
      </p></li><li><p>
        Search the bugs database at
        <a href="http://bugs.mysql.com/" target="_top">http://bugs.mysql.com/</a> to see whether the bug has
        been reported and fixed.
      </p></li><li><p>
        Search the MySQL mailing list archives at
        <a href="http://lists.mysql.com/" target="_top">http://lists.mysql.com/</a>. See
        <a href="introduction.html#mailing-lists" title="1.6.1. MySQL Mailing Lists">Section 1.6.1, “MySQL Mailing Lists”</a>.
      </p></li><li><p>
        You can also use <a href="http://www.mysql.com/search/" target="_top">http://www.mysql.com/search/</a> to
        search all the Web pages (including the manual) that are located
        at the MySQL AB Web site.
      </p></li></ul></div><p>
    If you can't find an answer in the manual, the bugs database, or the
    mailing list archives, check with your local MySQL expert. If you
    still can't find an answer to your question, please use the
    following guidelines for reporting the bug.
  </p><p>
    The normal way to report bugs is to visit
    <a href="http://bugs.mysql.com/" target="_top">http://bugs.mysql.com/</a>, which is the address for our
    bugs database. This database is public and can be browsed and
    searched by anyone. If you log in to the system, you can enter new
    reports. If you have no Web access, you can generate a bug report by
    using the <span><strong class="command">mysqlbug</strong></span> script described at the end of
    this section.
  </p><p>
    Bugs posted in the bugs database at
    <a href="http://bugs.mysql.com/" target="_top">http://bugs.mysql.com/</a> that are corrected for a given
    release are noted in the change history.
  </p><p>
    If you have found a sensitive security bug in MySQL, you can send
    email to <code class="email">&lt;<a href="mailto:security@mysql.com">security@mysql.com</a>&gt;</code>.
  </p><p>
    To discuss problems with other users, you can use one of the MySQL
    mailing lists. <a href="introduction.html#mailing-lists" title="1.6.1. MySQL Mailing Lists">Section 1.6.1, “MySQL Mailing Lists”</a>.
  </p><p>
    Writing a good bug report takes patience, but doing it right the
    first time saves time both for us and for yourself. A good bug
    report, containing a full test case for the bug, makes it very
    likely that we will fix the bug in the next release. This section
    helps you write your report correctly so that you don't waste your
    time doing things that may not help us much or at all. Please read
    this section carefully and make sure that all the information
    described here is included in your report.
  </p><p>
    Preferably, you should test the problem using the latest production
    or development version of MySQL Server before posting. Anyone should
    be able to repeat the bug by just using <code class="literal">mysql test &lt;
    script_file</code> on your test case or by running the shell or
    Perl script that you include in the bug report. Any bug that we are
    able to repeat has a high chance of being fixed in the next MySQL
    release.
  </p><p>
    It is most helpful when a good description of the problem is
    included in the bug report. That is, give a good example of
    everything you did that led to the problem and describe, in exact
    detail, the problem itself. The best reports are those that include
    a full example showing how to reproduce the bug or problem. See
    <a href="http://forge.mysql.com/wiki/MySQL_Internals_Porting" target="_top">MySQL
    Internals: Porting</a>.
  </p><p>
    Remember that it is possible for us to respond to a report
    containing too much information, but not to one containing too
    little. People often omit facts because they think they know the
    cause of a problem and assume that some details don't matter. A good
    principle to follow is that if you are in doubt about stating
    something, state it. It is faster and less troublesome to write a
    couple more lines in your report than to wait longer for the answer
    if we must ask you to provide information that was missing from the
    initial report.
  </p><p>
    The most common errors made in bug reports are (a) not including the
    version number of the MySQL distribution that you use, and (b) not
    fully describing the platform on which the MySQL server is installed
    (including the platform type and version number). These are highly
    relevant pieces of information, and in 99 cases out of 100, the bug
    report is useless without them. Very often we get questions like,
    “<span class="quote">Why doesn't this work for me?</span>” 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 in newer MySQL versions.
    Errors often are platform-dependent. In such cases, it is next to
    impossible for us to fix anything without knowing the operating
    system and the version number of the platform.
  </p><p>
    If you compiled MySQL from source, 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 your problem
    depends on your compiler, we need to know what compiler you used.
    Note that every compiling problem should be regarded as a bug and
    reported accordingly.
  </p><p>
    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, it is better that the error message
    reported exactly matches the one that the program produces. (Even
    the lettercase should be observed.) It is best to copy and paste the
    entire error message into your report. You should never try to
    reproduce the message from memory.
  </p><p>
    If you have a problem with Connector/ODBC (MyODBC), please try to
    generate a trace file and send it with your report. See the MyODBC
    section of <a href="connectors.html" title="Chapter 24. Connectors">Chapter 24, <i>Connectors</i></a>.
  </p><p>
    If your report includes long query output lines from test cases that
    you run with the <span><strong class="command">mysql</strong></span> command-line tool, you can
    make the output more readable by using the
    <code class="option">--vertical</code> option or the <code class="literal">\G</code>
    statement terminator. The <code class="literal">EXPLAIN SELECT</code> example
    later in this section demonstrates the use of <code class="literal">\G</code>.
  </p><p>
    Please include the following information in your report:
  </p><div class="itemizedlist"><ul type="disc"><li><p>
        The version number of the MySQL distribution you are using (for
        example, MySQL 5.0.19). You can find out which version you are
        running by executing <span><strong class="command">mysqladmin version</strong></span>. The
        <span><strong class="command">mysqladmin</strong></span> program can be found in the
        <code class="filename">bin</code> directory under your MySQL installation
        directory.
      </p></li><li><p>
        The manufacturer and model of the machine on which you
        experience the problem.
      </p></li><li><p>
        The operating system name and version. If you work with Windows,
        you can usually get the name and version number by
        double-clicking your My Computer icon and pulling down the
        “<span class="quote">Help/About Windows</span>” menu. For most Unix-like
        operating systems, you can get this information by executing the
        command <code class="literal">uname -a</code>.
      </p></li><li><p>
        Sometimes the amount of memory (real and virtual) is relevant.
        If in doubt, include these values.
      </p></li><li><p>
        If you are using a source distribution of the MySQL software,
        include the name and version number of the compiler that you
        used. If you have a binary distribution, include the
        distribution name.
      </p></li><li><p>
        If the problem occurs during compilation, include the exact
        error messages and also a few lines of context around the
        offending code in the file where the error occurs.
      </p></li><li><p>
        If <span><strong class="command">mysqld</strong></span> died, you should also report the
        statement that crashed <span><strong class="command">mysqld</strong></span>. You can
        usually get this information by running
        <span><strong class="command">mysqld</strong></span> with query logging enabled, and then
        looking in the log after <span><strong class="command">mysqld</strong></span> crashes. See
        <a href="http://forge.mysql.com/wiki/MySQL_Internals_Porting" target="_top">MySQL
        Internals: Porting</a>.
      </p></li><li><p>
        If a database table is related to the problem, include the
        output from the <code class="literal">SHOW CREATE TABLE
        <em class="replaceable"><code>db_name</code></em>.<em class="replaceable"><code>tbl_name</code></em></code>
        statement in the bug report. This is a very easy way to get the
        definition of any table in a database. The information helps us
        create a situation matching the one that you have experienced.
      </p></li><li><p>
        The SQL mode in effect when the problem occurred can be
        significant, so please report the value of the
        <code class="literal">sql_mode</code> system variable. For stored
        procedure, stored function, and trigger objects, the relevant
        <code class="literal">sql_mode</code> value is the one in effect when the
        object was created. For a stored procedure or function, the
        <code class="literal">SHOW CREATE PROCEDURE</code> or <code class="literal">SHOW CREATE
        FUNCTION</code> statement shows the relevant SQL mode, or you
        can query <code class="literal">INFORMATION_SCHEMA</code> for the
        information:
      </p><pre class="programlisting">SELECT ROUTINE_SCHEMA, ROUTINE_NAME, SQL_MODE
FROM INFORMATION_SCHEMA.ROUTINES;
</pre><p>
        For triggers, you can use this statement:
      </p><pre class="programlisting">SELECT EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE, TRIGGER_NAME, SQL_MODE
FROM INFORMATION_SCHEMA.TRIGGERS;
</pre></li><li><p>
        For performance-related bugs or problems with
        <code class="literal">SELECT</code> statements, you should always include
        the output of <code class="literal">EXPLAIN SELECT ...</code>, and at
        least the number of rows that the <code class="literal">SELECT</code>
        statement produces. You should also include the output from
        <code class="literal">SHOW CREATE TABLE
        <em class="replaceable"><code>tbl_name</code></em></code> for each table
        that is involved. The more information you provide about your
        situation, the more likely it is that someone can help you.
      </p><p>
        The following is an example of a very good bug report. The
        statements are run using the <span><strong class="command">mysql</strong></span>
        command-line tool. Note the use of the <code class="literal">\G</code>
        statement terminator for statements that would otherwise provide
        very long output lines that are difficult to read.
      </p><pre class="programlisting">mysql&gt; <strong class="userinput"><code>SHOW VARIABLES;</code></strong>
mysql&gt; <strong class="userinput"><code>SHOW COLUMNS FROM ...\G</code></strong>
       <em class="replaceable"><code>&lt;output from SHOW COLUMNS&gt;</code></em>
mysql&gt; <strong class="userinput"><code>EXPLAIN SELECT ...\G</code></strong>
       <em class="replaceable"><code>&lt;output from EXPLAIN&gt;</code></em>
mysql&gt; <strong class="userinput"><code>FLUSH STATUS;</code></strong>
mysql&gt; <strong class="userinput"><code>SELECT ...;</code></strong>
       <em class="replaceable"><code>&lt;A short version of the output from SELECT,
       including the time taken to run the query&gt;</code></em>
mysql&gt; <strong class="userinput"><code>SHOW STATUS;</code></strong>
       <em class="replaceable"><code>&lt;output from SHOW STATUS&gt;</code></em>
</pre></li><li><p>
        If a bug or problem occurs while running
        <span><strong class="command">mysqld</strong></span>, try to provide an input script that
        reproduces 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 reproducible test case,
        you should upload it to be attached to the bug report.
      </p><p>
        If you can't provide a script, you should at least include the
        output from <span><strong class="command">mysqladmin variables extended-status
        processlist</strong></span> in your report to provide some information
        on how your system is performing.
      </p></li><li><p>
        If you can't produce a test case with only a few rows, or if the
        test table is too big to be included in the bug report (more
        than 10 rows), you should dump your tables using
        <span><strong class="command">mysqldump</strong></span> and create a
        <code class="filename">README</code> file that describes your problem.
        Create a compressed archive of your files using
        <span><strong class="command">tar</strong></span> and <span><strong class="command">gzip</strong></span> or
        <span><strong class="command">zip</strong></span>, and use FTP to transfer the archive to
        <a href="ftp://ftp.mysql.com/pub/mysql/upload/" target="_top">ftp://ftp.mysql.com/pub/mysql/upload/</a>. Then enter the problem into
        our bugs database at <a href="http://bugs.mysql.com/" target="_top">http://bugs.mysql.com/</a>.
      </p></li><li><p>
        If you believe that the MySQL server produces a strange result
        from a statement, include not only the result, but also your
        opinion of what the result should be, and an explanation
        describing the basis for your opinion.
      </p></li><li><p>
        When you provide an example of the problem, it's better to use
        the table names, variable names, and so forth that exist in your
        actual situation than to come up with new names. The problem
        could be related to the name of a table or variable. 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. If
        you have data that you don't want to be visible to others in the
        bug report, you can use FTP to transfer it to
        <a href="ftp://ftp.mysql.com/pub/mysql/upload/" target="_top">ftp://ftp.mysql.com/pub/mysql/upload/</a>. If the information is really
        top secret and you don't want to show it even to us, go ahead
        and provide an example using other names, but please regard this
        as the last choice.
      </p></li><li><p>
        Include all the options given to the relevant programs, if
        possible. For example, indicate the options that you use when
        you start the <span><strong class="command">mysqld</strong></span> server, as well as the
        options that you use to run any MySQL client programs. The
        options to programs such as <span><strong class="command">mysqld</strong></span> and
        <span><strong class="command">mysql</strong></span>, and to the
        <span><strong class="command">configure</strong></span> script, are often key to resolving
        problems and are very relevant. It is never a bad idea to
        include them. If your problem involves a program written in a
        language such as Perl or PHP, please include the language
        processor's version number, as well as the version for any
        modules that the program uses. For example, if you have a Perl
        script that uses the <code class="literal">DBI</code> and
        <code class="literal">DBD::mysql</code> modules, include the version
        numbers for Perl, <code class="literal">DBI</code>, and
        <code class="literal">DBD::mysql</code>.
      </p></li><li><p>
        If your question is related to the privilege system, please
        include the output of <span><strong class="command">mysqlaccess</strong></span>, the output
        of <span><strong class="command">mysqladmin reload</strong></span>, and all the error
        messages you get when trying to connect. When you test your
        privileges, you should first run <span><strong class="command">mysqlaccess</strong></span>.
        After this, execute <span><strong class="command">mysqladmin reload version</strong></span>
        and try to connect with the program that gives you trouble.
        <span><strong class="command">mysqlaccess</strong></span> can be found in the
        <code class="filename">bin</code> directory under your MySQL installation
        directory.
      </p></li><li><p>
        If you have a patch for a bug, do include it. But don't assume
        that the patch is all we need, or that we can 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.
      </p><p>
        If we can't verify the exact purpose of the patch, we won't use
        it. Test cases help us here. Show that the patch handles 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.
      </p></li><li><p>
        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.
      </p></li><li><p>
        Indicate in your bug report that you have checked the reference
        manual and mail archive so that others know you have tried to
        solve the problem yourself.
      </p></li><li><p>
        If the problem is that your data appears corrupt or you get
        errors when you access a particular table, you should first
        check your tables and then try to repair them with
        <code class="literal">CHECK TABLE</code> and <code class="literal">REPAIR
        TABLE</code> or with <span><strong class="command">myisamchk</strong></span>. See
        <a href="server-administration.html" title="Chapter 5. MySQL Server Administration">Chapter 5, <i>MySQL Server Administration</i></a>.
      </p><p>
        If you are running Windows, please verify the value of
        <code class="literal">lower_case_table_names</code> using the
        <code class="literal">SHOW VARIABLES LIKE 'lower_case_table_names'</code>
        command. This variable affects how the server handles lettercase
        of database and table names. Its effect for a given value should
        be as described in
        <a href="language-structure.html#identifier-case-sensitivity" title="8.2.2. Identifier Case Sensitivity">Section 8.2.2, “Identifier Case Sensitivity”</a>.
      </p></li><li><p>
        If you often get corrupted tables, you should try to find out
        when and why this happens. In this case, the error log in the
        MySQL data directory may contain some information about what
        happened. (This is the file with the <code class="filename">.err</code>
        suffix in the name.) See <a href="server-administration.html#error-log" title="5.10.1. The Error Log">Section 5.10.1, “The Error Log”</a>. Please
        include any relevant information from this file in your bug
        report. Normally <span><strong class="command">mysqld</strong></span> should
        <span class="emphasis"><em>never</em></span> crash a table if nothing killed it in
        the middle of an update. If you can find the cause of
        <span><strong class="command">mysqld</strong></span> dying, it's much easier for us to
        provide you with a fix for the problem. See
        <a href="error-handling.html#what-is-crashing" title="B.1.1. How to Determine What Is Causing a Problem">Section B.1.1, “How to Determine What Is Causing a Problem”</a>.
      </p></li><li><p>
        If possible, download and install the most recent version of
        MySQL Server and check whether it solves your problem. All
        versions of the MySQL software 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 without difficulty. See
        <a href="installing.html#which-version" title="2.4.3. Choosing Which MySQL Distribution to Install">Section 2.4.3, “Choosing Which MySQL Distribution to Install”</a>.
      </p></li></ul></div><a class="indexterm" name="id2488013"></a><a class="indexterm" name="id2488026"></a><p>
    If you have no Web access and cannot report a bug by visiting
    <a href="http://bugs.mysql.com/" target="_top">http://bugs.mysql.com/</a>, you can use the
    <span><strong class="command">mysqlbug</strong></span> script to generate a bug report (or a
    report about any problem). <span><strong class="command">mysqlbug</strong></span> 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. <span><strong class="command">mysqlbug</strong></span> can be found in
    the <code class="filename">scripts</code> directory (source distribution) and
    in the <code class="filename">bin</code> directory under your MySQL
    installation directory (binary distribution).
  </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="compatibility"></a>1.8. MySQL Standards Compliance</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="introduction.html#standards">1.8.1. What Standards MySQL Follows</a></span></dt><dt><span class="section"><a href="introduction.html#sql-mode">1.8.2. Selecting SQL Modes</a></span></dt><dt><span class="section"><a href="introduction.html#ansi-mode">1.8.3. Running MySQL in ANSI Mode</a></span></dt><dt><span class="section"><a href="introduction.html#extensions-to-ansi">1.8.4. MySQL Extensions to Standard SQL</a></span></dt><dt><span class="section"><a href="introduction.html#differences-from-ansi">1.8.5. MySQL Differences from Standard SQL</a></span></dt><dt><span class="section"><a href="introduction.html#constraints">1.8.6. How MySQL Deals with Constraints</a></span></dt></dl></div><a class="indexterm" name="id2488097"></a><a class="indexterm" name="id2488110"></a><a class="indexterm" name="id2488119"></a><a class="indexterm" name="id2488132"></a><a class="indexterm" name="id2488144"></a><p>
      This section describes how MySQL relates to the ANSI/ISO SQL
      standards. MySQL Server has many extensions to the SQL standard,
      and here you can find out what they are and how to use them. You
      can also find information about functionality missing from MySQL
      Server, and how to work around some of the differences.
    </p><p>
      The SQL standard has been evolving since 1986 and several versions
      exist. In this manual, “<span class="quote">SQL-92</span>” refers to the
      standard released in 1992, “<span class="quote">SQL:1999</span>” refers to the
      standard released in 1999, and “<span class="quote">SQL:2003</span>” refers to
      the current version of the standard. We use the phrase “<span class="quote">the
      SQL standard</span>” or “<span class="quote">standard SQL</span>” to mean the
      current version of the SQL Standard at any time.
    </p><p>
      One of our main goals with the product is to continue to work
      toward compliance with the SQL standard, but without sacrificing
      speed or reliability. We are not afraid to add extensions to SQL
      or support for non-SQL features if this greatly increases the
      usability of MySQL Server for a large segment of our user base.
      The <code class="literal">HANDLER</code> interface is an example of this
      strategy. See <a href="sql-syntax.html#handler" title="12.2.3. HANDLER Syntax">Section 12.2.3, “<code class="literal">HANDLER</code> Syntax”</a>.
    </p><p>
      We continue to support transactional and non-transactional
      databases to satisfy both mission-critical 24/7 usage and heavy
      Web or logging usage.
    </p><p>
      MySQL Server was originally designed to work with medium-sized
      databases (10-100 million rows, or about 100MB per table) on small
      computer systems. Today MySQL Server handles terabyte-sized
      databases, but the code can also be compiled in a reduced version
      suitable for hand-held and embedded devices. The compact design of
      the MySQL server makes development in both directions possible
      without any conflicts in the source tree.
    </p><p>
      Currently, we are not targeting real-time support, although MySQL
      replication capabilities offer significant functionality.
    </p><p>
      MySQL supports high-availability database clustering using the
      <code class="literal">NDBCluster</code> storage engine. See
      <a href="mysql-cluster.html" title="Chapter 16. MySQL Cluster">Chapter 16, <i>MySQL Cluster</i></a>.
    </p><p>
      XML support is to be implemented in a future version of the
      database server.
    </p><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="standards"></a>1.8.1. What Standards MySQL Follows</h3></div></div></div><p>
        Our aim is to support the full ANSI/ISO SQL standard, but
        without making concessions to speed and quality of the code.
      </p><p>
        ODBC levels 0-3.51.
      </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="sql-mode"></a>1.8.2. Selecting SQL Modes</h3></div></div></div><p>
        The MySQL server can operate in different SQL modes, and can
        apply these modes differentially for different clients. This
        capability enables each application to tailor the server's
        operating mode to its own requirements.
      </p><p>
        SQL modes control aspects of server operation such as what SQL
        syntax MySQL should support and what kind of data validation
        checks it should perform. This makes it easier to use MySQL in
        different environments and to use MySQL together with other
        database servers.
      </p><p>
        You can set the default SQL mode by starting
        <span><strong class="command">mysqld</strong></span> with the
        <code class="option">--sql-mode="<em class="replaceable"><code>mode_value</code></em>"</code>
        option. You can also change the mode at runtime by setting the
        <code class="literal">sql_mode</code> system variable with a <code class="literal">SET
        [SESSION|GLOBAL]
        sql_mode='<em class="replaceable"><code>mode_value</code></em>'</code>
        statement.
      </p><p>
        For more information on setting the SQL mode, see
        <a href="server-administration.html#server-sql-mode" title="5.2.6. SQL Modes">Section 5.2.6, “SQL Modes”</a>.
      </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="ansi-mode"></a>1.8.3. Running MySQL in ANSI Mode</h3></div></div></div><a class="indexterm" name="id2488355"></a><a class="indexterm" name="id2488368"></a><p>
        You can tell <span><strong class="command">mysqld</strong></span> to run in ANSI mode with
        the <code class="option">--ansi</code> startup option. Running the server
        in ANSI mode is the same as starting it with the following
        options:
      </p><pre class="programlisting">--transaction-isolation=SERIALIZABLE --sql-mode=ANSI
</pre><p>
        You can achieve the same effect at runtime by executing these
        two statements:
      </p><pre class="programlisting">SET GLOBAL TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SET GLOBAL sql_mode = 'ANSI';
</pre><p>
        You can see that setting the <code class="literal">sql_mode</code> system
        variable to <code class="literal">'ANSI'</code> enables all SQL mode
        options that are relevant for ANSI mode as follows:
      </p><pre class="programlisting">mysql&gt; <strong class="userinput"><code>SET GLOBAL sql_mode='ANSI';</code></strong>
mysql&gt; <strong class="userinput"><code>SELECT @@global.sql_mode;</code></strong>
        -&gt; 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI'
</pre><p>
        Note that running the server in ANSI mode with
        <code class="option">--ansi</code> is not quite the same as setting the SQL
        mode to <code class="literal">'ANSI'</code>. The <code class="option">--ansi</code>
        option affects the SQL mode and also sets the transaction
        isolation level. Setting the SQL mode to
        <code class="literal">'ANSI'</code> has no effect on the isolation level.
      </p><p>
        See <a href="server-administration.html#server-options" title="5.2.2. Command Options">Section 5.2.2, “Command Options”</a>, and
        <a href="introduction.html#sql-mode" title="1.8.2. Selecting SQL Modes">Section 1.8.2, “Selecting SQL Modes”</a>.
      </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="extensions-to-ansi"></a>1.8.4. MySQL Extensions to Standard SQL</h3></div></div></div><a class="indexterm" name="id2488504"></a><a class="indexterm" name="id2488517"></a><p>
        MySQL Server supports some extensions that you probably won't
        find in other SQL DBMSs. Be warned that if you use them, your
        code won't 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 following form:
      </p><pre class="programlisting">/*! <em class="replaceable"><code>MySQL-specific code</code></em> */
</pre><p>
        In this case, MySQL Server parses and executes the code within
        the comment as it would any other SQL statement, but other SQL
        servers will ignore the extensions. For example, MySQL Server
        recognizes the <code class="literal">STRAIGHT_JOIN</code> keyword in the
        following statement, but other servers will not:
      </p><pre class="programlisting">SELECT /*! STRAIGHT_JOIN */ col1 FROM table1,table2 WHERE ...
</pre><p>
        If you add a version number after the
        “<span class="quote"><code class="literal">!</code></span>” character, the syntax within
        the comment is executed only if the MySQL version is greater
        than or equal to the specified version number. The
        <code class="literal">TEMPORARY</code> keyword in the following comment is
        executed only by servers from MySQL 3.23.02 or higher:
      </p><pre class="programlisting">CREATE /*!32302 TEMPORARY */ TABLE t (a INT);
</pre><p>
        The following descriptions list MySQL extensions, organized by
        category.
      </p><div class="itemizedlist"><ul type="disc"><li><p>
            Organization of data on disk
          </p><p>
            MySQL Server maps each database to a directory under the
            MySQL data directory, and maps tables within a database to
            filenames in the database directory. This has a few
            implications:
          </p><div class="itemizedlist"><ul type="circle"><li><p>
                <a class="indexterm" name="id2488621"></a>

                <a class="indexterm" name="id2488634"></a>

                <a class="indexterm" name="id2488646"></a>

                <a class="indexterm" name="id2488659"></a>

                Database and table names are case sensitive in MySQL
                Server on operating systems that have case-sensitive
                filenames (such as most Unix systems). See
                <a href="language-structure.html#identifier-case-sensitivity" title="8.2.2. Identifier Case Sensitivity">Section 8.2.2, “Identifier Case Sensitivity”</a>.
              </p></li><li><p>
                You can use standard system commands to back up, rename,
                move, delete, and copy tables that are managed by the
                <code class="literal">MyISAM</code> storage engine. For example,
                it is possible to rename a <code class="literal">MyISAM</code>
                table by renaming the <code class="filename">.MYD</code>,
                <code class="filename">.MYI</code>, and <code class="filename">.frm</code>
                files to which the table corresponds. (Nevertheless, it
                is preferable to use <code class="literal">RENAME TABLE</code> or
                <code class="literal">ALTER TABLE ... RENAME</code> and let the
                server rename the files.)
              </p></li></ul></div><p>
            Database and table names cannot contain pathname separator
            characters (“<span class="quote"><code class="literal">/</code></span>”,
            “<span class="quote"><code class="literal">\</code></span>”).
          </p></li><li><p>
            General language syntax
          </p><div class="itemizedlist"><ul type="circle"><li><p>
                By default, strings can be enclosed by either
                “<span class="quote"><code class="literal">"</code></span>” or
                “<span class="quote"><code class="literal">'</code></span>”, not just by
                “<span class="quote"><code class="literal">'</code></span>”. (If the
                <code class="literal">ANSI_QUOTES</code> SQL mode is enabled,
                strings can be enclosed only by
                “<span class="quote"><code class="literal">'</code></span>” and the server
                interprets strings enclosed by
                “<span class="quote"><code class="literal">"</code></span>” as identifiers.)
              </p></li><li><p>
                “<span class="quote"><code class="literal">\</code></span>” is the escape
                character in strings.
              </p></li><li><p>
                In SQL statements, you can access tables from different
                databases with the
                <em class="replaceable"><code>db_name.tbl_name</code></em> syntax. Some
                SQL servers provide the same functionality but call this
                <code class="literal">User space</code>. MySQL Server doesn't
                support tablespaces such as used in statements like
                this: <code class="literal">CREATE TABLE ralph.my_table ... IN
                my_tablespace</code>.
              </p></li></ul></div></li><li><p>
            SQL statement syntax
          </p><div class="itemizedlist"><ul type="circle"><li><p>
                The <code class="literal">ANALYZE TABLE</code>, <code class="literal">CHECK
                TABLE</code>, <code class="literal">OPTIMIZE TABLE</code>, and
                <code class="literal">REPAIR TABLE</code> statements.
              </p></li><li><p>
                The <code class="literal">CREATE DATABASE</code>, <code class="literal">DROP
                DATABASE</code>, and <code class="literal">ALTER
                DATABASE</code> statements. See
                <a href="sql-syntax.html#create-database" title="12.1.3. CREATE DATABASE Syntax">Section 12.1.3, “<code class="literal">CREATE DATABASE</code> Syntax”</a>,
                <a href="sql-syntax.html#drop-database" title="12.1.6. DROP DATABASE Syntax">Section 12.1.6, “<code class="literal">DROP DATABASE</code> Syntax”</a>, and
                <a href="sql-syntax.html#alter-database" title="12.1.1. ALTER DATABASE Syntax">Section 12.1.1, “<code class="literal">ALTER DATABASE</code> Syntax”</a>.
              </p></li><li><p>
                The <code class="literal">DO</code> statement.
              </p></li><li><p>
                <code class="literal">EXPLAIN SELECT</code> to obtain a
                description of how tables are processed by the query
                optimizer.
              </p></li><li><p>
                The <code class="literal">FLUSH</code> and
                <code class="literal">RESET</code> statements.
              </p></li><li><p>
                The <code class="literal">SET</code> statement. See
                <a href="sql-syntax.html#set-option" title="12.5.3. SET Syntax">Section 12.5.3, “<code class="literal">SET</code> Syntax”</a>.
              </p></li><li><p>
                The <code class="literal">SHOW</code> statement. See
                <a href="sql-syntax.html#show" title="12.5.4. SHOW Syntax">Section 12.5.4, “<code class="literal">SHOW</code> Syntax”</a>. As of MySQL 5.0, the information
                produced by many of the MySQL-specific
                <code class="literal">SHOW</code> statements can be obtained in
                more standard fashion by using <code class="literal">SELECT</code>
                to query <code class="literal">INFORMATION_SCHEMA</code>. See
                <a href="information-schema.html" title="Chapter 21. INFORMATION_SCHEMA Tables">Chapter 21, <i><code class="literal">INFORMATION_SCHEMA</code> Tables</i></a>.
              </p></li><li><p>
                <a class="indexterm" name="id2489060"></a>

                <a class="indexterm" name="id2489069"></a>

                Use of <code class="literal">LOAD DATA INFILE</code>. In many
                cases, this syntax is compatible with Oracle's
                <code class="literal">LOAD DATA INFILE</code>. See
                <a href="sql-syntax.html#load-data" title="12.2.5. LOAD DATA INFILE Syntax">Section 12.2.5, “<code class="literal">LOAD DATA INFILE</code> Syntax”</a>.
              </p></li><li><p>
                Use of <code class="literal">RENAME TABLE</code>. See
                <a href="sql-syntax.html#rename-table" title="12.1.9. RENAME TABLE Syntax">Section 12.1.9, “<code class="literal">RENAME TABLE</code> Syntax”</a>.
              </p></li><li><p>
                Use of <code class="literal">REPLACE</code> instead of
                <code class="literal">DELETE</code> plus
                <code class="literal">INSERT</code>. See
                <a href="sql-syntax.html#replace" title="12.2.6. REPLACE Syntax">Section 12.2.6, “<code class="literal">REPLACE</code> Syntax”</a>.
              </p></li><li><p>
                Use of <code class="literal">CHANGE
                <em class="replaceable"><code>col_name</code></em></code>,
                <code class="literal">DROP
                <em class="replaceable"><code>col_name</code></em></code>, or
                <code class="literal">DROP INDEX</code>, <code class="literal">IGNORE</code>
                or <code class="literal">RENAME</code> in <code class="literal">ALTER
                TABLE</code> statements. Use of multiple
                <code class="literal">ADD</code>, <code class="literal">ALTER</code>,
                <code class="literal">DROP</code>, or <code class="literal">CHANGE</code>
                clauses in an <code class="literal">ALTER TABLE</code> statement.
                See <a href="sql-syntax.html#alter-table" title="12.1.2. ALTER TABLE Syntax">Section 12.1.2, “<code class="literal">ALTER TABLE</code> Syntax”</a>.
              </p></li><li><p>
                Use of index names, indexes on a prefix of a column, and
                use of <code class="literal">INDEX</code> or
                <code class="literal">KEY</code> in <code class="literal">CREATE
                TABLE</code> statements. See
                <a href="sql-syntax.html#create-table" title="12.1.5. CREATE TABLE Syntax">Section 12.1.5, “<code class="literal">CREATE TABLE</code> Syntax”</a>.
              </p></li><li><p>
                Use of <code class="literal">TEMPORARY</code> or <code class="literal">IF NOT
                EXISTS</code> with <code class="literal">CREATE TABLE</code>.
              </p></li><li><p>
                Use of <code class="literal">IF EXISTS</code> with <code class="literal">DROP
                TABLE</code> and <code class="literal">DROP DATABASE</code>.
              </p></li><li><p>
                The capability of dropping multiple tables with a single
                <code class="literal">DROP TABLE</code> statement.
              </p></li><li><p>
                The <code class="literal">ORDER BY</code> and
                <code class="literal">LIMIT</code> clauses of the
                <code class="literal">UPDATE</code> and <code class="literal">DELETE</code>
                statements.
              </p></li><li><p>
                <code class="literal">INSERT INTO <em class="replaceable"><code>tbl_name</code></em>
                SET <em class="replaceable"><code>col_name</code></em> = ...</code>
                syntax.
              </p></li><li><p>
                The <code class="literal">DELAYED</code> clause of the
                <code class="literal">INSERT</code> and <code class="literal">REPLACE</code>
                statements.
              </p></li><li><p>
                The <code class="literal">LOW_PRIORITY</code> clause of the
                <code class="literal">INSERT</code>, <code class="literal">REPLACE</code>,
                <code class="literal">DELETE</code>, and <code class="literal">UPDATE</code>
                statements.
              </p></li><li><p>
                Use of <code class="literal">INTO OUTFILE</code> or <code class="literal">INTO
                DUMPFILE</code> in <code class="literal">SELECT</code>
                statements. See <a href="sql-syntax.html#select" title="12.2.7. SELECT Syntax">Section 12.2.7, “<code class="literal">SELECT</code> Syntax”</a>.
              </p></li><li><p>
                Options such as <code class="literal">STRAIGHT_JOIN</code> or
                <code class="literal">SQL_SMALL_RESULT</code> in
                <code class="literal">SELECT</code> statements.
              </p></li><li><p>
                You don't need to name all selected columns in the
                <code class="literal">GROUP BY</code> clause. This gives better
                performance for some very specific, but quite normal
                queries. See
                <a href="functions.html#group-by-functions-and-modifiers" title="11.11. Functions and Modifiers for Use with GROUP BY Clauses">Section 11.11, “Functions and Modifiers for Use with <code class="literal">GROUP BY</code> Clauses”</a>.
              </p></li><li><p>
                You can specify <code class="literal">ASC</code> and
                <code class="literal">DESC</code> with <code class="literal">GROUP
                BY</code>, not just with <code class="literal">ORDER BY</code>.
              </p></li><li><p>
                The ability to set variables in a statement with the
                <code class="literal">:=</code> assignment operator:
              </p><pre class="programlisting">mysql&gt; <strong class="userinput"><code>SELECT @a:=SUM(total),@b:=COUNT(*),@a/@b AS avg</code></strong>
    -&gt; <strong class="userinput"><code>FROM test_table;</code></strong>
mysql&gt; <strong class="userinput"><code>SELECT @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;</code></strong>
</pre></li></ul></div></li><li><p>
            Data types
          </p><div class="itemizedlist"><ul type="circle"><li><p>
                The <code class="literal">MEDIUMINT</code>,
                <code class="literal">SET</code>, and <code class="literal">ENUM</code> data
                types, and the various <code class="literal">BLOB</code> and
                <code class="literal">TEXT</code> data types.
              </p></li><li><p>
                The <code class="literal">AUTO_INCREMENT</code>,
                <code class="literal">BINARY</code>, <code class="literal">NULL</code>,
                <code class="literal">UNSIGNED</code>, and
                <code class="literal">ZEROFILL</code> data type attributes.
              </p></li></ul></div></li><li><p>
            Functions and operators
          </p><div class="itemizedlist"><ul type="circle"><li><p>
                To make it easier for users who migrate from other SQL
                environments, MySQL Server supports aliases for many
                functions. For example, all string functions support
                both standard SQL syntax and ODBC syntax.
              </p></li><li><p>
                MySQL Server understands the
                <a href="functions.html#operator_or"><code class="literal">||</code></a>
                and
                <a href="functions.html#operator_and"><code class="literal">&amp;&amp;</code></a>
                operators to mean logical OR and AND, as in the C
                programming language. In MySQL Server,
                <a href="functions.html#operator_or"><code class="literal">||</code></a>
                and
                <a href="functions.html#operator_or"><code class="literal">OR</code></a>
                are synonyms, as are
                <a href="functions.html#operator_and"><code class="literal">&amp;&amp;</code></a>
                and
                <a href="functions.html#operator_and"><code class="literal">AND</code></a>.
                Because of this nice syntax, MySQL Server doesn't
                support the standard SQL
                <a href="functions.html#operator_or"><code class="literal">||</code></a>
                operator for string concatenation; use
                <a href="functions.html#function_concat"><code class="literal">CONCAT()</code></a> instead.
                Because <a href="functions.html#function_concat"><code class="literal">CONCAT()</code></a> takes
                any number of arguments, it's easy to convert use of the
                <a href="functions.html#operator_or"><code class="literal">||</code></a>
                operator to MySQL Server.
              </p></li><li><p>
                Use of <a href="functions.html#function_count"><code class="literal">COUNT(DISTINCT
                <em class="replaceable"><code>value_list</code></em>)</code></a> where
                <em class="replaceable"><code>value_list</code></em> has more than one
                element.
              </p></li><li><p>
                String comparisons are case-insensitive by default, with
                sort ordering determined by the collation of the current
                character set, which is <code class="literal">latin1</code>
                (cp1252 West European) by default. If you don't like
                this, you should declare your columns with the
                <code class="literal">BINARY</code> attribute or use the
                <code class="literal">BINARY</code> cast, which causes comparisons
                to be done using the underlying character code values
                rather then a lexical ordering.
              </p></li><li><p>
                <a class="indexterm" name="id2489856"></a>

                <a class="indexterm" name="id2489865"></a>

                The
                <a href="functions.html#function_mod"><code class="literal">%</code></a>
                operator is a synonym for
                <a href="functions.html#function_mod"><code class="literal">MOD()</code></a>. That is,
                <code class="literal"><em class="replaceable"><code>N</code></em> %
                <em class="replaceable"><code>M</code></em></code> is equivalent to
                <a href="functions.html#function_mod"><code class="literal">MOD(<em class="replaceable"><code>N</code></em>,<em class="replaceable"><code>M</code></em>)</code></a>.
                <a href="functions.html#function_mod"><code class="literal">%</code></a>
                is supported for C programmers and for compatibility
                with PostgreSQL.
              </p></li><li><p>
                The
                <a href="functions.html#operator_equal"><code class="literal">=</code></a>,
                <a href="functions.html#operator_not-equal"><code class="literal">&lt;&gt;</code></a>,
                <a href="functions.html#operator_less-than-or-equal"><code class="literal">&lt;=</code></a>,
                <a href="functions.html#operator_less-than"><code class="literal">&lt;</code></a>,
                <a href="functions.html#operator_greater-than-or-equal"><code class="literal">&gt;=</code></a>,
                <a href="functions.html#operator_greater-than"><code class="literal">&gt;</code></a>,
                <a href="functions.html#operator_left-shift"><code class="literal">&lt;&lt;</code></a>,
                <a href="functions.html#operator_right-shift"><code class="literal">&gt;&gt;</code></a>,
                <a href="functions.html#operator_equal-to"><code class="literal">&lt;=&gt;</code></a>,
                <a href="functions.html#operator_and"><code class="literal">AND</code></a>,
                <a href="functions.html#operator_or"><code class="literal">OR</code></a>,
                or
                <a href="functions.html#operator_like"><code class="literal">LIKE</code></a>
                operators may be used in expressions in the output
                column list (to the left of the <code class="literal">FROM</code>)
                in <code class="literal">SELECT</code> statements. For example:
              </p><pre class="programlisting">mysql&gt; <strong class="userinput"><code>SELECT col1=1 AND col2=2 FROM my_table;</code></strong>
</pre></li><li><p>
                The <a href="functions.html#function_last-insert-id"><code class="literal">LAST_INSERT_ID()</code></a>
                function returns the most recent
                <code class="literal">AUTO_INCREMENT</code> value. See
                <a href="functions.html#information-functions" title="11.10.3. Information Functions">Section 11.10.3, “Information Functions”</a>.
              </p></li><li><p>
                <code class="literal">LIKE</code> is allowed on numeric values.
              </p></li><li><p>
                The <code class="literal">REGEXP</code> and <code class="literal">NOT
                REGEXP</code> extended regular expression operators.
              </p></li><li><p>
                <a href="functions.html#function_concat"><code class="literal">CONCAT()</code></a> or
                <a href="functions.html#function_char"><code class="literal">CHAR()</code></a> with one argument
                or more than two arguments. (In MySQL Server, these
                functions can take a variable number of arguments.)
              </p></li><li><p>
                The <a href="functions.html#function_bit-count"><code class="literal">BIT_COUNT()</code></a>,
                <a href="functions.html#operator_case"><code class="literal">CASE</code></a>,
                <a href="functions.html#function_elt"><code class="literal">ELT()</code></a>,
                <a href="functions.html#function_from-days"><code class="literal">FROM_DAYS()</code></a>,
                <a href="functions.html#function_format"><code class="literal">FORMAT()</code></a>,
                <a href="functions.html#function_if"><code class="literal">IF()</code></a>,
                <a href="functions.html#function_password"><code class="literal">PASSWORD()</code></a>,
                <a href="functions.html#function_encrypt"><code class="literal">ENCRYPT()</code></a>,
                <a href="functions.html#function_md5"><code class="literal">MD5()</code></a>,
                <a href="functions.html#function_encode"><code class="literal">ENCODE()</code></a>,
                <a href="functions.html#function_decode"><code class="literal">DECODE()</code></a>,
                <a href="functions.html#function_period-add"><code class="literal">PERIOD_ADD()</code></a>,
                <a href="functions.html#function_period-diff"><code class="literal">PERIOD_DIFF()</code></a>,
                <a href="functions.html#function_to-days"><code class="literal">TO_DAYS()</code></a>, and
                <a href="functions.html#function_weekday"><code class="literal">WEEKDAY()</code></a> functions.
              </p></li><li><p>
                Use of <a href="functions.html#function_trim"><code class="literal">TRIM()</code></a> to trim
                substrings. Standard SQL supports removal of single
                characters only.
              </p></li><li><p>
                The <code class="literal">GROUP BY</code> functions
                <a href="functions.html#function_std"><code class="literal">STD()</code></a>,
                <a href="functions.html#function_bit-or"><code class="literal">BIT_OR()</code></a>,
                <a href="functions.html#function_bit-and"><code class="literal">BIT_AND()</code></a>,
                <a href="functions.html#function_bit-xor"><code class="literal">BIT_XOR()</code></a>, and
                <a href="functions.html#function_group-concat"><code class="literal">GROUP_CONCAT()</code></a>. See
                <a href="functions.html#group-by-functions-and-modifiers" title="11.11. Functions and Modifiers for Use with GROUP BY Clauses">Section 11.11, “Functions and Modifiers for Use with <code class="literal">GROUP BY</code> Clauses”</a>.
              </p></li></ul></div></li></ul></div><p>
        For a prioritized list indicating when new extensions are added
        to MySQL Server, you should consult the online MySQL development
        roadmap at <a href="http://dev.mysql.com/doc/mysql/en/roadmap.html" target="_top">http://dev.mysql.com/doc/mysql/en/roadmap.html</a>.
      </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="differences-from-ansi"></a>1.8.5. MySQL Differences from Standard SQL</h3></div></div></div><div class="toc"><dl><dt><span class="section"><a href="introduction.html#ansi-diff-select-into-table">1.8.5.1. <code class="literal">SELECT INTO TABLE</code></a></span></dt><dt><span class="section"><a href="introduction.html#ansi-diff-transactions">1.8.5.2. Transactions and Atomic Operations</a></span></dt><dt><span class="section"><a href="introduction.html#ansi-diff-triggers">1.8.5.3. Stored Routines and Triggers</a></span></dt><dt><span class="section"><a href="introduction.html#ansi-diff-foreign-keys">1.8.5.4. Foreign Keys</a></span></dt><dt><span class="section"><a href="introduction.html#ansi-diff-views">1.8.5.5. Views</a></span></dt><dt><span class="section"><a href="introduction.html#ansi-diff-comments">1.8.5.6. '<code class="literal">--</code>' as the Start of a Comment</a></span></dt></dl></div><a class="indexterm" name="id2490350"></a><p>
        We try to make MySQL Server follow the ANSI SQL standard and the
        ODBC SQL standard, but MySQL Server performs operations
        differently in some cases:
      </p><div class="itemizedlist"><ul type="disc"><li><p>
            For <code class="literal">VARCHAR</code> columns, trailing spaces are
            removed when the value is stored. (This is fixed in MySQL
            5.0.3). See <a href="error-handling.html#bugs" title="B.1.8. Known Issues in MySQL">Section B.1.8, “Known Issues in MySQL”</a>.
          </p></li><li><p>
            In some cases, <code class="literal">CHAR</code> columns are silently
            converted to <code class="literal">VARCHAR</code> columns when you
            define a table or alter its structure. (This no longer
            occurs as of MySQL 5.0.3). See
            <a href="sql-syntax.html#silent-column-changes" title="12.1.5.1. Silent Column Specification Changes">Section 12.1.5.1, “Silent Column Specification Changes”</a>.
          </p></li><li><p>
            There are several differences between the MySQL and standard
            SQL privilege systems. For example, in MySQL, privileges for
            a table are not automatically revoked when you delete a
            table. You must explicitly issue a <code class="literal">REVOKE</code>
            statement to revoke privileges for a table. For more
            information, see <a href="sql-syntax.html#revoke" title="12.5.1.5. REVOKE Syntax">Section 12.5.1.5, “<code class="literal">REVOKE</code> Syntax”</a>.
          </p></li><li><p>
            The <a href="functions.html#function_cast"><code class="literal">CAST()</code></a> function does not
            support cast to <code class="literal">REAL</code> or
            <code class="literal">BIGINT</code>. See
            <a href="functions.html#cast-functions" title="11.9. Cast Functions and Operators">Section 11.9, “Cast Functions and Operators”</a>.
          </p></li><li><p>
            Standard SQL requires that a <code class="literal">HAVING</code>
            clause in a <code class="literal">SELECT</code> statement be able to
            refer to columns in the <code class="literal">GROUP BY</code> clause.
            This cannot be done before MySQL 5.0.2.
          </p></li></ul></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="ansi-diff-select-into-table"></a>1.8.5.1. <code class="literal">SELECT INTO TABLE</code></h4></div></div></div><a class="indexterm" name="id2490512"></a><p>
          MySQL Server doesn't support the <code class="literal">SELECT ... INTO
          TABLE</code> Sybase SQL extension. Instead, MySQL Server
          supports the <code class="literal">INSERT INTO ... SELECT</code>
          standard SQL syntax, which is basically the same thing. See
          <a href="sql-syntax.html#insert-select" title="12.2.4.1. INSERT ... SELECT Syntax">Section 12.2.4.1, “<code class="literal">INSERT ... SELECT</code> Syntax”</a>. For example:
        </p><pre class="programlisting">INSERT INTO tbl_temp2 (fld_id)
    SELECT tbl_temp1.fld_order_id
    FROM tbl_temp1 WHERE tbl_temp1.fld_order_id &gt; 100;
</pre><p>
          Alternatively, you can use <code class="literal">SELECT ... INTO
          OUTFILE</code> or <code class="literal">CREATE TABLE ...
          SELECT</code>.
        </p><p>
          As of MySQL 5.0, you can use <code class="literal">SELECT ...
          INTO</code> with user-defined variables. The same syntax
          can also be used inside stored routines using cursors and
          local variables. See <a href="stored-procedures.html#select-into-statement" title="18.2.7.3. SELECT ... INTO Statement">Section 18.2.7.3, “<code class="literal">SELECT ... INTO</code> Statement”</a>.
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="ansi-diff-transactions"></a>1.8.5.2. Transactions and Atomic Operations</h4></div></div></div><a class="indexterm" name="id2490605"></a><a class="indexterm" name="id2490614"></a><a class="indexterm" name="id2490623"></a><a class="indexterm" name="id2490636"></a><a class="indexterm" name="id2490645"></a><a class="indexterm" name="id2490657"></a><a class="indexterm" name="id2490670"></a><a class="indexterm" name="id2490679"></a><a class="indexterm" name="id2490688"></a><p>
          MySQL Server (version 3.23-max and all versions 4.0 and above)
          supports transactions with the <code class="literal">InnoDB</code> and
          <code class="literal">BDB</code> transactional storage engines.
          <code class="literal">InnoDB</code> provides <span class="emphasis"><em>full</em></span>
          <code class="literal">ACID</code> compliance. See
          <a href="storage-engines.html" title="Chapter 13. Storage Engines">Chapter 13, <i>Storage Engines</i></a>. For information about
          <code class="literal">InnoDB</code> differences from standard SQL with
          regard to treatment of transaction errors, see
          <a href="storage-engines.html#innodb-error-handling" title="13.2.15. InnoDB Error Handling">Section 13.2.15, “<code class="literal">InnoDB</code> Error Handling”</a>.
        </p><p>
          The other non-transactional storage engines in MySQL Server
          (such as <code class="literal">MyISAM</code>) follow a different
          paradigm for data integrity called “<span class="quote">atomic
          operations.</span>” In transactional terms,
          <code class="literal">MyISAM</code> tables effectively always operate in
          <code class="literal">AUTOCOMMIT=1</code> mode. Atomic operations often
          offer comparable integrity with higher performance.
        </p><p>
          Because MySQL Server supports both paradigms, you can decide
          whether your applications are best served by the speed of
          atomic operations or the use of transactional features. This
          choice can be made on a per-table basis.
        </p><p class="mnmas"><b>MySQL Enterprise</b>
            For expert advice on choosing and tuning storage engines,
            subscribe to the MySQL Enterprise Monitor. For more
            information see
            <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>.
          </p><p>
          As noted, the trade-off for transactional versus
          non-transactional storage engines lies mostly in performance.
          Transactional tables have significantly higher memory and disk
          space requirements, and more CPU overhead. On the other hand,
          transactional storage engines such as
          <code class="literal">InnoDB</code> also offer many significant
          features. MySQL Server's modular design allows the concurrent
          use of different storage engines to suit different
          requirements and deliver optimum performance in all
          situations.
        </p><p>
          But how do you use the features of MySQL Server to maintain
          rigorous integrity even with the non-transactional
          <code class="literal">MyISAM</code> tables, and how do these features
          compare with the transactional storage engines?
        </p><div class="itemizedlist"><ul type="disc"><li><p>
              If your applications are written in a way that is
              dependent on being able to call
              <code class="literal">ROLLBACK</code> rather than
              <code class="literal">COMMIT</code> in critical situations,
              transactions are more convenient. Transactions also 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.
            </p><p>
              If you use non-transactional tables, MySQL Server in
              almost all cases allows you to resolve 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
              an inconsistency occurs. Note that just by using the MySQL
              log or even adding one extra log, you can normally fix
              tables perfectly with no data integrity loss.
            </p></li><li><p>
              More often than not, critical transactional updates can be
              rewritten to be atomic. Generally speaking, all integrity
              problems that transactions solve can be done with
              <code class="literal">LOCK TABLES</code> or atomic updates, ensuring
              that there are no automatic aborts from the server, which
              is a common problem with transactional database systems.
            </p></li><li><p>
              To be safe with MySQL Server, regardless of whether you
              use transactional tables, you only need to have backups
              and have binary logging turned on. When that is true, you
              can recover from any situation that you could with any
              other transactional database system. It is always good to
              have backups, regardless of which database system you use.
            </p></li></ul></div><p>
          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 necessary, or is necessary. However, even if you are new to
          the atomic operations paradigm, or more familiar with
          transactions, do consider the speed benefit that
          non-transactional tables can offer on the order of three to
          five times the speed of the fastest and most optimally tuned
          transactional tables.
        </p><p>
          In situations where integrity is of highest importance, MySQL
          Server offers transaction-level reliability and integrity even
          for non-transactional tables. If you lock tables with
          <code class="literal">LOCK TABLES</code>, all updates stall until
          integrity checks are made. If you obtain a <code class="literal">READ
          LOCAL</code> lock (as opposed to a write lock) for a table
          that allows concurrent inserts at the end of the table, reads
          are allowed, as are inserts by other clients. The newly
          inserted records are not be seen by the client that has the
          read lock until it releases the lock. With <code class="literal">INSERT
          DELAYED</code>, you can write inserts that go into a local
          queue until the locks are released, without having the client
          wait for the insert to complete. See
          <a href="optimization.html#concurrent-inserts" title="6.3.3. Concurrent Inserts">Section 6.3.3, “Concurrent Inserts”</a>, and
          <a href="sql-syntax.html#insert-delayed" title="12.2.4.2. INSERT DELAYED Syntax">Section 12.2.4.2, “<code class="literal">INSERT DELAYED</code> Syntax”</a>.
        </p><p>
          “<span class="quote">Atomic,</span>” 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 can never be an automatic rollback (which
          can happen with transactional tables if you are not very
          careful). MySQL Server also guarantees that there are no dirty
          reads.
        </p><p>
          Following are some techniques for working with
          non-transactional tables:
        </p><div class="itemizedlist"><ul type="disc"><li><p>
              Loops that need transactions normally can be coded with
              the help of <code class="literal">LOCK TABLES</code>, and you don't
              need cursors to update records on the fly.
            </p></li><li><p>
              To avoid using <code class="literal">ROLLBACK</code>, you can employ
              the following strategy:
            </p><div class="orderedlist"><ol type="1"><li><p>
                  Use <code class="literal">LOCK TABLES</code> to lock all the
                  tables you want to access.
                </p></li><li><p>
                  Test the conditions that must be true before
                  performing the update.
                </p></li><li><p>
                  Update if the conditions are satisfied.
                </p></li><li><p>
                  Use <code class="literal">UNLOCK TABLES</code> to release your
                  locks.
                </p></li></ol></div><p>
              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
              that case, all locks are released but some of the updates
              may not have been executed.
            </p></li><li><p>
              You can also use functions to update records in a single
              operation. You can get a very efficient application by
              using the following techniques:
            </p><div class="itemizedlist"><ul type="circle"><li><p>
                  Modify columns relative to their current value.
                </p></li><li><p>
                  Update only those columns that actually have changed.
                </p></li></ul></div><p>
              For example, when we are updating customer information, we
              update only the customer data that has changed and test
              only that none of the changed data, or data that depends
              on the changed data, has changed compared to the original
              row. The test for changed data is done with the
              <code class="literal">WHERE</code> clause in the
              <code class="literal">UPDATE</code> statement. If the record wasn't
              updated, we give the client a message: “<span class="quote">Some of the
              data you have changed has been changed by another
              user.</span>” Then we show the old row versus the new row
              in a window so that the user can decide which version of
              the customer record to use.
            </p><p>
              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
              <code class="literal">UPDATE</code> statements look something like
              these:
            </p><pre class="programlisting">UPDATE tablename SET pay_back=pay_back+125;

UPDATE customer
  SET
    customer_date='current_date',
    address='new address',
    phone='new phone',
    money_owed_to_us=money_owed_to_us-125
  WHERE
    customer_id=id AND address='old address' AND phone='old phone';
</pre><p>
              This is very efficient and works even if another client
              has changed the values in the <code class="literal">pay_back</code>
              or <code class="literal">money_owed_to_us</code> columns.
            </p></li><li><p>
              <a class="indexterm" name="id2491192"></a>

              <a class="indexterm" name="id2491201"></a>

              In many cases, users have wanted <code class="literal">LOCK
              TABLES</code> or <code class="literal">ROLLBACK</code> for the
              purpose of managing unique identifiers. This can be
              handled much more efficiently without locking or rolling
              back by using an <code class="literal">AUTO_INCREMENT</code> column
              and either the
              <a href="functions.html#function_last-insert-id"><code class="literal">LAST_INSERT_ID()</code></a> SQL
              function or the
              <a href="apis.html#mysql-insert-id" title="23.2.3.37. mysql_insert_id()"><code class="literal">mysql_insert_id()</code></a> C API
              function. See <a href="functions.html#information-functions" title="11.10.3. Information Functions">Section 11.10.3, “Information Functions”</a>, and
              <a href="apis.html#mysql-insert-id" title="23.2.3.37. mysql_insert_id()">Section 23.2.3.37, “<code class="literal">mysql_insert_id()</code>”</a>.
            </p><a class="indexterm" name="id2491260"></a><a class="indexterm" name="id2491272"></a><p>
              You can generally code around the need for row-level
              locking. Some situations really do need it, and
              <code class="literal">InnoDB</code> tables support row-level
              locking. Otherwise, with <code class="literal">MyISAM</code> tables,
              you can use a flag column in the table and do something
              like the following:
            </p><pre class="programlisting">UPDATE <em class="replaceable"><code>tbl_name</code></em> SET row_flag=1 WHERE id=ID;
</pre><p>
              MySQL returns <code class="literal">1</code> for the number of
              affected rows if the row was found and
              <code class="literal">row_flag</code> wasn't <code class="literal">1</code> in
              the original row. You can think of this as though MySQL
              Server changed the preceding statement to:
            </p><pre class="programlisting">UPDATE <em class="replaceable"><code>tbl_name</code></em> SET row_flag=1 WHERE id=ID AND row_flag &lt;&gt; 1;
</pre></li></ul></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="ansi-diff-triggers"></a>1.8.5.3. Stored Routines and Triggers</h4></div></div></div><a class="indexterm" name="id2491363"></a><a class="indexterm" name="id2491376"></a><a class="indexterm" name="id2491388"></a><p>
          Stored procedures and functions are implemented beginning with
          MySQL 5.0. See <a href="stored-procedures.html" title="Chapter 18. Stored Procedures and Functions">Chapter 18, <i>Stored Procedures and Functions</i></a>.
        </p><p>
          Basic trigger functionality is implemented beginning with
          MySQL 5.0.2, with further development planned for MySQL 5.1.
          See <a href="triggers.html" title="Chapter 19. Triggers">Chapter 19, <i>Triggers</i></a>.
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="ansi-diff-foreign-keys"></a>1.8.5.4. Foreign Keys</h4></div></div></div><a class="indexterm" name="id2491427"></a><a class="indexterm" name="id2491436"></a><p>
          In MySQL Server 3.23.44 and up, the <code class="literal">InnoDB</code>
          storage engine supports checking of foreign key constraints,
          including <code class="literal">CASCADE</code>, <code class="literal">ON
          DELETE</code>, and <code class="literal">ON UPDATE</code>. See
          <a href="storage-engines.html#innodb-foreign-key-constraints" title="13.2.6.4. FOREIGN KEY Constraints">Section 13.2.6.4, “<code class="literal">FOREIGN KEY</code> Constraints”</a>.
        </p><p>
          For storage engines other than <code class="literal">InnoDB</code>,
          MySQL Server parses the <code class="literal">FOREIGN KEY</code> syntax
          in <code class="literal">CREATE TABLE</code> statements, but does not
          use or store it. In the future, the implementation will be
          extended to store this information in the table specification
          file so that it may be retrieved by
          <span><strong class="command">mysqldump</strong></span> and ODBC. At a later stage,
          foreign key constraints will be implemented for
          <code class="literal">MyISAM</code> tables as well.
        </p><p>
          Foreign key enforcement offers several benefits to database
          developers:
        </p><div class="itemizedlist"><ul type="disc"><li><p>
              Assuming proper design of the relationships, foreign key
              constraints make it more difficult for a programmer to
              introduce an inconsistency into the database.
            </p></li><li><p>
              Centralized checking of constraints by the database server
              makes it unnecessary to perform these checks on the
              application side. This eliminates the possibility that
              different applications may not all check the constraints
              in the same way.
            </p></li><li><p>
              Using cascading updates and deletes can simplify the
              application code.
            </p></li><li><p>
              Properly designed foreign key rules aid in documenting
              relationships between tables.
            </p></li></ul></div><p>
          Do keep in mind that these benefits come at the cost of
          additional overhead for the database server to perform the
          necessary checks. Additional checking by the server affects
          performance, which for some applications may be sufficiently
          undesirable as to be avoided if possible. (Some major
          commercial applications have coded the foreign key logic at
          the application level for this reason.)
        </p><p>
          MySQL gives database developers the choice of which approach
          to use. If you don't need foreign keys and want to avoid the
          overhead associated with enforcing referential integrity, you
          can choose another storage engine instead, such as
          <code class="literal">MyISAM</code>. (For example, the
          <code class="literal">MyISAM</code> storage engine offers very fast
          performance for applications that perform only
          <code class="literal">INSERT</code> and <code class="literal">SELECT</code>
          operations. In this case, the table has no holes in the middle
          and the inserts can be performed concurrently with retrievals.
          See <a href="optimization.html#concurrent-inserts" title="6.3.3. Concurrent Inserts">Section 6.3.3, “Concurrent Inserts”</a>.)
        </p><p>
          If you choose not to take advantage of referential integrity
          checks, keep the following considerations in mind:
        </p><div class="itemizedlist"><ul type="disc"><li><p>
              In the absence of server-side foreign key relationship
              checking, the application itself must handle relationship
              issues. For example, it must take care to insert rows into
              tables in the proper order, and to avoid creating orphaned
              child records. It must also be able to recover from errors
              that occur in the middle of multiple-record insert
              operations.
            </p></li><li><p>
              If <code class="literal">ON DELETE</code> is the only referential
              integrity capability an application needs, you can achieve
              a similar effect as of MySQL Server 4.0 by using
              multiple-table <code class="literal">DELETE</code> statements to
              delete rows from many tables with a single statement. See
              <a href="sql-syntax.html#delete" title="12.2.1. DELETE Syntax">Section 12.2.1, “<code class="literal">DELETE</code> Syntax”</a>.
            </p></li><li><p>
              A workaround for the lack of <code class="literal">ON DELETE</code>
              is to add the appropriate <code class="literal">DELETE</code>
              statements to your application when you delete records
              from a table that has a foreign key. In practice, this is
              often as quick as using foreign keys and is more portable.
            </p></li></ul></div><p>
          Be aware that the use of foreign keys can sometimes lead to
          problems:
        </p><div class="itemizedlist"><ul type="disc"><li><p>
              Foreign key support addresses many referential integrity
              issues, but it is still necessary to design key
              relationships carefully to avoid circular rules or
              incorrect combinations of cascading deletes.
            </p></li><li><p>
              It is not uncommon for a DBA to create a topology of
              relationships that makes it difficult to restore
              individual tables from a backup. (MySQL alleviates this
              difficulty by allowing you to temporarily disable foreign
              key checks when reloading a table that depends on other
              tables. See
              <a href="storage-engines.html#innodb-foreign-key-constraints" title="13.2.6.4. FOREIGN KEY Constraints">Section 13.2.6.4, “<code class="literal">FOREIGN KEY</code> Constraints”</a>. As of
              MySQL 4.1.1, <span><strong class="command">mysqldump</strong></span> generates dump
              files that take advantage of this capability automatically
              when they are reloaded.)
            </p></li></ul></div><p>
          Note that foreign keys in SQL are used to check and enforce
          referential integrity, not to join tables. If you want to get
          results from multiple tables from a <code class="literal">SELECT</code>
          statement, you do this by performing a join between them:
        </p><pre class="programlisting">SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id;
</pre><p>
          See <a href="sql-syntax.html#join" title="12.2.7.1. JOIN Syntax">Section 12.2.7.1, “<code class="literal">JOIN</code> Syntax”</a>, and
          <a href="tutorial.html#example-foreign-keys" title="3.6.6. Using Foreign Keys">Section 3.6.6, “Using Foreign Keys”</a>.
        </p><p>
          The <code class="literal">FOREIGN KEY</code> syntax without <code class="literal">ON
          DELETE ...</code> is often used by ODBC applications to
          produce automatic <code class="literal">WHERE</code> clauses.
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="ansi-diff-views"></a>1.8.5.5. Views</h4></div></div></div><a class="indexterm" name="id2491810"></a><a class="indexterm" name="id2491819"></a><p>
          Views (including updatable views) are implemented beginning
          with MySQL Server 5.0.1. See <a href="views.html" title="Chapter 20. Views">Chapter 20, <i>Views</i></a>.
        </p><p>
          Views are useful for allowing users to access a set of
          relations (tables) as if it were a single table, and limiting
          their access to just that. Views can also be used to restrict
          access to rows (a subset of a particular table). For access
          control to columns, you can also use the sophisticated
          privilege system in MySQL Server. See
          <a href="server-administration.html#privilege-system" title="5.7. The MySQL Access Privilege System">Section 5.7, “The MySQL Access Privilege System”</a>.
        </p><p>
          In designing an implementation of views, our ambitious goal,
          as much as is possible within the confines of SQL, has been
          full compliance with “<span class="quote">Codd's Rule #6</span>” for
          relational database systems: “<span class="quote">All views that are
          theoretically updatable, should in practice also be
          updatable.</span>”
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="ansi-diff-comments"></a>1.8.5.6. '<code class="literal">--</code>' as the Start of a Comment</h4></div></div></div><a class="indexterm" name="id2491887"></a><a class="indexterm" name="id2491899"></a><p>
          Standard SQL uses the C syntax <code class="literal">/* this is a comment
          */</code> for comments, and MySQL Server supports this
          syntax as well. MySQL also support extensions to this syntax
          that allow MySQL-specific SQL to be embedded in the comment,
          as described in <a href="language-structure.html#comments" title="8.5. Comment Syntax">Section 8.5, “Comment Syntax”</a>.
        </p><p>
          Standard SQL uses “<span class="quote"><code class="option">--</code></span>” as a
          start-comment sequence. MySQL Server uses
          “<span class="quote"><code class="literal">#</code></span>” as the start comment
          character. MySQL Server 3.23.3 and up also supports a variant
          of the “<span class="quote"><code class="literal">--</code></span>” comment style.
          That is, the “<span class="quote"><code class="literal">--</code></span>”
          start-comment sequence must be followed by a space (or by a
          control character such as a newline). The space is required to
          prevent problems with automatically generated SQL queries that
          use constructs such as the following, where we automatically
          insert the value of the payment for
          <code class="literal">payment</code>:
        </p><pre class="programlisting">UPDATE account SET credit=credit-payment
</pre><p>
          Consider about what happens if <code class="literal">payment</code> has
          a negative value such as <code class="literal">-1</code>:
        </p><pre class="programlisting">UPDATE account SET credit=credit--1
</pre><p>
          <code class="literal">credit--1</code> is a legal expression in SQL, but
          “<span class="quote"><code class="literal">--</code></span>” is interpreted as the
          start of a comment, part of the expression is discarded. The
          result is a statement that has a completely different meaning
          than intended:
        </p><pre class="programlisting">UPDATE account SET credit=credit
</pre><p>
          The statement produces no change in value at all. This
          illustrates that allowing comments to start with
          “<span class="quote"><code class="literal">--</code></span>” can have serious
          consequences.
        </p><p>
          Using our implementation requires a space following the
          “<span class="quote"><code class="literal">--</code></span>” in order for it to be
          recognized as a start-comment sequence in MySQL Server 3.23.3
          and newer. Therefore, <code class="literal">credit--1</code> is safe to
          use.
        </p><p>
          Another safe feature is that the <span><strong class="command">mysql</strong></span>
          command-line client ignores lines that start with
          “<span class="quote"><code class="literal">--</code></span>”.
        </p><p>
          The following information is relevant only if you are running
          a MySQL version earlier than 3.23.3:
        </p><p>
          If you have an SQL script in a text file that contains
          “<span class="quote"><code class="literal">--</code></span>” comments, you should use
          the <span><strong class="command">replace</strong></span> utility as follows to convert
          the comments to use “<span class="quote"><code class="literal">#</code></span>”
          characters before executing the script:
        </p><pre class="programlisting">shell&gt; <strong class="userinput"><code>replace " --" " #" &lt; text-file-with-funny-comments.sql \</code></strong>
         <strong class="userinput"><code>| mysql <em class="replaceable"><code>db_name</code></em></code></strong>
</pre><p>
          That is safer than executing the script in the usual way:
        </p><pre class="programlisting">shell&gt; <strong class="userinput"><code>mysql <em class="replaceable"><code>db_name</code></em> &lt; text-file-with-funny-comments.sql</code></strong>
</pre><p>
          You can also edit the script file “<span class="quote">in place</span>” to
          change the “<span class="quote"><code class="literal">--</code></span>” comments to
          “<span class="quote"><code class="literal">#</code></span>” comments:
        </p><pre class="programlisting">shell&gt; <strong class="userinput"><code>replace " --" " #" -- text-file-with-funny-comments.sql</code></strong>
</pre><p>
          Change them back with this command:
        </p><pre class="programlisting">shell&gt; <strong class="userinput"><code>replace " #" " --" -- text-file-with-funny-comments.sql</code></strong>
</pre><p>
          See <a href="client-utility-programs.html#replace-utility" title="7.27. replace — A String-Replacement Utility">Section 7.27, “<span><strong class="command">replace</strong></span> — A String-Replacement Utility”</a>.
        </p></div></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="constraints"></a>1.8.6. How MySQL Deals with Constraints</h3></div></div></div><div class="toc"><dl><dt><span class="section"><a href="introduction.html#constraint-primary-key">1.8.6.1. <code class="literal">PRIMARY KEY</code> and <code class="literal">UNIQUE</code> Index
          Constraints</a></span></dt><dt><span class="section"><a href="introduction.html#constraint-invalid-data">1.8.6.2. Constraints on Invalid Data</a></span></dt><dt><span class="section"><a href="introduction.html#constraint-enum">1.8.6.3. <code class="literal">ENUM</code> and <code class="literal">SET</code> Constraints</a></span></dt></dl></div><a class="indexterm" name="id2492293"></a><p>
        MySQL allows you to work both with transactional tables that
        allow rollback and with non-transactional tables that do not.
        Because of this, constraint handling is a bit different in MySQL
        than in other DBMSs. We must handle the case when you have
        inserted or updated a lot of rows in a non-transactional table
        for which changes cannot be rolled back when an error occurs.
      </p><p>
        The basic philosophy is that MySQL Server tries to produce an
        error for anything that it can detect while parsing a statement
        to be executed, and tries to recover from any errors that occur
        while executing the statement. We do this in most cases, but not
        yet for all.
      </p><p>
        The options MySQL has when an error occurs are to stop the
        statement in the middle or to recover as well as possible from
        the problem and continue. By default, the server follows the
        latter course. This means, for example, that the server may
        coerce illegal values to the closest legal values.
      </p><p>
        Beginning with MySQL 5.0.2, several SQL mode options are
        available to provide greater control over handling of bad data
        values and whether to continue statement execution or abort when
        errors occur. Using these options, you can configure MySQL
        Server to act in a more traditional fashion that is like other
        DBMSs that reject improper input. The SQL mode can be set
        globally at server startup to affect all clients. Individual
        clients can set the SQL mode at runtime, which enables each
        client to select the behavior most appropriate for its
        requirements. See <a href="server-administration.html#server-sql-mode" title="5.2.6. SQL Modes">Section 5.2.6, “SQL Modes”</a>.
      </p><p class="mnmas"><b>MySQL Enterprise</b>
          To be alerted when there is no form of server-enforced data
          integrity, subscribe to the MySQL Enterprise Monitor. For more
          information see
          <a href="http://www.mysql.com/products/enterprise/advisors.html" target="_top">http://www.mysql.com/products/enterprise/advisors.html</a>.
        </p><p>
        The following sections describe how MySQL Server handles
        different types of constraints.
      </p><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="constraint-primary-key"></a>1.8.6.1. <code class="literal">PRIMARY KEY</code> and <code class="literal">UNIQUE</code> Index
          Constraints</h4></div></div></div><a class="indexterm" name="id2492394"></a><a class="indexterm" name="id2492406"></a><a class="indexterm" name="id2492419"></a><p>
          Normally, an error occurs when you try to
          <code class="literal">INSERT</code> or <code class="literal">UPDATE</code> a row
          that causes a primary key, unique key, or foreign key
          violation. If you are using a transactional storage engine
          such as <code class="literal">InnoDB</code>, MySQL automatically rolls
          back the statement. If you are using a non-transactional
          storage engine, MySQL stops processing the statement at the
          row for which the error occurred and leaves any remaining rows
          unprocessed.
        </p><p>
          If you want to ignore such key violations, MySQL supports an
          <code class="literal">IGNORE</code> keyword for
          <code class="literal">INSERT</code> and <code class="literal">UPDATE</code>. In
          this case, MySQL ignores any key violations and continues
          processing with the next row. See <a href="sql-syntax.html#insert" title="12.2.4. INSERT Syntax">Section 12.2.4, “<code class="literal">INSERT</code> Syntax”</a>,
          and <a href="sql-syntax.html#update" title="12.2.10. UPDATE Syntax">Section 12.2.10, “<code class="literal">UPDATE</code> Syntax”</a>.
        </p><p>
          You can get information about the number of rows actually
          inserted or updated with the
          <a href="apis.html#mysql-info" title="23.2.3.35. mysql_info()"><code class="literal">mysql_info()</code></a> C API function.
          You can also use the <code class="literal">SHOW WARNINGS</code>
          statement. See <a href="apis.html#mysql-info" title="23.2.3.35. mysql_info()">Section 23.2.3.35, “<code class="literal">mysql_info()</code>”</a>, and
          <a href="sql-syntax.html#show-warnings" title="12.5.4.28. SHOW WARNINGS Syntax">Section 12.5.4.28, “<code class="literal">SHOW WARNINGS</code> Syntax”</a>.
        </p><p>
          Currently, only <code class="literal">InnoDB</code> tables support
          foreign keys. See
          <a href="storage-engines.html#innodb-foreign-key-constraints" title="13.2.6.4. FOREIGN KEY Constraints">Section 13.2.6.4, “<code class="literal">FOREIGN KEY</code> Constraints”</a>. We plan to
          add foreign key support by other storage engines in a future
          MySQL release. See <a href="introduction.html#roadmap" title="1.5. MySQL Development Roadmap">Section 1.5, “MySQL Development Roadmap”</a>.
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="constraint-invalid-data"></a>1.8.6.2. Constraints on Invalid Data</h4></div></div></div><a class="indexterm" name="id2492555"></a><a class="indexterm" name="id2492568"></a><a class="indexterm" name="id2492580"></a><a class="indexterm" name="id2492593"></a><a class="indexterm" name="id2492605"></a><p>
          Before MySQL 5.0.2, MySQL is forgiving of illegal or improper
          data values and coerces them to legal values for data entry.
          In MySQL 5.0.2 and up, that remains the default behavior, but
          you can change the server SQL mode to select more traditional
          treatment of bad values such that the server rejects them and
          aborts the statement in which they occur.
          <a href="server-administration.html#server-sql-mode" title="5.2.6. SQL Modes">Section 5.2.6, “SQL Modes”</a>.
        </p><p>
          This section describes the default (forgiving) behavior of
          MySQL, as well as the strict SQL mode and how it differs.
        </p><p>
          If you are not using strict mode, then whenever you insert an
          “<span class="quote">incorrect</span>” value into a column, such as a
          <code class="literal">NULL</code> into a <code class="literal">NOT NULL</code>
          column or a too-large numeric value into a numeric column,
          MySQL sets the column to the “<span class="quote">best possible
          value</span>” instead of producing an error: The following
          rules describe in more detail how this works:
        </p><div class="itemizedlist"><ul type="disc"><li><p>
              If you try to store an out of range value into a numeric
              column, MySQL Server instead stores zero, the smallest
              possible value, or the largest possible value, whichever
              is closest to the invalid value.
            </p></li><li><p>
              For strings, MySQL stores either the empty string or as
              much of the string as can be stored in the column.
            </p></li><li><p>
              If you try to store a string that doesn't start with a
              number into a numeric column, MySQL Server stores 0.
            </p></li><li><p>
              Invalid values for <code class="literal">ENUM</code> and
              <code class="literal">SET</code> columns are handled as described in
              <a href="introduction.html#constraint-enum" title="1.8.6.3. ENUM and SET Constraints">Section 1.8.6.3, “<code class="literal">ENUM</code> and <code class="literal">SET</code> Constraints”</a>.
            </p></li><li><p>
              MySQL allows you to store certain incorrect date values
              into <code class="literal">DATE</code> and
              <code class="literal">DATETIME</code> columns (such as
              <code class="literal">'2000-02-31'</code> or
              <code class="literal">'2000-02-00'</code>). The idea is that it's
              not the job of the SQL server to validate dates. If MySQL
              can store a date value and retrieve exactly the same
              value, MySQL stores it as given. If the date is totally
              wrong (outside the server's ability to store it), the
              special “<span class="quote">zero</span>” date value
              <code class="literal">'0000-00-00'</code> is stored in the column
              instead.
            </p></li><li><p>
              If you try to store <code class="literal">NULL</code> into a column
              that doesn't take <code class="literal">NULL</code> values, an error
              occurs for single-row <code class="literal">INSERT</code>
              statements. For multiple-row <code class="literal">INSERT</code>
              statements or for <code class="literal">INSERT INTO ...
              SELECT</code> statements, MySQL Server stores the
              implicit default value for the column data type. In
              general, this is <code class="literal">0</code> for numeric types,
              the empty string (<code class="literal">''</code>) for string types,
              and the “<span class="quote">zero</span>” value for date and time types.
              Implicit default values are discussed in
              <a href="data-types.html#data-type-defaults" title="10.1.4. Data Type Default Values">Section 10.1.4, “Data Type Default Values”</a>.
            </p></li><li><p>
              If an <code class="literal">INSERT</code> statement specifies no
              value for a column, MySQL inserts its default value if the
              column definition includes an explicit
              <code class="literal">DEFAULT</code> clause. If the definition has
              no such <code class="literal">DEFAULT</code> clause, MySQL inserts
              the implicit default value for the column data type.
            </p></li></ul></div><p>
          The reason for using the preceding rules in non-strict mode is
          that we can't check these conditions until the statement has
          begun executing. We can't just roll back if we encounter a
          problem after updating a few rows, because the storage engine
          may not support rollback. The option of terminating the
          statement is not that good; in this case, the update would be
          “<span class="quote">half done,</span>” which is probably the worst possible
          scenario. In this case, it's better to “<span class="quote">do the best you
          can</span>” and then continue as if nothing happened.
        </p><p>
          In MySQL 5.0.2 and up, you can select stricter treatment of
          input values by using the
          <code class="literal">STRICT_TRANS_TABLES</code> or
          <code class="literal">STRICT_ALL_TABLES</code> SQL modes:
        </p><pre class="programlisting">SET sql_mode = 'STRICT_TRANS_TABLES';
SET sql_mode = 'STRICT_ALL_TABLES';
</pre><p>
          <code class="literal">STRICT_TRANS_TABLES</code> enables strict mode for
          transactional storage engines, and also to some extent for
          non-transactional engines. It works like this:
        </p><div class="itemizedlist"><ul type="disc"><li><p>
              For transactional storage engines, bad data values
              occurring anywhere in a statement cause the statement to
              abort and roll back.
            </p></li><li><p>
              For non-transactional storage engines, a statement aborts
              if the error occurs in the first row to be inserted or
              updated. (When the error occurs in the first row, the
              statement can be aborted to leave the table unchanged,
              just as for a transactional table.) Errors in rows after
              the first do not abort the statement, because the table
              has already been changed by the first row. Instead, bad
              data values are adjusted and result in warnings rather
              than errors. In other words, with
              <code class="literal">STRICT_TRANS_TABLES</code>, a wrong value
              causes MySQL to roll back all updates done so far, if that
              can be done without changing the table. But once the table
              has been changed, further errors result in adjustments and
              warnings.
            </p></li></ul></div><p>
          For even stricter checking, enable
          <code class="literal">STRICT_ALL_TABLES</code>. This is the same as
          <code class="literal">STRICT_TRANS_TABLES</code> except that for
          non-transactional storage engines, errors abort the statement
          even for bad data in rows following the first row. This means
          that if an error occurs partway through a multiple-row insert
          or update for a non-transactional table, a partial update
          results. Earlier rows are inserted or updated, but those from
          the point of the error on are not. To avoid this for
          non-transactional tables, either use single-row statements or
          else use <code class="literal">STRICT_TRANS_TABLES</code> if conversion
          warnings rather than errors are acceptable. To avoid problems
          in the first place, do not use MySQL to check column content.
          It is safest (and often faster) to let the application ensure
          that it passes only legal values to the database.
        </p><p>
          With either of the strict mode options, you can cause errors
          to be treated as warnings by using <code class="literal">INSERT
          IGNORE</code> or <code class="literal">UPDATE IGNORE</code> rather
          than <code class="literal">INSERT</code> or <code class="literal">UPDATE</code>
          without <code class="literal">IGNORE</code>.
        </p></div><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="constraint-enum"></a>1.8.6.3. <code class="literal">ENUM</code> and <code class="literal">SET</code> Constraints</h4></div></div></div><p>
          <code class="literal">ENUM</code> and <code class="literal">SET</code> columns
          provide an efficient way to define columns that can contain
          only a given set of values. See <a href="data-types.html#enum" title="10.4.4. The ENUM Type">Section 10.4.4, “The <code class="literal">ENUM</code> Type”</a>, and
          <a href="data-types.html#set" title="10.4.5. The SET Type">Section 10.4.5, “The <code class="literal">SET</code> Type”</a>. However, before MySQL 5.0.2,
          <code class="literal">ENUM</code> and <code class="literal">SET</code> columns do
          not provide true constraints on entry of invalid data:
        </p><div class="itemizedlist"><ul type="disc"><li><p>
              <code class="literal">ENUM</code> columns always have a default
              value. If you specify no default value, then it is
              <code class="literal">NULL</code> for columns that can have
              <code class="literal">NULL</code>, otherwise it is the first
              enumeration value in the column definition.
            </p></li><li><p>
              If you insert an incorrect value into an
              <code class="literal">ENUM</code> column or if you force a value
              into an <code class="literal">ENUM</code> column with
              <code class="literal">IGNORE</code>, it is set to the reserved
              enumeration value of <code class="literal">0</code>, which is
              displayed as an empty string in string context.
            </p></li><li><p>
              If you insert an incorrect value into a
              <code class="literal">SET</code> column, the incorrect value is
              ignored. For example, if the column can contain the values
              <code class="literal">'a'</code>, <code class="literal">'b'</code>, and
              <code class="literal">'c'</code>, an attempt to assign
              <code class="literal">'a,x,b,y'</code> results in a value of
              <code class="literal">'a,b'</code>.
            </p></li></ul></div><p>
          As of MySQL 5.0.2, you can configure the server to use strict
          SQL mode. See <a href="server-administration.html#server-sql-mode" title="5.2.6. SQL Modes">Section 5.2.6, “SQL Modes”</a>. With strict
          mode enabled, the definition of a <code class="literal">ENUM</code> or
          <code class="literal">SET</code> column does act as a constraint on
          values entered into the column. An error occurs for values
          that do not satisfy these conditions:
        </p><div class="itemizedlist"><ul type="disc"><li><p>
              An <code class="literal">ENUM</code> value must be one of those
              listed in the column definition, or the internal numeric
              equivalent thereof. The value cannot be the error value
              (that is, 0 or the empty string). For a column defined as
              <code class="literal">ENUM('a','b','c')</code>, values such as
              <code class="literal">''</code>, <code class="literal">'d'</code>, or
              <code class="literal">'ax'</code> are illegal and are rejected.
            </p></li><li><p>
              A <code class="literal">SET</code> value must be the empty string or
              a value consisting only of the values listed in the column
              definition separated by commas. For a column defined as
              <code class="literal">SET('a','b','c')</code>, values such as
              <code class="literal">'d'</code> or <code class="literal">'a,b,c,d'</code> are
              illegal and are rejected.
            </p></li></ul></div><p>
          Errors for invalid values can be suppressed in strict mode if
          you use <code class="literal">INSERT IGNORE</code> or <code class="literal">UPDATE
          IGNORE</code>. In this case, a warning is generated rather
          than an error. For <code class="literal">ENUM</code>, the value is
          inserted as the error member (<code class="literal">0</code>). For
          <code class="literal">SET</code>, the value is inserted as given except
          that any invalid substrings are deleted. For example,
          <code class="literal">'a,x,b,y'</code> results in a value of
          <code class="literal">'a,b'</code>.
        </p></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="preface.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="installing.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Preface </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 2. Installing and Upgrading MySQL</td></tr></table></div></body></html>