CreateTableTask

Class CreateTableTask

Creates a table. If the tables exists, this task won't change the table.

Inheritance
CreateTableTask
Implements
Namespace: ETLBox.ControlFlow
Assembly: ETLBox.dll
Syntax
    public sealed class CreateTableTask : ControlFlowTask, ILoggableTask
Examples
CreateTableTask.Create("demo.table1", new List<TableColumn>() {
new TableColumn(name:"key", dataType:"int", allowNulls:false, isPrimaryKey:true, isIdentity:true),
    new TableColumn(name:"value", dataType:"nvarchar(100)", allowNulls:true)
});

Constructors

CreateTableTask()

Declaration
    public CreateTableTask()

CreateTableTask(TableDefinition)

Declaration
    public CreateTableTask(TableDefinition tableDefinition)
Parameters
TypeNameDescription
TableDefinitiontableDefinition

CreateTableTask(string, List<TableColumn>)

Declaration
    public CreateTableTask(string tableName, List<TableColumn> columns)
Parameters
TypeNameDescription
stringtableName
List<TableColumn>columns

Properties

Columns

The list of columns to create. Either use the TableDefinition or a combination of TableName and TableColumn.

Declaration
    public IList<TableColumn> Columns { get; set; }
Property Value
TypeDescription
IList<TableColumn>

DataTypeConverter

A data type converter that is used to remap the current data type names in the TableDefintion to other, database specific type names. E.g. you can remap that the type VARCHAR(8000) is created as TEXT.

Declaration
    public IDataTypeConverter DataTypeConverter { get; set; }
Property Value
TypeDescription
IDataTypeConverter

IgnoreCollation

When creating the CREATE TABLE sql, ignore the Collation definition that a TableColumn potentially has.

Declaration
    public bool IgnoreCollation { get; set; }
Property Value
TypeDescription
bool

IsTemporaryTable

If set to true, the table will be create as temp table on the database.

Declaration
    public bool IsTemporaryTable { get; set; }
Property Value
TypeDescription
bool

Sql

The sql code that is used to create the table.

Declaration
    public string Sql { get; }
Property Value
TypeDescription
string

TN

The formatted table name

Declaration
    public ObjectNameDescriptor TN { get; }
Property Value
TypeDescription
ObjectNameDescriptor

TableDefinition

The table definition for the table that should be created. Either use the TableDefinition or a combination of TableName and TableColumn.

Declaration
    public TableDefinition TableDefinition { get; set; }
Property Value
TypeDescription
TableDefinition

TableName

The name of the table to create.

Declaration
    public string TableName { get; set; }
Property Value
TypeDescription
string

Methods

Alter()

Declaration
    public void Alter()

Alter(TableDefinition)

Alters a table using ALTER TABLE statements.

Declaration
    public static void Alter(TableDefinition tableDefinition)
Parameters
TypeNameDescription
TableDefinitiontableDefinition

The definition of the table containing table name and columns.

Alter(IConnectionManager, TableDefinition)

Alters a table using ALTER TABLE statements.

Declaration
    public static void Alter(IConnectionManager connectionManager, TableDefinition tableDefinition)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager

The connection manager of the database you want to connect

TableDefinitiontableDefinition

The definition of the table containing table name and columns.

Alter(IConnectionManager, string, List<TableColumn>)

Alters a table using ALTER TABLE statements.

Declaration
    public static void Alter(IConnectionManager connectionManager, string tableName, List<TableColumn> columns)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager

The connection manager of the database you want to connect

stringtableName

The name of the table

List<TableColumn>columns

The columns of the table

Alter(string, List<TableColumn>)

Alters a table using ALTER TABLE statements.

Declaration
    public static void Alter(string tableName, List<TableColumn> columns)
Parameters
TypeNameDescription
stringtableName

The name of the table

List<TableColumn>columns

The columns of the table

AlterIfDifferent()

Execute the alter statements to change the table

Declaration
    public void AlterIfDifferent()

AlterIfNeeded(TableDefinition)

Alters a table using ALTER TABLE statements.

Declaration
    public static void AlterIfNeeded(TableDefinition tableDefinition)
Parameters
TypeNameDescription
TableDefinitiontableDefinition

The definition of the table containing table name and columns.

AlterIfNeeded(IConnectionManager, TableDefinition)

Alters a table using ALTER TABLE statements.

Declaration
    public static void AlterIfNeeded(IConnectionManager connectionManager, TableDefinition tableDefinition)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager

The connection manager of the database you want to connect

TableDefinitiontableDefinition

The definition of the table containing table name and columns.

AlterIfNeeded(IConnectionManager, string, List<TableColumn>)

Alters a table using ALTER TABLE statements.

Declaration
    public static void AlterIfNeeded(IConnectionManager connectionManager, string tableName, List<TableColumn> columns)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager

The connection manager of the database you want to connect

stringtableName

The name of the table

List<TableColumn>columns

The columns of the table

AlterIfNeeded(string, List<TableColumn>)

