Learn R Programming

ROracle (version 1.1-5)

dbReadTable-methods: Convenience functions for manipulating DBMS tables

Description

These functions mimic their R counterpart get, assign, exists, remove, objects, and names except that they generate code that gets remotely executed in a database engine.

Arguments

conn
an OraConnection database connection object.
name
a case sensitive character string specifying a table name.
schema
a case sensitive character string specifying a schema name (or a vector of character strings for dbListTables).
all
a boolean specifying whether to look at all schemas.
full
a boolean specifying whether to generate schema names. When 'all' is set to TRUE the output is a vector containing schema names followed by the table names. One can do matrix(..., ncol = 2) on the output. This way each row of the matrix will c
value
a data.frame (or coercible to data.frame). Vectors of types logical, integer, numeric, and character are supported natively; all other vectors must be coercible to character.
row.names
in the case of dbReadTable, this argument can be a string, an index or a logical vector specifying the column in the DBMS table to be used as row.names in the output data.frame (a NULL specifies that no c
overwrite
a logical specifying whether to overwrite an existing table or not. Its default is FALSE.
append
a logical specifying whether to append to an existing table in the DBMS. Its default is FALSE.
ora.number
a logical specifying whether to create a table with NUMBER or BINARY_DOUBLE columns while writing numeric data. The default value is TRUE - create NUMBER columns.
purge
a logical specifying whether to add PURGE option to the DROP TABLE statement.
...
any optional arguments.

Value

  • A data.frame in the case of dbReadTable; a vector in the case of dbListTables and dbListFields; a logical in the case of dbExistsTable indicating whether the table exists; otherwise TRUE when the operation was successful or an exception.

References

For the Oracle Database documentaion see http://www.oracle.com/technetwork/indexes/documentation/index.html.

See Also

Oracle, dbDriver, dbConnect, dbSendQuery, dbGetQuery, fetch, dbCommit, dbGetInfo.

Examples

Run this code
con <- dbConnect(Oracle(), "scott", "tiger")
    if (dbExistsTable(con, "FOO", "SCOTT"))
      dbRemoveTable(con, "FOO")

    foo <- dbReadTable(con, "EMP")
    row.names(foo) <- foo$EMPNO
    foo <- foo[,-1]

    dbWriteTable(con, "FOO", foo, row.names = TRUE)
    dbWriteTable(con, "FOO", foo, row.names = TRUE, overwrite = TRUE)
    dbReadTable(con, "FOO", row.names = 1)

    dbGetQuery(con, "delete from foo")
    dbWriteTable(con, "FOO", foo, row.names = TRUE, append = TRUE)
    dbReadTable(con, "FOO", row.names = 1)
    dbRemoveTable(con, "FOO")

    dbListTables(con)
    dbListFields(con, "EMP")

Run the code above in your browser using DataLab