Copy Tables to a New Database/Schema
Source: R/utils-db.R
Copies one or more tables to a new location (database/schema) by creating new tables via CREATE TABLE … AS SELECT * FROM …. Requires motherduck connection
Usage
copy_tables_to_new_location(
.con,
from_table_names,
to_database_name,
to_schema_name
)Arguments
Value
Invisibly returns a character vector of fully-qualified destination table names that were created. Side effect: creates target DB/schema if needed and writes new tables.
Details
-
Input
from_table_namesmust contain columns:database_name,schema_name, andtable_name. -
For each source table, the function issues:
CREATE TABLE <to_db>.<to_schema>.<table> AS SELECT * FROM <src_db>.<src_schema>.<table>. -
On local DuckDB (non-MotherDuck), the target database name is ignored and defaults to the current database of the connection.
See Also
Other db-manage: alter_table_schema(), create_database(), create_if_not_exists_share(), create_or_replace_share(), create_schema(), create_table(), delete_and_create_schema(), delete_database(), delete_schema(), delete_table(), describe_share(), drop_share(), list_owned_shares(), list_shared_with_me_shares(), upload_database_to_md()