Description Usage Arguments Value Examples
create table in SQLite and postgresql databases
1 2 3 |
src |
It is the connection as done by |
table |
Name if table. The function will raise error if table name already exists. |
types |
Named vector of column names and type. For |
temporary |
(default |
typeUnique |
character vector denoting the columns with only unique values allowed. |
typePK |
character vector (usually, single string) denoting the Primary Key of the table. |
typeRequired |
character vector denoting the columns which cannot be left empty. |
typeDefault |
named list with list(column1 = "defaultVal1", column2 = "defaultval2", ...) format. |
typeFK |
named list of the format list(fk_column1 = "tableName1withPK", fk_column2 = "tableName2withPK", ...) |
onUpdate |
to be used only if foreign key is defined. One of the
following options: |
onDelete |
to be used only if foreign key is defined. One of the
following options: |
Resulting SQL statement.
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## Not run:
createTable(src, table = "tbl1", types = c(id = "numeric", name =
"character(50)", address = "character(50)", age = "numeric"), temporary = F,
typeUnique = c("name", "address"), typePK = "id", typeRequired = "name",
typeDefault = list(age = 20, name = "mee"))
createTable(src, table = "tbl2", types = c(id = "numeric", fk_id =
"numeric", name = "character(50)", address = "character(50)", age =
"numeric"), temporary = F, typeUnique = "name", typePK = "id", typeRequired =
c("fk_id", "name"), typeDefault = list(age = 20), typeFK = list(fk_id =
"tbl1"), onUpdate = "setNull", onDelete = "cascade")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.