31.07.2015 Views

Database Migration from MySQL to RDM Server - Embedded Tools ...

Database Migration from MySQL to RDM Server - Embedded Tools ...

Database Migration from MySQL to RDM Server - Embedded Tools ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

MIGRATION GUIDE<strong>Database</strong> <strong>Migration</strong> <strong>from</strong> <strong>MySQL</strong><strong>to</strong> <strong>RDM</strong> <strong>Server</strong>A Birdstep Technology, Inc. Raima <strong>Embedded</strong> <strong>Database</strong> Division <strong>Migration</strong> GuidePublished: May, 2009Author: Daigoro F. ToyamaSenior Software Engineerdaigoro.<strong>to</strong>yama@birdstep.comCopyright: Birdstep Technology, Inc. All rights reservedAbstract:This document is designed <strong>to</strong> act as a quick guide <strong>to</strong> the database migration <strong>from</strong> <strong>MySQL</strong> <strong>to</strong> <strong>RDM</strong><strong>Server</strong> by exposing the differences between the two products with regards <strong>to</strong> the data types, featuresand SQL statement syntaxes supported differently between them.This article is relative <strong>to</strong> the following versions of <strong>RDM</strong>:In this document, <strong>MySQL</strong> refers <strong>to</strong> <strong>MySQL</strong> 6.0. Likewise, <strong>RDM</strong> <strong>Server</strong> (or <strong>RDM</strong>s) refers <strong>to</strong><strong>RDM</strong> <strong>Server</strong> 8.2.http://www.raima.com


<strong>Migration</strong> GuideContents:Abstract: ........................................................................................................................................... 1Contents: .......................................................................................................................................... 2Overview ........................................................................................................................................... 4Data Types........................................................................................................................................ 4Data Definition Language Statements ................................................................................................ 5ALTER DATABASE / SCHEMA ...................................................................................................... 5ALTER EVENT .............................................................................................................................. 5ALTER FUNCTION / PROCEDURE................................................................................................ 5ALTER SERVER............................................................................................................................ 5ALTER TABLE ............................................................................................................................... 6CREATE DATABASE ..................................................................................................................... 6CREATE EVENT ........................................................................................................................... 6CREATE INDEX ............................................................................................................................ 6CREATE FUNCTION / PROCEDURE ............................................................................................. 6CREATE SERVER ......................................................................................................................... 6CREATE TABLE ............................................................................................................................ 7CREATE TRIGGER ....................................................................................................................... 7CREATE VIEW .............................................................................................................................. 7DROP DATABASE / SCHEMA ....................................................................................................... 7DROP EVENT ............................................................................................................................... 7DROP INDEX ................................................................................................................................ 7DROP PROCEDURE / FUNCTION ................................................................................................. 7DROP SERVER ............................................................................................................................. 8DROP TABLE ................................................................................................................................ 8DROP TRIGGER ........................................................................................................................... 8DROP VIEW .................................................................................................................................. 8RENAME TABLE ........................................................................................................................... 8Data Manipulation Language Statements ........................................................................................... 8CALL ............................................................................................................................................. 8DELETE ........................................................................................................................................ 9DO ................................................................................................................................................ 9HANDLER ..................................................................................................................................... 9http://www.raima.comPage | 2


<strong>Migration</strong> GuideINSERT ......................................................................................................................................... 9LOAD DATA INFILE ....................................................................................................................... 9LOAD XML INFILE ......................................................................................................................... 9REPLACE.................................................................................................................................... 10SELECT ...................................................................................................................................... 10TRUNCATE ................................................................................................................................. 10UPDATE ...................................................................................................................................... 10Transactional and Locking Statements ............................................................................................. 10START TRANSACTION / BEGIN .................................................................................................. 10COMMIT / ROLLBACK ................................................................................................................. 10SET AUTOCOMMIT ..................................................................................................................... 11SAVEPOINT ................................................................................................................................ 11ROLLBACK TO SAVEPOINT ....................................................................................................... 11LOCK / UNLOCK TABLES ........................................................................................................... 11SET TRANSACTION ISOLATION................................................................................................. 11Conclusion ...................................................................................................................................... 11Contact Information ......................................................................................................................... 12http://www.raima.comPage | 3


