odbcDataType function

Return the corresponding ODBC data type for an R object

Return the corresponding ODBC data type for an R object

This is used when creating a new table with dbWriteTable(). Databases with default methods defined are:

  • MySQL
  • PostgreSQL
  • SQL Server
  • Oracle
  • SQLite
  • Spark
  • Hive
  • Impala
  • Redshift
  • Vertica
  • BigQuery
  • Teradata
  • Access
  • Snowflake
odbcDataType(con, obj, ...)

Arguments

  • con: A driver connection object, as returned by dbConnect().
  • obj: An R object.
  • ...: Additional arguments passed to methods.

Returns

Corresponding SQL type for the obj.

Details

If you are using a different database and dbWriteTable() fails with a SQL parsing error the default method is not appropriate, you will need to write a new method. The object type for your method will be the database name retrieved by dbGetInfo(con)$dbms.name. Use the documentation provided with your database to determine appropriate values for each R data type.

  • Maintainer: Hadley Wickham
  • License: MIT + file LICENSE
  • Last published: 2025-03-27