- Schema and table names
- Column names (supports composite keys)
- Primary key definitions
Database Editions
ChartDB supports multiple MySQL versions:- MySQL 8.0+: Modern query with optimized variable assignment
- MySQL 5.7: Compatible query using traditional GROUP_CONCAT approach
Smart Query Import
The MySQL Smart Query extracts complete schema metadata using database-specific functions.MySQL 8.0+ Query
For MySQL 5.7 compatibility, ChartDB uses
GROUP_CONCAT instead of variable assignment. Run this before the query:What the Smart Query Retrieves
Foreign Keys (fk_info)
Foreign Keys (fk_info)
- Schema and table names
- Column names
- Foreign key constraint names
- Referenced schema, table, and column
- Update and delete rules (CASCADE, RESTRICT, SET NULL, NO ACTION)
- Full FK definition string
Primary Keys (pk_info)
Primary Keys (pk_info)
Columns (cols)
Columns (cols)
- Data types (normalized to lowercase)
- Character maximum length
- Numeric precision and scale (for DECIMAL, NUMERIC)
- Ordinal position
- Nullable constraints
- Default values
- Collation names
- AUTO_INCREMENT detection via
extracolumn - Column comments
Indexes (indexes)
Indexes (indexes)
- Index names and types (BTREE, HASH, FULLTEXT, SPATIAL)
- Indexed columns
- Index size (from
mysql.innodb_index_stats) - Cardinality statistics
- Sort direction (ASC/DESC)
- Column position in composite indexes
- Unique constraint flags
Tables (tbls)
Tables (tbls)
- Schema and table names
- Row counts (estimated)
- Table type (BASE TABLE, VIEW, SYSTEM VIEW)
- Storage engine (InnoDB, MyISAM, etc.)
- Table collation
- Table comments
Views (views)
Views (views)
- Schema and view names
- View definitions (empty in base query)
SQL Import
ChartDB can parse MySQL DDL scripts with support for MySQL-specific syntax.Supported Features
- Table Creation: CREATE TABLE with IF NOT EXISTS
- Data Types: All MySQL types including:
- Integer types: TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT
- Decimal types: DECIMAL, NUMERIC, FLOAT, DOUBLE
- String types: CHAR, VARCHAR, TEXT, MEDIUMTEXT, LONGTEXT
- Binary types: BINARY, VARBINARY, BLOB
- Date/time: DATE, DATETIME, TIMESTAMP, TIME, YEAR
- JSON (MySQL 5.7.8+)
- ENUM and SET types
- Constraints:
- PRIMARY KEY (inline and table-level)
- FOREIGN KEY with ON DELETE/UPDATE actions
- UNIQUE constraints
- CHECK constraints (MySQL 8.0.16+)
- NOT NULL
- AUTO_INCREMENT: Automatic sequence generation
- Storage Engines: ENGINE=InnoDB, MyISAM, etc.
- Character Sets: CHARACTER SET and COLLATE
- Table Comments: COMMENT=‘description’
- Column Comments: COMMENT ‘description’
- Indexes: CREATE INDEX and CREATE UNIQUE INDEX
- Views: CREATE VIEW and CREATE OR REPLACE VIEW
- Databases: Multi-database support
Import Example
SQL Export
Export your ChartDB diagrams to production-ready MySQL SQL.Export Features
- Database Creation: CREATE DATABASE IF NOT EXISTS statements
- Table Creation: CREATE TABLE IF NOT EXISTS
- AUTO_INCREMENT: Automatic for primary key integer columns
- Data Type Mapping: Converts types to MySQL equivalents:
- boolean → TINYINT(1)
- uuid → CHAR(36)
- jsonb → JSON
- Arrays → JSON
- timestamp with time zone → DATETIME
- Comments: Inline table and column comments
- Indexes: Separate CREATE INDEX statements with:
- Prefix length for TEXT/BLOB columns
- Unique index support
- Constraints:
- Primary keys as table constraints
- Foreign keys with proper references
- Check constraints (MySQL 8.0.16+)
- Unique constraints
- Default VARCHAR Size: Automatically adds (255) if not specified
- Backtick Quoting: Proper identifier quoting
Export Example
MySQL-Specific Features
AUTO_INCREMENT
MySQL uses AUTO_INCREMENT for automatic sequence generation:- Detects AUTO_INCREMENT from Smart Query
- Adds AUTO_INCREMENT to primary key integer columns on export
- Removes default values when AUTO_INCREMENT is present
Storage Engines
MySQL supports multiple storage engines:- InnoDB: Default, supports transactions and foreign keys
- MyISAM: Legacy, no transaction support
- MEMORY: In-memory tables
- CSV: Comma-separated values
Character Sets and Collations
Comments
MySQL supports inline comments:ENUM and SET Types
ChartDB converts ENUM types to VARCHAR(50) on export to other databases.
Best Practices
Troubleshooting
GROUP_CONCAT truncation
GROUP_CONCAT truncation
For large databases in MySQL 5.7, increase the limit:
Permission denied errors
Permission denied errors
Ensure your database user has SELECT permissions on:
information_schema.tablesinformation_schema.columnsinformation_schema.key_column_usageinformation_schema.referential_constraintsinformation_schema.statisticsmysql.innodb_index_stats
Inline REFERENCES error
Inline REFERENCES error
MySQL does not support inline REFERENCES. Use table-level FOREIGN KEY constraints instead.
CHECK constraint not working
CHECK constraint not working
CHECK constraints are only enforced in MySQL 8.0.16+. For older versions, they are parsed but not enforced.