<strong>Migration</strong> GuideOverviewThis document gives an overview of the key differences in the SQL implementations between <strong>MySQL</strong>and <strong>RDM</strong> <strong>Server</strong>. It is intended <strong>to</strong> be a guide for developers <strong>to</strong> obtain a quick overview of the items <strong>to</strong>take in<strong>to</strong> consideration when moving an application <strong>from</strong> <strong>MySQL</strong> <strong>to</strong> <strong>RDM</strong> <strong>Server</strong>. The first two sectionsof this document outline the differences in the data types and SQL statements that exist between thetwo database solutions. However, it does not outline any of the differences in the native APIs of eachproduct. As long as developers use the standard SQL-API, ODBC and/or JDBC interfaces the matchbetween the two products should be nearly identical. If developers are using the <strong>MySQL</strong> native C-API atranslation is required <strong>to</strong> <strong>RDM</strong> <strong>Server</strong>s-supported SAG CLI-API. Information on how <strong>to</strong> do thistranslation can be found at: http://en.wikipedia.org/wiki/Call_Level_Interface.Data TypesThe following table shows the data types supported by <strong>MySQL</strong> in its data definition language and thecorresponding data types supported by <strong>RDM</strong> <strong>Server</strong> when applicable.Data Type <strong>MySQL</strong> <strong>RDM</strong> <strong>Server</strong>8-bit integerBIT16-bit integer SMALLINT SMALLINT24-bit integerMEDIUMINT32-bit integer INT/INTEGER INTEGER64-bit integer BIGINT BIGINT32-bit floating point64-bit floating pointFLOATDOUBLE / REALVariable floating point DECIMAL / NUMERIC DECIMAL / NUMERICDate DATE DATETime TIME TIMEDate and Time DATETIME / TIMESTAMP TIMESTAMPYearYEARCharacter String CHAR / VARCHAR CHAR / VARCHARBinary BINARY / VARBINARY BINARY / VARBINARYhttp://www.raima.comPage | 4


<strong>Migration</strong> GuideData Type <strong>MySQL</strong> <strong>RDM</strong> <strong>Server</strong>BLOB (binary) TINYBLOB / BLOB /MEDIUMBLOB / LONGBLOBBLOB (character) TINYTEXT / TEXT /MEDIUMTEXT / LONGTEXTLONG VARBINARYLONG VARCHARCharacter string (enum)Character string (set)ENUMSETData Definition Language StatementsHere is the list of the DDL statements supported by <strong>MySQL</strong>.ALTER DATABASE / SCHEMAThe ALTER DATABASE statement in <strong>MySQL</strong> is used <strong>to</strong> change the overall characteristics of adatabase. It differs <strong>from</strong> that of <strong>RDM</strong> <strong>Server</strong> where the statement is used <strong>to</strong> change the contents of adatabase (such as adding/dropping tables/indices). <strong>RDM</strong> <strong>Server</strong> currently does not support thisfunctionality, but the statement is used mainly for upgrading a <strong>MySQL</strong> 5.1 database <strong>to</strong> 6.0.Supported:Necessary:NoNoALTER EVENTThe ALTER EVENT statement in <strong>MySQL</strong> is used <strong>to</strong> change the characteristics of an existing event.Since <strong>RDM</strong> <strong>Server</strong> does not support events, it naturally does not support this statement.Supported:Necessary:NoALTER FUNCTION / PROCEDUREThe ALTER FUNCTION / PROCEDURE statement in <strong>MySQL</strong> is used <strong>to</strong> change the characteristics of as<strong>to</strong>red function or s<strong>to</strong>red procedure. <strong>RDM</strong> <strong>Server</strong> supports functions and procedures but does not allowthe alternation of their characteristics.Supported:Necessary:NoALTER SERVERThe ALTER SERVER statement in <strong>MySQL</strong> is used <strong>to</strong> change the information on the specified server.<strong>RDM</strong> <strong>Server</strong> does not support the concept of creating/altering servers.Supported:Necessary:NoNohttp://www.raima.comPage | 5


