Class AlterTableAddColumns
java.lang.Object
com.datastax.astra.client.tables.commands.AlterTableAddColumns
- All Implemented Interfaces:
AlterTableOperation
Represents an operation to add columns to an existing table in a database schema.
This class implements the
AlterTableOperation
interface, providing functionality
to define new columns and their types for the "alter table add" operation.
Example usage:
AlterTableAddColumns operation = new AlterTableAddColumns()
.ifNotExists()
.addColumn("name", ColumnTypes.TEXT)
.addColumnInt("age")
.addColumnMap("attributes", ColumnTypes.TEXT, ColumnTypes.TEXT);
Key Features:
- Supports adding columns with various data types, including primitive, list, set, and map types.
- Chainable methods for building operations fluently.
- Ability to specify the "IF NOT EXISTS" clause to avoid errors if the column already exists.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddColumn
(String name, ColumnTypes type) Adds a column with the specified name and type to the table.addColumnBoolean
(String name) Adds a column with the BOOLEAN type.addColumnInt
(String name) Adds a column with the INT type.addColumnList
(String name, ColumnTypes valueType) Adds a column with the LIST type, where the list items are of the specified value type.addColumnMap
(String name, ColumnTypes keyType, ColumnTypes valueType) Adds a column with the MAP type, where the keys and values are of the specified types.addColumnSet
(String name, ColumnTypes valueType) Adds a column with the SET type, where the set items are of the specified value type.addColumnText
(String name) Adds a column with the TEXT type.addColumnVector
(String name, ColumnDefinitionVector cdv) Adds a column defined by aColumnDefinitionVector
.Returns the name of this operation.
-
Constructor Details
-
AlterTableAddColumns
public AlterTableAddColumns()Constructs a newAlterTableAddColumns
instance.
-
-
Method Details
-
getOperationName
Returns the name of this operation. Always returns "add" for this operation type.- Specified by:
getOperationName
in interfaceAlterTableOperation
- Returns:
- the operation name.
-
addColumn
Adds a column with the specified name and type to the table.- Parameters:
name
- the name of the column.type
- the type of the column.- Returns:
- the current instance for chaining.
-
addColumnVector
Adds a column defined by aColumnDefinitionVector
.- Parameters:
name
- the name of the column.cdv
- the column definition vector.- Returns:
- the current instance for chaining.
-
addColumnText
Adds a column with the TEXT type.- Parameters:
name
- the name of the column.- Returns:
- the current instance for chaining.
-
addColumnInt
Adds a column with the INT type.- Parameters:
name
- the name of the column.- Returns:
- the current instance for chaining.
-
addColumnBoolean
Adds a column with the BOOLEAN type.- Parameters:
name
- the name of the column.- Returns:
- the current instance for chaining.
-
addColumnList
Adds a column with the LIST type, where the list items are of the specified value type.- Parameters:
name
- the name of the column.valueType
- the type of the values in the list.- Returns:
- the current instance for chaining.
-
addColumnSet
Adds a column with the SET type, where the set items are of the specified value type.- Parameters:
name
- the name of the column.valueType
- the type of the values in the set.- Returns:
- the current instance for chaining.
-
addColumnMap
Adds a column with the MAP type, where the keys and values are of the specified types.- Parameters:
name
- the name of the column.keyType
- the type of the keys in the map.valueType
- the type of the values in the map.- Returns:
- the current instance for chaining.
-