Databases
MySQL
Column Types

MySQL Column Types

SchemaHero supports the following MySQL column types. If a type is missing, open an issue (opens in a new tab).

Simple Types

These types are used without parameters:

TypeDescription
dateDate (YYYY-MM-DD)
datetimeDate and time
timestampTimestamp
tinyblobTiny binary data (255 bytes)
tinytextTiny text (255 bytes)
blobBinary data (64KB)
textText (64KB)
mediumblobMedium binary data (16MB)
mediumtextMedium text (16MB)
longblobLong binary data (4GB)
longtextLong text (4GB)
jsonJSON data

Integer Types

TypeExampleDescription
tinyinttinyint, tinyint(1)1-byte integer (-128 to 127)
smallintsmallint, smallint(5)2-byte integer
mediumintmediumint, mediumint(9)3-byte integer
intint, int(11)4-byte integer
bigintbigint, bigint(20)8-byte integer
bitbit(1), bit(64)Bit field

Numeric Types

TypeExampleDescription
decimal(p,s)decimal(10,2)Exact numeric
decimal(p)decimal(10)Exact numeric (scale 0)
floatfloat, float(p,s)4-byte floating point
doubledouble, double(p,s)8-byte floating point

String Types

TypeExampleDescription
char(n)char(10)Fixed-length string
varchar(n)varchar(255)Variable-length string
binary(n)binary(16)Fixed-length binary
varbinary(n)varbinary(255)Variable-length binary

Date/Time Types

TypeExampleDescription
datedateDate only
timetimeTime only
datetimedatetime, datetime(6)Date and time
timestamptimestamp, timestamp(6)Timestamp (with precision 0-6)
yearyearYear

Type Aliases

SchemaHero automatically normalizes these aliases:

You WriteSchemaHero Uses
bool, booleantinyint(1)
integerint
decdecimal
double precisiondouble

Character Set and Collation

MySQL columns can specify charset and collation:

columns:
  - name: name
    type: varchar(255)
    charset: utf8mb4
    collation: utf8mb4_unicode_ci

Examples

columns:
  - name: id
    type: int
    attributes:
      autoIncrement: true
  - name: email
    type: varchar(255)
  - name: price
    type: decimal(10,2)
  - name: active
    type: boolean
  - name: metadata
    type: json
  - name: content
    type: longtext
  - name: created_at
    type: timestamp
    default: current_timestamp
  - name: data
    type: blob
  - name: bits
    type: bit(8)

Display Width (Deprecated)

MySQL 8.0.17+ deprecated display width for integer types. While SchemaHero still accepts int(11), the width is ignored by modern MySQL. Use int instead.