skip to main content
About the MongoDB Driver : Data Types
  

Try DataDirect Drivers Now

Data Types

The following table lists the MongoDB data types and their default mapping for ODBC. Default mappings can be overridden using the Schema Tool. See "Defining Columns" for additional information.
Table 1. Default Mapping for MongoDB Data Types
MongoDB Data Type
ODBC Data Type
Array1
SQL_WLONGVARCHAR (-10)
Bigint
SQL_BIGINT (-5)
BinData
SQL_VARBINARY (-3)
Boolean
SQL_BIT (-7)
Date
SQL_TIMESTAMP (93)
Decimal1282
SQL_DECIMAL (3)
Double
SQL_DOUBLE (8)
Integer
SQL_INTEGER (4)
Object3
SQL_WLONGVARCHAR (-10)
ObjectID4
SQL_WVARCHAR (-9)
String
SQL_WVARCHAR (-9)5, 6, 7

1 Complex data types can be returned as strings in the JSON format, or can be normalized such that nested elements are returned as columns in a new logical table.

2 The driver reports a precision of 68 digits this type; however, the native type limits the maximum number of digits before or after the decimal to 34 digits.

3 Complex data types can be returned as strings in the JSON format, or can be normalized such that nested elements are returned as columns in a new logical table.

4 The CAST_TO_NATIVE function escape may be needed to select or insert a value of the ObjectID type when MongoDB has inconsistent native types for a given field. See "Default Mapping of Columns with Inconsistent Native Data Types" and "CAST_TO_NATIVE Function Escape" for details.

5 When the driver discovers a String column with a value that is less than or equal to 4000 characters, the column is mapped as WVARCHAR and the precision is 4000 characters. When a String column with a value greater than 4000 characters is discovered, the column is mapped as WLONGVARCHAR and precision is 16 MB.

6 During the initial discovery and normalization process, you can use the DefaultVarcharSize configuration option to specify the default length of fields that are discovered and mapped as WVarchar by the driver. If the driver discovers a field with String data of a greater length, the String data is truncated to the length of the specified value. See "DefaultVarcharSize" for details.

7 You can map String to CHAR, VARCHAR, or LONGVARCHAR, regardless of the column size, using the Schema Tool. See "Creating and Customizing Schemas Using the DataDirect Schema Tool" and "Defining Columns" for details.

* Default Mapping of Columns with Inconsistent Native Data Types
* Retrieving Data Type Information