Data Types for MySQL

Overview

Every column in a table has a name and a data type. The data type tells MySQL how much physical storage to set aside for the column and the form in which the data is stored. This section includes information about MySQL data types and data conversions.

Supported MySQL Data Types

Here are the data types that the MySQL engine supports.

LIBNAME Statement Data Conversions

This table shows the default formats that SAS/ACCESS Interface to MySQL assigns to SAS variables when using the LIBNAME statement to read from a MySQL table. These default formats are based on MySQL column attributes.

LIBNAME Statement: Default SAS Formats for MySQL Data Types

MySQL Column Type

SAS Data Type

Default SAS Format

CHAR(n)1

character

$w.

VARCHAR(n)1

character

$w.

TINYTEXT

character

$w.

TEXT

character

$w.2

MEDIUMTEXT

character

$w.2

LONGTEXT

character

$w.2

JSON

character

$w.2

TINYBLOB

character

$w.2

BLOB

character

$w.2

MEDIUMBLOB

character

$w.2

LONGBLOB

character

$w.2

ENUM

character

$w.

SET

character

$w.

TINYINT

numeric

4.0

SMALLINT

numeric

6.0

MEDIUMINT

numeric

8.0

INT

numeric

11.0

BIGINT

numeric

20.

DECIMAL

numeric

w.d

FLOAT

numeric

DOUBLE

numeric

DATE

numeric

DATE

TIME

numeric

TIME

DATETIME

numeric

DATETIME

TIMESTAMP

numeric

DATETIME

1 n in MySQL character data types is equivalent to w in SAS formats.
2 In this case, w is the value of the DBMAX_TEXT= option.

This table shows the default MySQL data types that SAS/ACCESS assigns to SAS variable formats during output operations when you use the LIBNAME statement.

LIBNAME Statement: Default MySQL Data Types for SAS Variable Formats

SAS Variable Format

MySQL Data Type

w.d1

DECIMAL ([m-1],n)2, 3

w. (where w <= 2)

TINYINT

w. (where w <= 4)

SMALLINT

w. (where w <=6)

MEDIUMINT

w (where w <= 17)

BIGINT

other numerics

DOUBLE

$w. (where w <= 65535)

VARCHAR(n)1

$w. (where w > 65535)

TEXT

datetime formats

TIMESTAMP

date formats

DATE

time formats

TIME

1 n in MySQL character data types is equivalent to w in SAS formats.
2 m and n in MySQL numeric data types are equivalent to w and d in SAS formats.
3 DECIMAL types are created as (m-1, n). SAS includes space to write the value, the decimal point, and a minus sign (if necessary) in its calculation for precision. These must be removed when converting to MySQL.

Last updated: February 3, 2026