EVOLUTION-MANAGER
Edit File: dbReadTable.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Copy data frames from database tables</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for dbReadTable {DBI}"><tr><td>dbReadTable {DBI}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Copy data frames from database tables</h2> <h3>Description</h3> <p>Reads a database table to a data frame, optionally converting a column to row names and converting the column names to valid R identifiers. </p> <h3>Usage</h3> <pre> dbReadTable(conn, name, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>conn</code></td> <td> <p>A <a href="DBIConnection-class.html">DBIConnection</a> object, as returned by <code><a href="dbConnect.html">dbConnect()</a></code>.</p> </td></tr> <tr valign="top"><td><code>name</code></td> <td> <p>A character string specifying the unquoted DBMS table name, or the result of a call to <code><a href="dbQuoteIdentifier.html">dbQuoteIdentifier()</a></code>.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Other parameters passed on to methods.</p> </td></tr> </table> <h3>Value</h3> <p><code>dbReadTable()</code> returns a data frame that contains the complete data from the remote table, effectively the result of calling <code><a href="dbGetQuery.html">dbGetQuery()</a></code> with <code style="white-space: pre;">SELECT * FROM <name></code>. An error is raised if the table does not exist. An empty table is returned as a data frame with zero rows. </p> <p>The presence of <a href="rownames.html">rownames</a> depends on the <code>row.names</code> argument, see <code><a href="rownames.html">sqlColumnToRownames()</a></code> for details: </p> <ul> <li><p> If <code>FALSE</code> or <code>NULL</code>, the returned data frame doesn't have row names. </p> </li> <li><p> If <code>TRUE</code>, a column named "row_names" is converted to row names, an error is raised if no such column exists. </p> </li> <li><p> If <code>NA</code>, a column named "row_names" is converted to row names if it exists, otherwise no translation occurs. </p> </li> <li><p> If a string, this specifies the name of the column in the remote table that contains the row names, an error is raised if no such column exists. </p> </li></ul> <p>The default is <code>row.names = FALSE</code>. </p> <p>If the database supports identifiers with special characters, the columns in the returned data frame are converted to valid R identifiers if the <code>check.names</code> argument is <code>TRUE</code>, otherwise non-syntactic column names can be returned unquoted. </p> <p>An error is raised when calling this method for a closed or invalid connection. An error is raised if <code>name</code> cannot be processed with <code><a href="dbQuoteIdentifier.html">dbQuoteIdentifier()</a></code> or if this results in a non-scalar. Unsupported values for <code>row.names</code> and <code>check.names</code> (non-scalars, unsupported data types, <code>NA</code> for <code>check.names</code>) also raise an error. </p> <h3>Additional arguments</h3> <p>The following arguments are not part of the <code>dbReadTable()</code> generic (to improve compatibility across backends) but are part of the DBI specification: </p> <ul> <li> <p><code>row.names</code> (default: <code>FALSE</code>) </p> </li> <li> <p><code>check.names</code> </p> </li></ul> <p>They must be provided as named arguments. See the "Value" section for details on their usage. </p> <h3>Specification</h3> <p>The <code>name</code> argument is processed as follows, to support databases that allow non-syntactic names for their objects: </p> <ul> <li><p> If an unquoted table name as string: <code>dbReadTable()</code> will do the quoting, perhaps by calling <code>dbQuoteIdentifier(conn, x = name)</code> </p> </li> <li><p> If the result of a call to <code><a href="dbQuoteIdentifier.html">dbQuoteIdentifier()</a></code>: no more quoting is done </p> </li></ul> <h3>See Also</h3> <p>Other DBIConnection generics: <code><a href="DBIConnection-class.html">DBIConnection-class</a></code>, <code><a href="dbAppendTable.html">dbAppendTable</a>()</code>, <code><a href="dbCreateTable.html">dbCreateTable</a>()</code>, <code><a href="dbDataType.html">dbDataType</a>()</code>, <code><a href="dbDisconnect.html">dbDisconnect</a>()</code>, <code><a href="dbExecute.html">dbExecute</a>()</code>, <code><a href="dbExistsTable.html">dbExistsTable</a>()</code>, <code><a href="dbGetException.html">dbGetException</a>()</code>, <code><a href="dbGetInfo.html">dbGetInfo</a>()</code>, <code><a href="dbGetQuery.html">dbGetQuery</a>()</code>, <code><a href="dbIsReadOnly.html">dbIsReadOnly</a>()</code>, <code><a href="dbIsValid.html">dbIsValid</a>()</code>, <code><a href="dbListFields.html">dbListFields</a>()</code>, <code><a href="dbListObjects.html">dbListObjects</a>()</code>, <code><a href="dbListResults.html">dbListResults</a>()</code>, <code><a href="dbListTables.html">dbListTables</a>()</code>, <code><a href="dbRemoveTable.html">dbRemoveTable</a>()</code>, <code><a href="dbSendQuery.html">dbSendQuery</a>()</code>, <code><a href="dbSendStatement.html">dbSendStatement</a>()</code>, <code><a href="dbWriteTable.html">dbWriteTable</a>()</code> </p> <h3>Examples</h3> <pre> con <- dbConnect(RSQLite::SQLite(), ":memory:") dbWriteTable(con, "mtcars", mtcars[1:10, ]) dbReadTable(con, "mtcars") dbDisconnect(con) </pre> <hr /><div style="text-align: center;">[Package <em>DBI</em> version 1.1.0 <a href="00Index.html">Index</a>]</div> </body></html>