Interface IAlterTableBuilder

All Superinterfaces:
IBaseBuilder
All Known Implementing Classes:
AlterTableBuilder, DryRunAlterTableBuilder

public interface IAlterTableBuilder extends IBaseBuilder
  • Method Details

    • renameTable

      @CheckReturnValue default IBaseBuilder renameTable(String newTableName)
      Rename a table.

      Note: This is a terminal statement.

      Note: to specify non-standard table names, use renameTable(Token) with Token.literal(String)

      Parameters:
      newTableName - the new name of the table, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
      Returns:
      this builder, but no more chaining makes sense after this statement. Remember to call IBaseBuilder.execute()
    • renameTable

      @CheckReturnValue IBaseBuilder renameTable(Token newTableName)
      Rename a table.

      Note: This is a terminal statement.

      Parameters:
      newTableName - the new name of the table
      Returns:
      this builder, but no more chaining makes sense after this statement. Remember to call IBaseBuilder.execute()
    • renameTableIfPossible

      @CheckReturnValue default IBaseBuilder renameTableIfPossible(String newTableName)
      Rename a table if no table exists with the new name.

      Note: This is a terminal statement.

      Note: to specify non-standard table names, use renameTableIfPossible(Token) with Token.literal(String)

      Parameters:
      newTableName - the new name of the table, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
      Returns:
      this builder, but no more chaining makes sense after this statement. Remember to call IBaseBuilder.execute()
    • renameTableIfPossible

      @CheckReturnValue IBaseBuilder renameTableIfPossible(Token newTableName)
      Rename a table if no table exists with the new name.

      Note: This is a terminal statement.

      Parameters:
      newTableName - the new name of the table
      Returns:
      this builder, but no more chaining makes sense after this statement. Remember to call IBaseBuilder.execute()
    • addColumn

      @CheckReturnValue default IAlterTableBuilder addColumn(String columnName, SqlType<?> columnType)
      Add a column with a specific sql type. Will fail if a column with the same name already exists. If you are adding auto-increment column it will be automatically made the new primary key.

      Note: to specify non-standard column names, use addColumn(Token, SqlType) with Token.literal(String)

      Parameters:
      columnName - the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      columnType - the type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addColumn

      @CheckReturnValue IAlterTableBuilder addColumn(Token columnName, SqlType<?> columnType)
      Add a column with a specific sql type. Will fail if a column with the same name already exists. If you are adding auto-increment column it will be automatically made the new primary key.
      Parameters:
      columnName - the name of the column
      columnType - the type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addColumn

      @CheckReturnValue default IAlterTableBuilder addColumn(String columnName, Class<?> columnType)
      Add a column with a type deduced from a java class. Will fail if a column with the same name already exists.

      Note: to specify non-standard column names, use addColumn(Token, Class) with Token.literal(String)

      Parameters:
      columnName - the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      columnType - the type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addColumn

      @CheckReturnValue default IAlterTableBuilder addColumn(Token columnName, Class<?> columnType)
      Add a column with a type deduced from a java class. Will fail if a column with the same name already exists.
      Parameters:
      columnName - the name of the column
      columnType - the type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addColumnIfNotExists

      @CheckReturnValue default IAlterTableBuilder addColumnIfNotExists(String columnName, SqlType<?> columnType)
      Add a column with a specific sql type. Does nothing if a column with the same name already exists. If you are adding auto-increment column it will be automatically made the new primary key.

      Note: to specify non-standard column names, use addColumnIfNotExists(Token, SqlType) with Token.literal(String)

      Parameters:
      columnName - the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      columnType - the type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addColumnIfNotExists

      @CheckReturnValue IAlterTableBuilder addColumnIfNotExists(Token columnName, SqlType<?> columnType)
      Add a column with a specific sql type. Does nothing if a column with the same name already exists. If you are adding auto-increment column it will be automatically made the new primary key.
      Parameters:
      columnName - the name of the column
      columnType - the type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addColumnIfNotExists

      @CheckReturnValue default IAlterTableBuilder addColumnIfNotExists(String columnName, Class<?> columnType)
      Add a column with a type deduced from a java class. Does nothing if a column with the same name already exists.

      Note: to specify non-standard column names, use addColumnIfNotExists(Token, Class) with Token.literal(String)

      Parameters:
      columnName - the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      columnType - the type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addColumnIfNotExists

      @CheckReturnValue default IAlterTableBuilder addColumnIfNotExists(Token columnName, Class<?> columnType)
      Add a column with a type deduced from a java class. Does nothing if a column with the same name already exists.
      Parameters:
      columnName - the name of the column
      columnType - the type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • renameColumn

      @CheckReturnValue default IAlterTableBuilder renameColumn(String oldColumnName, String newColumnName)
      Rename a column.

      Note: to specify non-standard column names, use renameColumn(Token, Token) with Token.literal(String)

      Parameters:
      oldColumnName - the old name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      newColumnName - the new name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • renameColumn

      @CheckReturnValue IAlterTableBuilder renameColumn(Token oldColumnName, Token newColumnName)
      Rename a column.
      Parameters:
      oldColumnName - the old name of the column
      newColumnName - the new name of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • renameColumnIfPossible

      @CheckReturnValue default IAlterTableBuilder renameColumnIfPossible(String oldColumnName, String newColumnName)
      Rename a column if it exists and no column exists with the new name.

      Note: to specify non-standard column names, use renameColumn(Token, Token) with Token.literal(String)

      Parameters:
      oldColumnName - the old name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      newColumnName - the new name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • renameColumnIfPossible

      @CheckReturnValue IAlterTableBuilder renameColumnIfPossible(Token oldColumnName, Token newColumnName)
      Rename a column if it exists and no column exists with the new name.
      Parameters:
      oldColumnName - the old name of the column
      newColumnName - the new name of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • changeColumnType

      @CheckReturnValue default IAlterTableBuilder changeColumnType(String columnName, SqlType<?> newColumnType)
      Change the type of column to a specific sql type.

      Note: to specify non-standard column names, use changeColumnType(Token, SqlType) with Token.literal(String)

      Parameters:
      columnName - the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      newColumnType - the new type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • changeColumnType

      @CheckReturnValue IAlterTableBuilder changeColumnType(Token columnName, SqlType<?> newColumnType)
      Change the type of column to a specific sql type. Auto-increment is not supported, you will have to drop the column and add a new one.
      Parameters:
      columnName - the name of the column
      newColumnType - the new type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • changeColumnType

      @CheckReturnValue default IAlterTableBuilder changeColumnType(String columnName, Class<?> newColumnType)
      Change the type of column to a type deduced from a java class.

      Note: to specify non-standard column names, use changeColumnType(Token, Class) with Token.literal(String)

      Parameters:
      columnName - the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      newColumnType - the new type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • changeColumnType

      @CheckReturnValue default IAlterTableBuilder changeColumnType(Token columnName, Class<?> newColumnType)
      Change the type of column to a type deduced from a java class.
      Parameters:
      columnName - the name of the column
      newColumnType - the new type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • changeColumnTypeIfExists

      @CheckReturnValue default IAlterTableBuilder changeColumnTypeIfExists(String columnName, SqlType<?> newColumnType)
      Change the type of column to a specific sql type, if it exists.

      Note: to specify non-standard column names, use changeColumnTypeIfExists(Token, SqlType) with Token.literal(String)

      Parameters:
      columnName - the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      newColumnType - the new type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • changeColumnTypeIfExists

      @CheckReturnValue IAlterTableBuilder changeColumnTypeIfExists(Token columnName, SqlType<?> newColumnType)
      Change the type of column to a specific sql type, if it exists. Auto-increment is not supported, you will have to drop the column and add a new one.
      Parameters:
      columnName - the name of the column
      newColumnType - the new type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • changeColumnTypeIfExists

      @CheckReturnValue default IAlterTableBuilder changeColumnTypeIfExists(String columnName, Class<?> newColumnType)
      Change the type of column to a type deduced from a java class, if it exists.

      Note: to specify non-standard column names, use changeColumnTypeIfExists(Token, Class) with Token.literal(String)

      Parameters:
      columnName - the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      newColumnType - the new type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • changeColumnTypeIfExists

      @CheckReturnValue default IAlterTableBuilder changeColumnTypeIfExists(Token columnName, Class<?> newColumnType)
      Change the type of column to a type deduced from a java class, if it exists.
      Parameters:
      columnName - the name of the column
      newColumnType - the new type of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • dropColumn

      @CheckReturnValue default IAlterTableBuilder dropColumn(String columnName)
      Drop a column. Will fail if the column does not exist.

      Note: to specify non-standard column names, use dropColumn(Token) with Token.literal(String)

      Parameters:
      columnName - the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • dropColumn

      @CheckReturnValue IAlterTableBuilder dropColumn(Token columnName)
      Drop a column. Will fail if the column does not exist.
      Parameters:
      columnName - the name of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • dropColumnIfExists

      @CheckReturnValue default IAlterTableBuilder dropColumnIfExists(String columnName)
      Drop a column if it exists.

      Note: to specify non-standard column names, use dropColumnIfExists(Token) with Token.literal(String)

      Parameters:
      columnName - the name of the column, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • dropColumnIfExists

      @CheckReturnValue IAlterTableBuilder dropColumnIfExists(Token columnName)
      Drop a column if it exists.
      Parameters:
      columnName - the name of the column
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addPrimaryKey

      @Deprecated @CheckReturnValue default IAlterTableBuilder addPrimaryKey(String firstColumn, String... columns)
      Deprecated.
      because it requires the table to not have a primary key, which is not allowed on MySQL if sql_require_primary_key is set.
      Add a primary key. If the table already has a primary key, use changePrimaryKey(String, String...).

      Note: to specify non-standard column names, use addPrimaryKey(Token, Token...) with Token.literal(String)

      Parameters:
      firstColumn - the first column of the primary key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      columns - the rest of the columns of the primary key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addPrimaryKey

      @Deprecated @CheckReturnValue IAlterTableBuilder addPrimaryKey(Token firstColumn, Token... columns)
      Deprecated.
      because it requires the table to not have a primary key, which is not allowed on MySQL if sql_require_primary_key is set.
      Add a primary key. If the table already has a primary key, use changePrimaryKey(Token, Token...).
      Parameters:
      firstColumn - the first column of the primary key
      columns - the rest of the columns of the primary key
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addForeignKey

      @CheckReturnValue default IForeignKeyBuilder<IAlterTableBuilder> addForeignKey(String constraintName, String firstColumn, String... columns)
      Add a foreign key

      Note: to specify non-standard column names, use addForeignKey(String, Token, Token...) with Token.literal(String)

      Parameters:
      constraintName - the name of the foreign key
      firstColumn - the first column of the foreign key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      columns - the rest of the columns of the foreign key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      Returns:
      foreign key builder used to specify the referenced table and column(s)
    • addForeignKey

      @CheckReturnValue default IForeignKeyBuilder<IAlterTableBuilder> addForeignKey(String constraintName, Token firstColumn, Token... columns)
      Add a foreign key
      Parameters:
      constraintName - the name of the foreign key
      firstColumn - the first column of the foreign key
      columns - the rest of the columns of the foreign key
      Returns:
      foreign key builder used to specify the referenced table and column(s)
    • addForeignKey

      @CheckReturnValue default IAlterTableBuilder addForeignKey(String constraintName, String[] columns, String referencedTable, String[] referencedColumns)
      Add a foreign key

      Note: to specify non-standard column names, use addForeignKey(String, Token, Token...) with Token.literal(String)

      Parameters:
      constraintName - the name of the foreign key
      columns - the columns of the foreign key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      referencedTable - the table referenced by the foreign key, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
      referencedColumns - the referenced columns of the foreign key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      Returns:
      foreign key builder used to specify the referenced table and column(s)
    • addForeignKey

      @CheckReturnValue IAlterTableBuilder addForeignKey(String constraintName, Token[] columns, Token referencedTable, Token[] referencedColumns)
      Add a foreign key
      Parameters:
      constraintName - the name of the foreign key
      columns - the columns of the foreign key
      referencedTable - the table referenced by the foreign key
      referencedColumns - the referenced columns of the foreign key
      Returns:
      foreign key builder used to specify the referenced table and column(s)
    • addUnique

      @CheckReturnValue default IAlterTableBuilder addUnique(String constraintName, String firstColumn, String... columns)
      Add a unique constraint

      Note: to specify non-standard column names, use addUnique(String, Token, Token...) with Token.literal(String)

      Parameters:
      constraintName - the name of the constraint
      firstColumn - the first column of the constraint, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      columns - the rest of the columns of the constraint, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addUnique

      @CheckReturnValue IAlterTableBuilder addUnique(String constraintName, Token firstColumn, Token... columns)
      Add a unique constraint
      Parameters:
      constraintName - the name of the constraint
      firstColumn - the first column of the constraint
      columns - the rest of the columns of the constraint
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addIndex

      @CheckReturnValue IAlterTableBuilder addIndex(String indexName, Token firstColumn, Token... columns)
      Add an index
      Parameters:
      indexName - the name of the index
      firstColumn - the first column of the index
      columns - the rest of the columns of the index
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • addIndex

      @CheckReturnValue default IAlterTableBuilder addIndex(String indexName, String firstColumn, String... columns)
      Add an index

      Note: to specify non-standard column names, use addIndex(String, Token, Token...) with Token.literal(String)

      Parameters:
      indexName - the name of the index
      firstColumn - the first column of the index, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      columns - the rest of the columns of the index, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • changePrimaryKey

      default IAlterTableBuilder changePrimaryKey(String firstColumn, String... columns)
      Change the primary key. Works regardless if the table already has a primary key or not.

      Note: to specify non-standard column names, use changePrimaryKey(Token, Token...) with Token.literal(String)

      Parameters:
      firstColumn - the first column of the primary key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      columns - the rest of the columns of the primary key, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • changePrimaryKey

      IAlterTableBuilder changePrimaryKey(Token firstColumn, Token... columns)
      Change the primary key. Works regardless if the table already has a primary key or not.
      Parameters:
      firstColumn - the first column of the primary key
      columns - the rest of the columns of the primary key
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • renameIndex

      @CheckReturnValue IAlterTableBuilder renameIndex(String oldIndexName, String newIndexName)
      Rename an index
      Parameters:
      oldIndexName - the old name of the index
      newIndexName - the new name of the index
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • dropPrimaryKey

      @Deprecated @CheckReturnValue IAlterTableBuilder dropPrimaryKey()
      Deprecated.
      because it will fail on MySQL if sql_require_primary_key is set.
      Drop a primary key without adding a new one. Consider using changePrimaryKey(String, String...) instead. If you are adding auto-increment column as a new primary key, do not use this method, but use changePrimaryKey(String, String...) afterwards.
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • dropPrimaryKeyIfExists

      @Deprecated @CheckReturnValue IAlterTableBuilder dropPrimaryKeyIfExists()
      Deprecated.
      because it will fail on MySQL if sql_require_primary_key is set.
      Drop a primary key if it exists, without adding a new one. Consider using changePrimaryKey(String, String...) instead. If you are adding auto-increment column as a new primary key, do not use this method, but use changePrimaryKey(String, String...) afterwards.
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • dropForeignKey

      @CheckReturnValue IAlterTableBuilder dropForeignKey(String constraintName)
      Drop a foreign key. Will fail if the foreign key does not exist.
      Parameters:
      constraintName - the name of the foreign key
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • dropUnique

      @CheckReturnValue IAlterTableBuilder dropUnique(String constraintName)
      Drop a unique constraint. Will fail if the constraint does not exist.
      Parameters:
      constraintName - the name of the constraint
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()
    • dropIndex

      @CheckReturnValue IAlterTableBuilder dropIndex(String indexName)
      Drop an index. Will fail if the index does not exist.
      Parameters:
      indexName - the name of the index
      Returns:
      this builder, for chaining. Remember to call IBaseBuilder.execute()