SQLMapper provides comprehensive support for converting MySQL database schemas to other database systems. This document outlines MySQL-specific features and usage examples.
- Numeric:
INT,TINYINT,SMALLINT,MEDIUMINT,BIGINT,DECIMAL,FLOAT,DOUBLE - Text:
CHAR,VARCHAR,TEXT,TINYTEXT,MEDIUMTEXT,LONGTEXT - Date/Time:
DATE,TIME,DATETIME,TIMESTAMP,YEAR - Binary:
BINARY,VARBINARY,BLOB,TINYBLOB,MEDIUMBLOB,LONGBLOB - Others:
ENUM,SET,JSON
- Auto-incrementing fields (
AUTO_INCREMENT) - Table comments (
COMMENT) - Table character set and collation
- Storage engines (InnoDB, MyISAM, etc.)
- Primary keys
- Foreign keys
- Unique indexes
- Composite indexes
- Full-text indexes
NOT NULLUNIQUEPRIMARY KEYFOREIGN KEYCHECK(MySQL 8.0.16 and above)DEFAULTvalues
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(255) UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
COMMENT 'Table containing user information'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;CREATE TABLE categories (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
description TEXT
) ENGINE=InnoDB;
CREATE TABLE products (
id INT AUTO_INCREMENT PRIMARY KEY,
category_id INT NOT NULL,
name VARCHAR(200) NOT NULL,
price DECIMAL(10,2) NOT NULL,
stock INT DEFAULT 0,
FOREIGN KEY (category_id) REFERENCES categories(id)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB;CREATE TABLE articles (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(200) NOT NULL,
content TEXT,
tags VARCHAR(500),
publish_date TIMESTAMP,
INDEX idx_publish_date (publish_date),
FULLTEXT INDEX idx_title_content (title, content)
) ENGINE=InnoDB;CREATE VIEW active_products AS
SELECT p.id, p.name, p.price, c.name AS category_name
FROM products p
JOIN categories c ON p.category_id = c.id
WHERE p.stock > 0;DELIMITER //
CREATE TRIGGER product_update_log
AFTER UPDATE ON products
FOR EACH ROW
BEGIN
INSERT INTO product_log (product_id, old_price, new_price, update_time)
VALUES (NEW.id, OLD.price, NEW.price, NOW());
END//
DELIMITER ;AUTO_INCREMENT->SERIALorIDENTITYUNSIGNED-> Removed (PostgreSQL doesn't support it)ON UPDATE CURRENT_TIMESTAMP-> Simulated using triggersENUM-> PostgreSQL's nativeENUMtype orCHECKconstraint
AUTO_INCREMENT->AUTOINCREMENT- Complex data types ->
TEXTorBLOB - Foreign key constraints -> Limited FK support in SQLite
- Triggers -> Simplified trigger syntax
AUTO_INCREMENT->SEQUENCEandTRIGGERTIMESTAMP->DATEorTIMESTAMPVARCHAR->VARCHAR2TEXT->CLOB
- Always use UTF8MB4 character set
- Prefer InnoDB engine type
- Plan indexes carefully
- Choose appropriate data types
- Pay attention to comment usage
- Some MySQL-specific features may not be perfectly converted to other databases
- Complex triggers might need manual adjustment
- Some data types may be simplified during conversion
- Performance may vary with large schemas