Conversation
| "CREATE ", if (temporary) "TEMPORARY ", "TABLE ", table, " (\n", | ||
| " ", paste(fields, collapse = ",\n "), "\n)\n" | ||
| " ", paste0(fields, nullable, collapse = ",\n "), | ||
| if (!is.null(pk)) paste0(",\n PRIMARY KEY (", paste(dbQuoteIdentifier(con, pk), collapse = ", "), ")"), |
There was a problem hiding this comment.
Pretty much, I think, but I don't know. We'll find out soon enough, we can override in backends -- this is a method.
R/table-create.R
Outdated
| #' @param temporary If `TRUE`, will generate a temporary table statement. | ||
| #' @inheritParams rownames | ||
| #' @param ... Other arguments used by individual methods. | ||
| #' @param pk Primary key columns. |
There was a problem hiding this comment.
This seems too short compared to other argument names
There was a problem hiding this comment.
primary.key? I'm not sure this package already uses underscores for argument names :-\
Co-authored-by: Hadley Wickham <h.wickham@gmail.com>
|
As I understand it, DBI tries to be SQL 99 compliant. If so, I believe the standard syntax is in fact CREATE TABLE {tableName} (
{column Definitions},
CONSTRAINT {PK_Name} PRIMARY KEY ({column Names})
) Per W3Schools, the |
|
I was looking for a way to add a primary key when using |
|
@vnijs: The dm package supports this via |
|
@krlmlr |
This is important, because it is difficult and computationally intensive (and sometimes impossible) to change the primary key after creating the table.
Should we also support foreign keys and unique constraints?
This is a blocker for cynkra/dm#3. We would also need to adapt
dbplyr::copy_to()and perhapsdbplyr::compute().