通过IBM Migration Toolkit的支持把数据从MySQL迁移到DB2和Informix Dynamic
2010-05-14 15:00:44 来源:WEB开发网清单 7 说明 MySQL 数据类型和 CREATE TABLE 语句如何转换为 IDS 语法:
清单 7a. MySQL SQL - CREATE TABLE
CREATE TABLE tab7(
col1 CHAR(20),
col2 VARCHAR(30),
col3 SMALLINT(20),
col4 TINYINT(30),
col5 MEDIUMINT(20),
col6 INT(10),
col7 INTEGER(20),
col8 BIGINT(20),
col9 REAL,
col10 DOUBLE,
col11 FLOAT,
col12 DECIMAL(10,4),
col13 NUMERIC(10,4),
col14 DATE,
col15 TIME,
col16 TIMESTAMP,
col17 DATETIME,
col18 YEAR,
col19 BIT
);
清单 7b. MTK 转换 - CREATE TABLE(IDS)
CREATE TABLE tab7(
col1 CHAR(20),
col2 VARCHAR(30),
col3 SMALLINT,
col4 SMALLINT,
col5 INTEGER,
col6 INTEGER,
col7 INTEGER,
col8 INT8,
col9 DOUBLE PRECISION,
col10 DOUBLE PRECISION,
col11 DOUBLE PRECISION,
col12 DECIMAL(10,4),
col13 DECIMAL(10,4),
col14 DATE,
col15 DATETIME HOUR TO FRACTION (5),
col16 DATETIME YEAR TO FRACTION (5),
col17 DATETIME YEAR TO FRACTION (5),
col18 CHAR(4),
col19 SMALLINT
);
清单 8 是一个把约束转换为 IDS 语法的示例。
清单 8a. MySQL SQL - 约束
CREATE TABLE tab8 (
col1 TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
col2 SMALLINT
);
CREATE TABLE unq(
c1 INTEGER,
c2 CHAR(10),
CONSTRAINT ccc UNIQUE KEY(c1)
);
清单 8b. MTK 转换 - IDS 中的约束
CREATE TABLE tab8(
col1 DATETIME YEAR TO FRACTION (5)
DEFAULT CURRENT YEAR TO FRACTION (5),
col2 SMALLINT
);
CREATE TABLE unq(
c1 INTEGER,
c2 CHAR(10),
UNIQUE(c1) CONSTRAINT ccc
);
更多精彩
赞助商链接