![]() |
|
|
#1 |
|
Administrator
Join Date: Jun 2004
Posts: 383
|
1.8 MySQL Standards Compliance
From http://dev.mysql.com/doc/mysql/en/Compatibility.html
1.8 MySQL Standards Compliance This section describes how MySQL relates to the ANSI/ISO SQL standards. MySQL Server has many extensions to the SQL standard, and here you will find out what they are and how to use them. You will also find information about functionality missing from MySQL Server, and how to work around some differences. The SQL standard has been evolving since 1986 and several versions exist. In this manual, ``SQL-92'' refers to the standard released in 1992, ``SQL:1999'' refers to the standard released in 1999, and ``SQL:2003'' refers to the current version of the standard. We use the phrase ``the SQL standard'' to mean the current version of the SQL Standard at any time. Our goal is to not restrict MySQL Server usability for any usage without a very good reason for doing so. Even if we don't have the resources to perform development for every possible use, we are always willing to help and offer suggestions to people who are trying to use MySQL Server in new territories. 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 HANDLER interface in MySQL Server 4.0 is an example of this strategy. See section 14.1.3 HANDLER Syntax. We will continue to support transactional and non-transactional databases to satisfy both mission-critical 24/7 usage and heavy Web or logging usage. MySQL Server was originally designed to work with medium size databases (10-100 million rows, or about 100MB per table) on small computer systems. Today MySQL Server handles terabyte-size 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. Currently, we are not targeting realtime support, although MySQL replication capabilities already offer significant functionality. Database cluster support is planned through integration of our acquired NDB Cluster technology into a new storage engine, available early 2004. We are also looking at providing XML support in the database server. DISCUSS: |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Jun 2004
Posts: 383
|
1.8.1 What Standards MySQL Follows
From http://dev.mysql.com/doc/mysql/en/Standards.html
1.8.1 What Standards MySQL Follows We are aiming toward supporting the full ANSI/ISO SQL standard, but without making concessions to speed and quality of the code. ODBC levels 0-3.51. |
|
|
|
|
|
#3 |
|
Administrator
Join Date: Jun 2004
Posts: 383
|
1.8.2 Selecting SQL Modes
From http://dev.mysql.com/doc/mysql/en/SQL_mode.html
1.8.2 Selecting SQL Modes The MySQL server can operate in different SQL modes, and can apply these modes differentially for different clients. This allows applications to tailor server operation to their own requirements. Modes define what SQL syntax MySQL should support and what kind of validation checks it should perform on the data. This makes it easier to use MySQL in a lot of different environments and to use MySQL together with other database servers. You can set the default SQL mode by starting mysqld with the --sql-mode="modes" option. Beginning with MySQL 4.1, you can also change the mode after startup time by setting the sql_mode variable with a SET [SESSION|GLOBAL] sql_mode='modes' statement. For more information on setting the server mode, see section 5.2.2 The Server SQL Mode. |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Jun 2004
Posts: 383
|
1.8.3 Running MySQL in ANSI Mode
From http://dev.mysql.com/doc/mysql/en/ANSI_mode.html
1.8.3 Running MySQL in ANSI Mode You can tell mysqld to use the ANSI mode with the --ansi startup option. See section 5.2.1 mysqld Command-Line Options. Running the server in ANSI mode is the same as starting it with these options (specify the --sql_mode value on a single line): --transaction-isolation=SERIALIZABLE--sql-mode=REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGN ORE_SPACE,ONLY_FULL_GROUP_BYIn MySQL 4.1, you can achieve the same effect with these two statements (specify the sql_mode value on a single line): SET GLOBAL TRANSACTION ISOLATION LEVEL SERIALIZABLE;SET GLOBAL sql_mode = 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_ SPACE,ONLY_FULL_GROUP_BY';See section 1.8.2 Selecting SQL Modes. In MySQL 4.1.1, the sql_mode options shown can be also be set with this statement: SET GLOBAL sql_mode='ansi';In this case, the value of the sql_mode variable will be set to all options that are relevant for ANSI mode. You can check the result like this: mysql> SET GLOBAL sql_mode='ansi';mysql> SELECT @@global.sql_mode; |
|
|
|
|
|
#5 |
|
Administrator
Join Date: Jun 2004
Posts: 383
|
1.8.4 MySQL Extensions to Standard SQL
From http://dev.mysql.com/doc/mysql/en/Ex...s_to_ANSI.html
1.8.4 MySQL Extensions to Standard SQL MySQL Server includes some extensions that you probably will not find in other SQL databases. Be warned that if you use them, your code will not be portable to other SQL servers. In some cases, you can write code that includes MySQL extensions, but is still portable, by using comments of the form /*! ... */. In this case, MySQL Server will parse and execute the code within the comment as it would any other MySQL statement, but other SQL servers will ignore the extensions. For example: SELECT /*! STRAIGHT_JOIN */ col_name FROM table1,table2 WHERE ...If you add a version number after the `!' character, the syntax within the comment will be executed only if the MySQL version is equal to or newer than the specified version number: CREATE /*!32302 TEMPORARY */ TABLE t (a INT);This means that if you have Version 3.23.02 or newer, MySQL Server will use the TEMPORARY keyword. The following descriptions list MySQL extensions, organized by category. Organization of data on disk MySQL Server maps each database to a directory under the MySQL data directory, and tables within a database to filenames in the database directory. This has a few implications:
|
|
|
|
|
|
#6 |
|
Administrator
Join Date: Jun 2004
Posts: 383
|
1.8.5 MySQL Differences from Standard SQL
From http://dev.mysql.com/doc/mysql/en/Di...from_ANSI.html
1.8.5 MySQL Differences from Standard SQL 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:
|
|
|
|
|
|
#7 |
|
Administrator
Join Date: Jun 2004
Posts: 383
|
1.8.5.1 Subqueries
From http://dev.mysql.com/doc/mysql/en/AN...ubqueries.html
1.8.5.1 Subqueries MySQL 4.1 supports subqueries and derived tables. A ``subquery'' is a SELECT statement nested within another statement. A ``derived table'' (an unnamed view) is a subquery in the FROM clause of another statement. See section 14.1.8 Subquery Syntax. For MySQL versions older than 4.1, most subqueries can be rewritten using joins or other methods. See section 14.1.8.11 Rewriting Subqueries as Joins for Earlier MySQL Versions for examples that show how to do this. |
|
|
|
|
|
#8 |
|
Administrator
Join Date: Jun 2004
Posts: 383
|
1.8.5.2 Select Into Table
From http://dev.mysql.com/doc/mysql/en/AN...NTO_TABLE.html
1.8.5.2 SELECT INTO TABLE MySQL Server doesn't support the Sybase SQL extension: SELECT ... INTO TABLE .... Instead, MySQL Server supports the standard SQL syntax INSERT INTO ... SELECT ..., which is basically the same thing. See section 14.1.4.1 INSERT ... SELECT Syntax. INSERT INTO tbl_temp2 (fld_id) SELECT tbl_temp1.fld_order_id FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;Alternatively, you can use SELECT INTO OUTFILE ... or CREATE TABLE ... SELECT. From version 5.0, MySQL supports SELECT ... INTO with user variables. The same syntax may also be used inside stored procedures using cursors and local variables. See section 20.1.6.3 SELECT ... INTO Statement. Last edited by Administrator : 06-08-2004 at 03:11 AM. |
|
|
|
|
|
#9 |
|
Administrator
Join Date: Jun 2004
Posts: 383
|
1.8.5.3 Transactions and Atomic Operations
From http://dev.mysql.com/doc/mysql/en/AN...nsactions.html
1.8.5.3 Transactions and Atomic Operations MySQL Server (version 3.23-max and all versions 4.0 and above) supports transactions with the InnoDB and BDB transactional storage engines. InnoDB provides full ACID compliance. See section 15 MySQL Storage Engines and Table Types. The other non-transactional storage engines in MySQL Server (such as MyISAM) follow a different paradigm for data integrity called ``atomic operations.'' In transactional terms, MyISAM tables effectively always operate in AUTOCOMMIT=1 mode. Atomic operations often offer comparable integrity with higher performance. With MySQL Server supporting 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. As noted, the trade-off for transactional versus non-transactional table types lies mostly in performance. Transactional tables have significantly higher memory and diskspace requirements, and more CPU overhead. On the other hand, transactional table types such as InnoDB 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. But how do you use the features of MySQL Server to maintain rigorous integrity even with the non-transactional MyISAM tables, and how do these features compare with the transactional table types?
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 LOCK TABLES, all updates will stall until any integrity checks are made. If you obtain a READ LOCAL 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 new inserted records will not be seen by the client that has the read lock until it releases the lock. With INSERT DELAYED, you can queue inserts into a local queue, until the locks are released, without having the client wait for the insert to complete. See section 14.1.4.2 INSERT DELAYED Syntax. ``Atomic,'' in the sense that we mean it, is nothing magical. It only means that you can be sure that while each specific update is running, no other user can interfere with it, and there will never be an automatic rollback (which can happen with transactional tables if you are not very careful). MySQL Server also guarantees that there will not be any dirty reads. Following are some techniques for working with non-transactional tables:
Last edited by Administrator : 06-08-2004 at 03:11 AM. |
|
|
|
|
|
#10 |
|
Administrator
Join Date: Jun 2004
Posts: 383
|
1.8.5.4 Stored Procedures and Triggers
From http://dev.mysql.com/doc/mysql/en/AN..._Triggers.html
1.8.5.4 Stored Procedures and Triggers Stored procedures are implemented in MySQL version 5.0. See section 20 Stored Procedures and Functions. Triggers are scheduled for implementation in MySQL version 5.1. A ``trigger'' is effectively a type of stored procedure, one that is invoked when a particular event occurs. For example, you could set up a stored procedure that is triggered each time a record is deleted from a transactional table, and that stored procedure automatically deletes the corresponding customer from a customer table when all their transactions are deleted. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Import Access, Excel and data of other formats to MySQL by Navicat | NavicatGuy | Articles | 0 | 08-17-2004 01:08 AM |
| 3.2 Entering Queries | Administrator | Documentation | 0 | 06-09-2004 02:58 AM |
| 1.4.3.2 Using the MySQL Software for Free Under GPL | Administrator | Documentation | 0 | 06-08-2004 02:20 AM |
| 1.2.2 The Main Features of MySQL | Administrator | Documentation | 0 | 06-08-2004 01:55 AM |
| 1.2 Overview of the MySQL Database Management System | Administrator | Documentation | 0 | 06-07-2004 10:11 PM |