sqlFetch(RODBC)
sqlFetch()所属R语言包:RODBC
Reading Tables from ODBC Databases
阅读从ODBC数据库的表
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Read some or all of a table from an ODBC database into a data frame.
到一个数据框从一个ODBC数据库的一个表的部分或全部。
用法----------Usage----------
sqlFetch(channel, sqtable, ..., colnames = FALSE, rownames = TRUE)
sqlFetchMore(channel, ..., colnames = FALSE, rownames = TRUE)
参数----------Arguments----------
参数:channel
connection handle returned by odbcConnect.
连接返回的句柄odbcConnect。
参数:sqtable
a database table name accessible from the connected DSN. This should be either a literal character string or a character vector of length 1.
从连接的DSN访问数据库表名。这应该是一个文字字符串或字符向量的长度为1。
参数:...
additional arguments to be passed to sqlQuery or sqlGetResults. See "Details".
额外的参数传递给sqlQuery或sqlGetResults。请参阅“详细信息”。
参数:colnames
logical: retrieve column names from first row of table? (For use when sqlSave(colnames = TRUE) was used.)
逻辑:检索表的第一行中的列名? (适用于sqlSave(colnames = TRUE)使用。)
参数:rownames
either logical or character. If logical, retrieve row names from the first column (rownames) in the table? If character, the column name to retrieve them from.
逻辑或字符。如果逻辑,从第一列(rownames)表中检索行的名称吗?如果字符,列名对它们进行检索。
Details
详细信息----------Details----------
Note the "table" includes whatever table-like objects are provided by the DBMS, in particular views and system tables.
注意“表”包括任何表像所提供的对象的数据库管理系统,在特定的视图和系统表。
sqlFetch by default retrieves the the entire contents of the table sqtable. Rownames and column names are restored as indicated (assuming that they have been placed in the table by the corresponding arguments to sqlSave).
sqlFetch默认情况下,检索的整个内容的表sqtable。行名和列名恢复为(假定它们已经被放置在表中相应的参数sqlSave)。
Alternatively, sqlFetch can fetch the first max rows, in which case sqlFetchMore will retrieve further result rows, provided there has been no other ODBC query on that channel in the meantime.
另外,sqlFetch可以取第一max行,在这种情况下,sqlFetchMore将检索进一步结果行,在该通道在此期间一直没有其他ODBC查询。
These functions try to cope with the peculiar way the Excel ODBC driver handles table names, and to quote Access table names which contain spaces. Dotted table names, e.g. myschema.mytable, are allowed on systems that support them, unless the connection was opened with interpretDot = FALSE.
这些函数会尽量配合Excel的ODBC驱动程序的特殊方式处理的表名,并引用访问的表名包含空格。虚线表名,如“”myschema.mytable,允许系统上支持他们,,除非打开连接与interpretDot = FALSE。
Useful additional parameters to pass to sqlQuery or sqlGetResults include
有用的附加参数传递给sqlQuery或sqlGetResults包括:
max: limit on the number of rows to fetch, with
max:限制的行数取,
nullstring: character string to be used when reading SQL_NULL_DATA character items from the database:
nullstring:SQL_NULL_DATA从数据库中的字符项时所使用的字符串:
na.strings: character string(s) to be mapped to
na.strings:字符串(S)被映射到
as.is: as in sqlGetResults.
as.is:在sqlGetResults。
dec: The character for the decimal place to be assumed
dec:小数位的字符被假定
rows_at_time: Allow for multiple rows to be retrieved at
rows_at_time:允许多个行进行检索
值----------Value----------
A data frame on success, or a character or numeric error code (see sqlQuery).
成功的一个数据框,或一个字符或数值错误代码(见sqlQuery“)。
注意----------Note----------
If the table name desired is not a valid SQL name (alphanumeric plus _) and these functions are not able to interpret the name, you can use sqlQuery with whatever quoting mechanism your DBMS vendor provides (e.g. [ ] on some Microsoft products and backticks on MySQL).
如果需要的表名是不是一个有效的SQL名称(字母数字加_),这些功能是无法解释的名称,你可以使用sqlQuery不管你的DBMS供应商提供的报价机制(如: [ ]一些微软产品和在MySQL中是反向引号)。
(作者)----------Author(s)----------
Michael Lapsley and Brian Ripley
参见----------See Also----------
sqlSave, sqlQuery, odbcConnect, odbcGetInfo
sqlSave,sqlQuery,odbcConnect,odbcGetInfo
实例----------Examples----------
## Not run: [#不运行:]
channel <- odbcConnect("test")
sqlSave(channel, USArrests)
sqlFetch(channel, "USArrests") # get the lot[得到了很多]
sqlFetch(channel, "USArrests", max = 20, rows_at_time = 10)
sqlFetchMore(channel, max = 20)
sqlFetchMore(channel) # get the rest[得到截断]
sqlDrop(channel, "USArrests")
close(channel)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|