Package com.gengoai.sql.statement
Class AlterTable
- java.lang.Object
-
- com.gengoai.sql.statement.AlterTable
-
- All Implemented Interfaces:
SQLElement
,UpdateStatement
,Serializable
public class AlterTable extends Object implements UpdateStatement
Defines an SQL Alter Table statement to alter the definition of a table. The alter statement is made up of one or more
AlterTableAction
s that define the action to perform to alter the table. Note that some RDBMS (e.g. SQLite) only allow one action per alter statement. Furthermore, not all RDBMS support allAlterTableAction
.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AlterTable
action(@NonNull AlterTableAction action)
Adds an action to the statement.AlterTable
addColumn(@NonNull Column column)
Adds anAlterTableAction.AddColumn
action which will add the givenColumn
to the table.AlterTable
alterColumn(@NonNull Column column)
Adds an alter column action which updates the column based on the given column definition.AlterTable
dropColumn(String name)
Adds a drop column action to drop the column with the given nameAlterTable
renameColumn(String oldName, String newName)
Adds a rename column action to rename theold name
column tonew name
AlterTable
renameTable(String newName)
Adds a rename table action to rename the table tonew name
static AlterTable
table(@NonNull SQLElement table)
Static method for constructing an AlterTable statement given the table being altered.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.gengoai.sql.SQLElement
getClassName
-
-
-
-
Method Detail
-
table
public static AlterTable table(@NonNull @NonNull SQLElement table)
Static method for constructing an AlterTable statement given the table being altered.- Parameters:
table
- the table- Returns:
- the AlterTable statement
-
action
public AlterTable action(@NonNull @NonNull AlterTableAction action)
Adds an action to the statement.- Parameters:
action
- the action- Returns:
- the AlterTable statement
-
addColumn
public AlterTable addColumn(@NonNull @NonNull Column column)
Adds anAlterTableAction.AddColumn
action which will add the givenColumn
to the table.- Parameters:
column
- the column to add- Returns:
- the AlterTable statement
-
alterColumn
public AlterTable alterColumn(@NonNull @NonNull Column column)
Adds an alter column action which updates the column based on the given column definition.- Parameters:
column
- the column with new a definition- Returns:
- the AlterTable statement
-
dropColumn
public AlterTable dropColumn(String name)
Adds a drop column action to drop the column with the given name- Parameters:
name
- the name of the column to drop- Returns:
- the AlterTable statement
-
renameColumn
public AlterTable renameColumn(String oldName, String newName)
Adds a rename column action to rename theold name
column tonew name
- Parameters:
oldName
- the old name of the columnnewName
- the new name of the column- Returns:
- the AlterTable statement
-
renameTable
public AlterTable renameTable(String newName)
Adds a rename table action to rename the table tonew name
- Parameters:
newName
- the new name of the table- Returns:
- the AlterTable statement
-
-