-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathdbCreateTable.Rd
More file actions
87 lines (78 loc) · 2.7 KB
/
Copy pathdbCreateTable.Rd
File metadata and controls
87 lines (78 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/table-create.R
\name{dbCreateTable}
\alias{dbCreateTable}
\title{Create a table in the database}
\usage{
dbCreateTable(
conn,
name,
fields,
...,
row.names = NULL,
temporary = FALSE,
pk = NULL
)
}
\arguments{
\item{conn}{A \linkS4class{DBIConnection} object, as returned by
\code{\link[=dbConnect]{dbConnect()}}.}
\item{name}{Name of the table, escaped with \code{\link[=dbQuoteIdentifier]{dbQuoteIdentifier()}}.}
\item{fields}{Either a character vector or a data frame.
A named character vector: Names are column names, values are types.
Names are escaped with \code{\link[=dbQuoteIdentifier]{dbQuoteIdentifier()}}.
Field types are unescaped.
A data frame: field types are generated using
\code{\link[=dbDataType]{dbDataType()}}.}
\item{...}{Other arguments used by individual methods.}
\item{row.names}{Must be \code{NULL}.}
\item{temporary}{If \code{TRUE}, will generate a temporary table statement.}
\item{pk}{Primary key columns.
For some DBMS this must be specified at creation time.
Even if not strictly necessary, it may save substantial processing time later on.
This argument is processed with \code{\link[=dbQuoteIdentifier]{dbQuoteIdentifier()}}.}
}
\description{
The default \code{dbCreateTable()} method calls \code{\link[=sqlCreateTable]{sqlCreateTable()}} and
\code{\link[=dbExecute]{dbExecute()}}.
Backends compliant to ANSI SQL 99 don't need to override it.
Backends with a different SQL syntax can override \code{sqlCreateTable()},
backends with entirely different ways to create tables need to
override this method.
}
\details{
The \code{row.names} argument is not supported by this method.
Process the values with \code{\link[=sqlRownamesToColumn]{sqlRownamesToColumn()}} before calling this method.
The argument order is different from the \code{sqlCreateTable()} method, the
latter will be adapted in a later release of DBI.
}
\examples{
con <- dbConnect(RSQLite::SQLite(), ":memory:")
dbCreateTable(con, "iris", iris)
dbReadTable(con, "iris")
dbDisconnect(con)
}
\seealso{
Other DBIConnection generics:
\code{\link{DBIConnection-class}},
\code{\link{dbAppendTable}()},
\code{\link{dbDataType}()},
\code{\link{dbDisconnect}()},
\code{\link{dbExecute}()},
\code{\link{dbExistsTable}()},
\code{\link{dbGetException}()},
\code{\link{dbGetInfo}()},
\code{\link{dbGetQuery}()},
\code{\link{dbIsReadOnly}()},
\code{\link{dbIsValid}()},
\code{\link{dbListFields}()},
\code{\link{dbListObjects}()},
\code{\link{dbListResults}()},
\code{\link{dbListTables}()},
\code{\link{dbReadTable}()},
\code{\link{dbRemoveTable}()},
\code{\link{dbSendQuery}()},
\code{\link{dbSendStatement}()},
\code{\link{dbWriteTable}()}
}
\concept{DBIConnection generics}