1.ODBC File Download Http://dasapp.oregon.gov/datamart/files/IBM_DB2_9.7_Run_Time_client_Notes.pdf Open:/http dasapp.oregon.gov/datamart/Download the driver and install it. Configure ODBC, just start by tutorial, in ODBC did not find DB2 driver behind in C:\Windows\SysWOW64 search ODBC, find this: open and follow the tutorial configuration. Configuration also reference: HTTP://XUJINGLI88.BLOG.163.COM/BLOG/STATIC/411786192009324294164/2. Connect db2> Library (RODBC) > conn = Odbcconnect (dsn= "DB2", uid= "Tjfx", "1") #刚开始在64位R下, reported this error: is version incompatibility caused, I fear trouble, directly to the Rstudio changed to 32-bit: Click Tools--Global Options--Modify R version 3. Query http://www.ibm.com/developerworks/data/library/techarticle/dm-1402db2andr/#listing6 Library (RODBC) conn = Odbcconnect (dsn= "DB2", uid= "Tjfx", "1") #把表中的数据存到内存res <-SqlFetch (conn, "Etlusr". Ecs_brand ") #查询, but cannot be queried across tables SQLQuery (conn, paste (' select ' brand_id ', ' brand_name ' from ' Dim_ecs_goods_brand ', ' where ' brand_id "<100 ORDER by" brand_id "))
R Connecting the DB2 database