Class CreateTableTask

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

Inheritance
System.Object
CreateTableTask
Implements
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: ETLBox.ControlFlow.Tasks
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
System.StringtableName
System.Collections.Generic.List<TableColumn>columns

Properties

Columns

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

Declaration
    public List<TableColumn> Columns { get; set; }
Property Value
TypeDescription
System.Collections.Generic.List<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
System.Boolean

Sql

The sql code that is used to create the table.

Declaration
    public string Sql { get; }
Property Value
TypeDescription
System.String

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
System.String

TaskName

A name to identify the task or component. Every component or task comes with a default name that can be overwritten.

Declaration
    public override string TaskName { get; set; }
Property Value
TypeDescription
System.String
Overrides

TN

The formatted table name

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

Methods

Alter()

Declaration
    public void Alter()

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

System.StringtableName

The name of the table

System.Collections.Generic.List<TableColumn>columns

The columns of the table

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(String, List<TableColumn>)

Alters a table using ALTER TABLE statements.

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

The name of the table

System.Collections.Generic.List<TableColumn>columns

The columns of the table

AlterIfDifferent()

Execute the alter statements to change the table

Declaration
    public void AlterIfDifferent()

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

System.StringtableName

The name of the table

System.Collections.Generic.List<TableColumn>columns

The columns of the table

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(String, List<TableColumn>)

Alters a table using ALTER TABLE statements.

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

The name of the table

System.Collections.Generic.List<TableColumn>columns

The columns of the table

Create()

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

Declaration
    public void Create()

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

System.StringtableName

The name of the table

System.Collections.Generic.List<TableColumn>columns

The columns of the table

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(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
System.StringtableName

The name of the table

System.Collections.Generic.List<TableColumn>columns

The columns of the table

CreateIfNotExists()

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

Declaration
    public void CreateIfNotExists()

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

System.StringtableName

The name of the table

System.Collections.Generic.List<TableColumn>columns

The columns of the table

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(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
System.StringtableName

The name of the table

System.Collections.Generic.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(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

System.StringtableName

The name of the table

System.Collections.Generic.List<TableColumn>columns

The columns of the table

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(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
System.StringtableName

The name of the table

System.Collections.Generic.List<TableColumn>columns

The columns of the table

Implements