5

I'm trying to understand how RODBC determines the column types of a newly created (Access) table? The R documentation of sqlSave is very cryptic: "types are selected by consulting arguments varTypes and typeInfo". And no examples for this arguments. Where can I find a better explanation?

waanders
  • 8,907
  • 22
  • 70
  • 102

2 Answers2

6

Just look at the sources of the RODBC package.

# from R/TypeInfo.R:
typesR2DBMS <-
    list(MySQL = list(double="double", integer="integer",
         character="varchar(255)", logical="varchar(5)"),
         ACCESS = list(double="DOUBLE", integer="INTEGER",
         character="VARCHAR(255)", logical="varchar(5)"),
         # etc ...
rcs
  • 67,191
  • 22
  • 172
  • 153
  • 1
    http://cran.r-project.org/src/contrib/RODBC_1.3-2.tar.gz, File R/TypeInfo.R, Line 41 – rcs Jul 28 '10 at 11:30
  • Thanks. But I'm using Windows, my C:\Program Files\R\R-2.10.1\library\RODBC directory doesn't contains TypeInfo.R. Is there no example on the net? – waanders Jul 28 '10 at 11:56
  • 1
    You have to download the source package from the link above to view the source of `TypeInfo.R` – rcs Jul 28 '10 at 12:26
  • 1
    fantastic answer. I love that you pulled from the source and then gave a reference to where in the source it came from. That's excellent. – JD Long Jul 28 '10 at 15:26
  • str(getAnywhere(typesR2DBMS)) – Dieter Menne Dec 16 '11 at 07:41
  • How can we increase the default varchar length (without changing the source code)? – Hack-R Jan 19 '17 at 15:33
2

No need to look at the sources. Use "getSqlTypeInfo(driver)" instead.

> getSqlTypeInfo("ACCESS")
$double
[1] "DOUBLE"

$integer
[1] "INTEGER"

$character
[1] "VARCHAR(255)"

$logical
[1] "varchar(5)"

> 
Angelo
  • 2,936
  • 5
  • 29
  • 44