Alters a table using ALTER TABLE statements.

Declaration
    public static void AlterIfNeeded(string tableName, List<TableColumn> columns)
Parameters
TypeNameDescription
stringtableName

The name of the table

List<TableColumn>columns

The columns of the table

CheckTableDefinition()

Declaration
    public void CheckTableDefinition()

Create()

Executes the table creation. Throws an exception if the table exists.

Declaration
    public void Create()

Create(TableDefinition)

Creates a table using a CREATE TABLE statement. Throws an exception if the table already exists.

Declaration
    public static void Create(TableDefinition tableDefinition)
Parameters
TypeNameDescription
TableDefinitiontableDefinition

The definition of the table containing table name and columns.

Create(IConnectionManager, TableDefinition)

Creates a table using a CREATE TABLE statement. Throws an exception if the table already exists.

Declaration
    public static void Create(IConnectionManager connectionManager, TableDefinition tableDefinition)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager

The connection manager of the database you want to connect

TableDefinitiontableDefinition

The definition of the table containing table name and columns.

Create(IConnectionManager, string, List<TableColumn>)

Creates a table using a CREATE TABLE statement. Throws an exception if the table already exists.

Declaration
    public static void Create(IConnectionManager connectionManager, string tableName, List<TableColumn> columns)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager

The connection manager of the database you want to connect

stringtableName

The name of the table

List<TableColumn>columns

The columns of the table

Create(string, List<TableColumn>)

Creates a table using a CREATE TABLE statement. Throws an exception if the table already exists.

Declaration
    public static void Create(string tableName, List<TableColumn> columns)
Parameters
TypeNameDescription
stringtableName

The name of the table

List<TableColumn>columns

The columns of the table

CreateIfNotExists()

Executes the table creation if the table doesn't exist.

Declaration
    public void CreateIfNotExists()

CreateIfNotExists(TableDefinition)

Creates a table using a CREATE TABLE statement if the table doesn't exist.

Declaration
    public static void CreateIfNotExists(TableDefinition tableDefinition)
Parameters
TypeNameDescription
TableDefinitiontableDefinition

The definition of the table containing table name and columns.

CreateIfNotExists(IConnectionManager, TableDefinition)

Creates a table using a CREATE TABLE statement if the table doesn't exist.

Declaration
    public static void CreateIfNotExists(IConnectionManager connectionManager, TableDefinition tableDefinition)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager

The connection manager of the database you want to connect

TableDefinitiontableDefinition

The definition of the table containing table name and columns.

CreateIfNotExists(IConnectionManager, string, List<TableColumn>)

Creates a table using a CREATE TABLE statement if the table doesn't exist.

Declaration
    public static void CreateIfNotExists(IConnectionManager connectionManager, string tableName, List<TableColumn> columns)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager

The connection manager of the database you want to connect

stringtableName

The name of the table

List<TableColumn>columns

The columns of the table

CreateIfNotExists(string, List<TableColumn>)

Creates a table using a CREATE TABLE statement if the table doesn't exist.

Declaration
    public static void CreateIfNotExists(string tableName, List<TableColumn> columns)
Parameters
TypeNameDescription
stringtableName

The name of the table

List<TableColumn>columns

The columns of the table

CreateOrAlter()

Executes the table creation or execute the corresponding alter statements to adjust the table. If the table is empty, the new table is always dropped and recreated.

Declaration
    public void CreateOrAlter()

CreateOrAlter(TableDefinition)

Creates a table if the table doesn't exist or alters a table using ALTER TABLE statements. If the table does not contain any rows, it will be dropped and created again.

Declaration
    public static void CreateOrAlter(TableDefinition tableDefinition)
Parameters
TypeNameDescription
TableDefinitiontableDefinition

The definition of the table containing table name and columns.

CreateOrAlter(IConnectionManager, TableDefinition)

Creates a table if the table doesn't exist or alters a table using ALTER TABLE statements. If the table does not contain any rows, it will be dropped and created again.

Declaration
    public static void CreateOrAlter(IConnectionManager connectionManager, TableDefinition tableDefinition)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager

The connection manager of the database you want to connect

TableDefinitiontableDefinition

The definition of the table containing table name and columns.

CreateOrAlter(IConnectionManager, string, List<TableColumn>)

Creates a table if the table doesn't exist or alters a table using ALTER TABLE statements. If the table does not contain any rows, it will be dropped and created again.

Declaration
    public static void CreateOrAlter(IConnectionManager connectionManager, string tableName, List<TableColumn> columns)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager

The connection manager of the database you want to connect

stringtableName

The name of the table

List<TableColumn>columns

The columns of the table

CreateOrAlter(string, List<TableColumn>)

Creates a table if the table doesn't exist or alters a table using ALTER TABLE statements. If the table does not contain any rows, it will be dropped and created again.

Declaration
    public static void CreateOrAlter(string tableName, List<TableColumn> columns)
Parameters
TypeNameDescription
stringtableName

The name of the table

List<TableColumn>columns

The columns of the table

Implements