<strong>Migration</strong> GuideALTER TABLEThe ALTER TABLE statement in <strong>MySQL</strong> is used <strong>to</strong> change the structure of an existing table. <strong>RDM</strong><strong>Server</strong> supports most of the core options, such as adding/dropping indices, adding/dropping/alteringcolumns, and renaming columns. Those we do not support are mostly for the features that we do notsupport.Supported:Necessary:YesYesCREATE DATABASEThe CREATE DATABASE statement in <strong>MySQL</strong> creates a new database. <strong>MySQL</strong> and <strong>RDM</strong> <strong>Server</strong>supports different options as they support different database features. For instance, <strong>MySQL</strong> allows theuser <strong>to</strong> set the default database character set and collation name.Supported:Necessary;YesYesCREATE EVENTThe CREATE EVENT statement in <strong>MySQL</strong> creates and schedules a new event. <strong>RDM</strong> <strong>Server</strong> does notsupport events; therefore not CREATE EVENT.Supported:Necessary:NoNoCREATE INDEXThe CREATE INDEX statement in <strong>MySQL</strong> is used <strong>to</strong> create an index. <strong>RDM</strong> <strong>Server</strong> supports it exceptfor the USING [ BTREE | HASH | RTREE ] clause that specifies the indexing algorithm (we only useBTREE) and the WITH PARSER clause.Supported:Necessary:YesYesCREATE FUNCTION / PROCEDUREThe CREATE FUNCTION / PROCEDURE statement in <strong>MySQL</strong> is used <strong>to</strong> create a function or a s<strong>to</strong>redprocedure. <strong>RDM</strong> <strong>Server</strong> supports both, though the details differ. <strong>MySQL</strong> lets you create both functionsand procedures in SQL; <strong>RDM</strong> <strong>Server</strong> requires that functions and user-defined procedures be written asshared librariesSupported:Necessary:YesYesCREATE SERVERThe CREATE SERVER statement in <strong>MySQL</strong> creates the definition of a server. <strong>RDM</strong> <strong>Server</strong> does notsupport it as our concept of a server is different than that of <strong>MySQL</strong>.Supported:Necessary:NoNohttp://www.raima.comPage | 6


<strong>Migration</strong> GuideDROP SERVERThe DROP SERVER statement in <strong>MySQL</strong> drops a server definition. <strong>RDM</strong> <strong>Server</strong> does not support it asour concept of a server is different than that of <strong>MySQL</strong>.DROP TABLEThe DROP TABLE statement in <strong>MySQL</strong> removes one or more tables. Triggers for the dropped table(s)will also be dropped. <strong>RDM</strong> <strong>Server</strong> supports DROP TABLE, though only one table can be removed at atime. <strong>RDM</strong> <strong>Server</strong> does not support the IF EXISTS extension, either.Supported:Necessary;YesYesDROP TRIGGERThe DROP TRIGGER statement in <strong>MySQL</strong> drops a trigger. <strong>RDM</strong> <strong>Server</strong> supports triggers in the form ofUDF, but not in this ANSI format.Supported:Necessary:NoProbablyDROP VIEWThe DROP VIEW statement in <strong>MySQL</strong> drops one or more views. <strong>RDM</strong> <strong>Server</strong> supports DROP VIEW,though only one view can be removed at a time. <strong>RDM</strong> <strong>Server</strong> does not support the IF EXISTSextension, either.Supported:Necessary:Yes, basicallyYesRENAME TABLEThe RENAME TABLE statement in <strong>MySQL</strong> renames one or more tables. <strong>RDM</strong> <strong>Server</strong> supportsRENAME TABLE with a slightly different syntax. It also only supports renaming one table at a time.Supported:Necessary:Yes, basicallyYesData Manipulation Language StatementsHere is the list of the DML statements supported by <strong>MySQL</strong>.CALLThe CALL statement in <strong>MySQL</strong> invokes a s<strong>to</strong>red procedure. The <strong>RDM</strong> <strong>Server</strong> equivalent is EXECUTE.Supported:Necessary:YesYeshttp://www.raima.comPage | 8


