Class CreateTableTask
Creates a table. If the tables exists, this task won't change the table.
Implements
Inherited Members
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()
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)
});
CreateTableTask(TableDefinition)
Declaration
public CreateTableTask(TableDefinition tableDefinition)
Parameters
Type | Name | Description |
---|---|---|
TableDefinition | tableDefinition |
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)
});
CreateTableTask(string, List<TableColumn>)
Declaration
public CreateTableTask(string tableName, List<TableColumn> columns)
Parameters
Type | Name | Description |
---|---|---|
string | tableName | |
System.Collections.Generic.List<T><TableColumn> | columns |
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)
});
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
Type | Description |
---|---|
System.Collections.Generic.IList<T><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
Type | Description |
---|---|
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
Type | Description |
---|---|
bool |
Sql
The sql code that is used to create the table.
Declaration
public string Sql { get; }
Property Value
Type | Description |
---|---|
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
Type | Description |
---|---|
TableDefinition |
TableName
The name of the table to create.
Declaration
public string TableName { get; set; }
Property Value
Type | Description |
---|---|
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
Type | Description |
---|---|
string |
Overrides
TN
The formatted table name
Declaration
public ObjectNameDescriptor TN { get; }
Property Value
Type | Description |
---|---|
ObjectNameDescriptor |
Methods
Alter()
Declaration
public void Alter()
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)
});
Alter(IConnectionManager, TableDefinition)
Alters a table using ALTER TABLE statements.
Declaration
public static void Alter(IConnectionManager connectionManager, TableDefinition tableDefinition)
Parameters
Type | Name | Description |
---|---|---|
IConnectionManager | connectionManager | The connection manager of the database you want to connect |
TableDefinition | tableDefinition | 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
Type | Name | Description |
---|---|---|
IConnectionManager | connectionManager | The connection manager of the database you want to connect |
string | tableName | The name of the table |
System.Collections.Generic.List<T><TableColumn> | columns | The columns of the table |
Alter(TableDefinition)
Alters a table using ALTER TABLE statements.
Declaration
public static void Alter(TableDefinition tableDefinition)
Parameters
Type | Name | Description |
---|---|---|
TableDefinition | tableDefinition | 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
Type | Name | Description |
---|---|---|
string | tableName | The name of the table |
System.Collections.Generic.List<T><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
Type | Name | Description |
---|---|---|
IConnectionManager | connectionManager | The connection manager of the database you want to connect |
TableDefinition | tableDefinition | 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
Type | Name | Description |
---|---|---|
IConnectionManager | connectionManager | The connection manager of the database you want to connect |
string | tableName | The name of the table |
System.Collections.Generic.List<T><TableColumn> | columns | The columns of the table |
AlterIfNeeded(TableDefinition)
Alters a table using ALTER TABLE statements.
Declaration
public static void AlterIfNeeded(TableDefinition tableDefinition)
Parameters
Type | Name | Description |
---|---|---|
TableDefinition | tableDefinition | 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
Type | Name | Description |
---|---|---|
string | tableName | The name of the table |
System.Collections.Generic.List<T><TableColumn> | columns | The columns of the table |
CheckTableDefinition()
Declaration
public void CheckTableDefinition()
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)
});
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
Type | Name | Description |
---|---|---|
IConnectionManager | connectionManager | The connection manager of the database you want to connect |
TableDefinition | tableDefinition | 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
Type | Name | Description |
---|---|---|
IConnectionManager | connectionManager | The connection manager of the database you want to connect |
string | tableName | The name of the table |
System.Collections.Generic.List<T><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
Type | Name | Description |
---|---|---|
TableDefinition | tableDefinition | 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
Type | Name | Description |
---|---|---|
string | tableName | The name of the table |
System.Collections.Generic.List<T><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
Type | Name | Description |
---|---|---|
IConnectionManager | connectionManager | The connection manager of the database you want to connect |
TableDefinition | tableDefinition | 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
Type | Name | Description |
---|---|---|
IConnectionManager | connectionManager | The connection manager of the database you want to connect |
string | tableName | The name of the table |
System.Collections.Generic.List<T><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
Type | Name | Description |
---|---|---|
TableDefinition | tableDefinition | 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
Type | Name | Description |
---|---|---|
string | tableName | The name of the table |
System.Collections.Generic.List<T><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
Type | Name | Description |
---|---|---|
IConnectionManager | connectionManager | The connection manager of the database you want to connect |
TableDefinition | tableDefinition | 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
Type | Name | Description |
---|---|---|
IConnectionManager | connectionManager | The connection manager of the database you want to connect |
string | tableName | The name of the table |
System.Collections.Generic.List<T><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
Type | Name | Description |
---|---|---|
TableDefinition | tableDefinition | 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
Type | Name | Description |
---|---|---|
string | tableName | The name of the table |
System.Collections.Generic.List<T><TableColumn> | columns | The columns of the table |