#' copy_table_structure
#' @name copy_table_structure
#' @example
#' {
#' data(mtcars2)
#' my_db <- dbR6$new()
#' my_db$add_table(mtcars, "mtcars_db")
#' my_db$copy_table_structure("mtcars_db", "mtcars_db_copy")
#' my_db$get_table("mtcars_db_copy")
#' }
#' @rdname copy_table_structure
#' @aliases copy_table_structure,dbR6
#' @exportMethod copy_table_structure
dbR6_copy_table_structure <- function(...) {
if(to %in% self$list_tables()) {
if(!overwrite) {
stop("The table ", to, " exists in the working directory. Use overwrite = TRUE to overwrite it")
} else {
self$remove_table(tabname = to)
}
}
self$send_statement(paste0("CREATE TABLE ", to, " AS SELECT * FROM ", from, " WHERE 1 = 2"))
invisible(self)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.