<strong>Migration</strong> GuideDELETEThe DELETE statement in <strong>MySQL</strong> deletes rows <strong>from</strong> the specified table and returns a count of thenumber of deleted rows. <strong>MySQL</strong> extends the statement with keywords such as QUICK (where theindex leaves are not merged during DELETE) and LIMIT (which limits the number of rows <strong>to</strong> delete).<strong>RDM</strong> <strong>Server</strong> supports the core DELETE statement, but not those <strong>MySQL</strong> extensions.Supported:Necessary:YesYesDOThe DO statement in <strong>MySQL</strong> executes the expressions but does not return any results. <strong>RDM</strong> <strong>Server</strong>does not support it.Supported:Necessary:NoNoHANDLERThe HANDLER statement in <strong>MySQL</strong> provides direct access <strong>to</strong> table s<strong>to</strong>rage engine interfaces. It isavailable for MyISAM and InnoDB tables. Naturally, <strong>RDM</strong> <strong>Server</strong> does not support it.Supported:Necessary:NoNoINSERTThe INSERT statement in <strong>MySQL</strong> inserts new rows in<strong>to</strong> an existing table. The INSERT … VALUESstatement works identically <strong>to</strong> that of <strong>RDM</strong> <strong>Server</strong>. The INSERT … SET statement can be replacedeasily with INSERT … VALUES with specific column names. <strong>RDM</strong> <strong>Server</strong> does not support <strong>MySQL</strong>extensions such as INSERT DELAYED and INSERT IGNORE.Supported:Necessary;YesYesLOAD DATA INFILEThe LOAD DATA INFILE statement in <strong>MySQL</strong> reads rows <strong>from</strong> a text file in<strong>to</strong> a table. The <strong>RDM</strong> <strong>Server</strong>equivalent is INSERT … FROM (ASCII) FILE. The LOAD DATA INFILE statement allows for moreflexibility than our INSERT … FROM FILE when selecting particular sections of the file <strong>to</strong> be read andinserted.Supported:Necessary:YesYesLOAD XML INFILEThe LOAD XML INFILE statement in <strong>MySQL</strong> reads data <strong>from</strong> an XML file in<strong>to</strong> a table. The <strong>RDM</strong> <strong>Server</strong>equivalent is INSERT … FROM XML FILE. The same issue with flexibility found in LOAD DATA INFILEexists here.Supported:Necessary;YesYeshttp://www.raima.comPage | 9


<strong>Migration</strong> GuideREPLACEThe REPLACE statement in <strong>MySQL</strong> works exactly like INSERT, except that if an old row has the samevalue as a new row for a PRIMARY / UNIQUE KEY index, the old row is deleted before the new row isinserted.It means the REPLACE statement is a combination of INSERT and UPDATE. <strong>RDM</strong> <strong>Server</strong> does notsupport this specific syntax, but the same result can be achieved by combining SELECT, INSERT andUPDATE. A UDP would be an option, <strong>to</strong>o.Supported:Necessary:No, but it can be worked aroundNoSELECTThe SELECT statement in <strong>MySQL</strong> is used <strong>to</strong> retrieve rows <strong>from</strong> one or more tables. <strong>MySQL</strong> allowsUNION, JOIN and sub queries. <strong>RDM</strong> <strong>Server</strong> supports it except for a few fine-tuning parameters andUNION. The UNION syntax will be supported in the next version of <strong>RDM</strong> <strong>Server</strong>. <strong>MySQL</strong> also allowsindex hints <strong>to</strong> be specified for manual query optimization. <strong>RDM</strong> <strong>Server</strong> supports the same conceptthrough a different syntax.Supported:Necessary:Yes, except for UNIONYesTRUNCATEThe TRUNCATE [TABLE] statement in <strong>MySQL</strong> empties a table completely. <strong>RDM</strong> <strong>Server</strong> does notsupport this, although DELETE FROM TABLE syntactically serves the same purpose. TheTRUNCATE statement in <strong>MySQL</strong> exists primarily for performance purposes.Supported:Necessary:NoNoUPDATEThe UPDATE statement in <strong>MySQL</strong> updates rows in one or more tables with the specified new values.<strong>RDM</strong> <strong>Server</strong> supports it except for the IGNORE and LIMIT extensions.Supported:Necessary:Yes, basicallyYesTransactional and Locking StatementsHere is the list of the transactional and locking statements supported by <strong>MySQL</strong>.START TRANSACTION / BEGINThe START TRANSACTION or BEGIN statement in <strong>MySQL</strong> begins a new transaction. <strong>RDM</strong> <strong>Server</strong>supports the operation with the BEGIN [WORK] statement.COMMIT / ROLLBACKThe COMMIT / ROLLBACK statement in <strong>MySQL</strong> commits / rolls back the current transaction. <strong>RDM</strong><strong>Server</strong> supports the operations with the COMMIT / ROLLBACK statements.http://www.raima.comPage | 10


