Skip to main content

DB_Table.select_into_database_table

select_into_database_tableconnectiontable_name primary_keytemporaryon_problems

Group: Output

Documentation

Creates a new database table from this table.

Arguments

  • connection: the database connection to use. The table will be created in the database and schema associated with this connection.
  • table_name: the name of the table to create.
  • primary_key: the names of the columns to use as the primary key. The first column from the table is used by default. If it is set to Nothing or an empty vector, no primary key will be created.
  • temporary: if set to True, the table will be temporary, meaning that it will be dropped once the connection is closed. Defaults to False.
  • on_problems: the behavior to use when encountering non-fatal problems. Defaults to reporting them as warning.

Errors

  • If a table with the given name already exists, then a Table_Already_Exists error is raised.
  • If a column type is not supported and is coerced to a similar supported type, an Inexact_Type_Coercion problem is reported according to the on_problems setting.
  • If a column type is not supported and there is no replacement (e.g. native Enso types), an Unsupported_Type error is raised.
  • If the provided primary key columns are not present in the source table, Missing_Input_Columns error is raised.
  • If the selected primary key columns are not unique, a Non_Unique_Key error is raised.
  • An SQL_Error may be reported if there is a failure on the database side.

If an error has been raised, the table is not created (that may not always apply to SQL_Error).

Remarks

Dry Run if Output disabled

If performing output actions is disabled, only a dry run is performed and no permanent changes occur. The operation checks for errors like missing columns, and returns a temporary table containing a sample of the input with a Dry_Run_Operation warning attached.

More expensive checks, like clashing keys are checked only on the sample of rows, so errors may still occur when the output action is enabled.