<strong>Migration</strong> GuideSET AUTOCOMMITThe SET AUTOCOMMIT statement in <strong>MySQL</strong> turns on or off the au<strong>to</strong>matic commit mode. Theau<strong>to</strong>matic commit mode is ON by default in <strong>MySQL</strong>. You run the statement in the following way <strong>to</strong>disable au<strong>to</strong> commit.SET au<strong>to</strong>commit = 0;<strong>RDM</strong> <strong>Server</strong> does not support the SET AUTOCOMMIT statement directly, though it should not be hard<strong>to</strong> add support for it. <strong>RDM</strong> <strong>Server</strong> also supports the INSERT statement with the WITH AUTO COMMIToption as follows.INSERT WITH AUTO COMMIT INTO table_name VALUES( … );SAVEPOINTThe SAVEPOINT statement in <strong>MySQL</strong>, when used with InnoDB or Falcon, sets a named transactionsave point with a name. If the current transaction has a save point with the same name, the old savepoint is deleted and a new one is set. <strong>RDM</strong> <strong>Server</strong> supports this feature with the MARK statement. Thebehaviour is identical.ROLLBACK TO SAVEPOINTThe ROLLBACK TO SAVEPOINT statement in <strong>MySQL</strong> rolls back a transaction <strong>to</strong> the named save pointwithout terminating the transaction. The locks applied after the save point will be freed under Falcon butnot under InnoDB. <strong>RDM</strong> <strong>Server</strong> supports this feature with the same syntax. Its behaviour regarding thelocks is identical <strong>to</strong> that of InnoDB.LOCK / UNLOCK TABLESThe LOCK / UNLOCK TABLES statements in <strong>MySQL</strong> acquires / releases non-transactional andtransactional table locks. The LOCK / UNLOCK TABLE statements can be used on views as well astables. <strong>RDM</strong> <strong>Server</strong> supports this feature with the LOCK / UNLOCK TABLE statements, though it doesnot support locking / unlocking views.SET TRANSACTION ISOLATIONThe SET TRANSACTION ISOLATION statement in <strong>MySQL</strong> sets the transaction isolation level globally,for the current session or for the next transaction. All modes – READ COMMITTED, READUNCOMMITTED, REPEATABLE READ and SERIALIZE are supported. <strong>RDM</strong> <strong>Server</strong> supports thisfeature as well, sans SERIALIZE. <strong>RDM</strong> <strong>Server</strong> also only supports the transaction isolation setting onthe current session.ConclusionWith <strong>RDM</strong> <strong>Server</strong>’s support for SQL being nearly the same as that of <strong>MySQL</strong>’s and <strong>RDM</strong> <strong>Server</strong>’sability <strong>to</strong> run as a embedded library like <strong>MySQL</strong>, moving an embedded application over <strong>to</strong> <strong>RDM</strong> <strong>Server</strong>is relatively easy. So why not take advantage of the additional benefits in <strong>RDM</strong> <strong>Server</strong>’s performance,full transactional support, and competitive licensing options.http://www.raima.comPage | 11


<strong>Migration</strong> GuideContact InformationWebsite: http://www.raima.comNORTH AMERICAEUROPEBirdstep Technology, Inc.Birdstep Technology ASA2101 Fourth Avenue, Suite 240 C.J. Hambros Plass 3cSeattle, WA 981210164 Oslo, NorwayTelephone: +1 206 748 5300 Telephone: +47 90628326Fax: +1 206 748 5200 Fax: +47 24134701E-mail: americas@birdstep.comE-mail: lpagni@birdstep.comhttp://www.raima.comPage | 12

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!