Interface ISchemaBuilder
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
DryRunSchemaBuilder
,SchemaBuilder
-
Method Summary
Modifier and TypeMethodDescriptionAlter an existing table.default IAlterTableBuilder
Alter an existing table.alterIfExists
(Token table) Alter an existing table if it exists.default IAlterTableBuilder
alterIfExists
(String table) Alter an existing table if it exists.void
close()
boolean
columnExists
(Token table, Token column) Check if a column exists.default boolean
columnExists
(String table, String column) Check if a column exists.Create a new table.default ICreateTableBuilder
Create a new table.void
createDatabaseAndUser
(String databaseName, String username, String password) Creates a new database and user.createIfNotExists
(Token table) Create a new table if it does not already exist.default ICreateTableBuilder
createIfNotExists
(String table) Create a new table.void
Drop an existing table.default void
Drop an existing table.void
dropIfExists
(Token table) Drop an existing table if it exists.default void
dropIfExists
(String table) Drop an existing table if it exists.boolean
Check if a table exists.default boolean
Check if a table exists.
-
Method Details
-
create
Create a new table. Will fail if a table with the same name already exists.Note: remember to call
IBaseBuilder.execute()
Note: to specify non-standard table names, use
create(Token)
withToken.literal(String)
- Parameters:
table
- that will be created, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb- Returns:
- a builder that can be used to build the new table.
-
create
Create a new table. Will fail if a table with the same name already exists.Note: remember to call
IBaseBuilder.execute()
- Parameters:
table
- that will be created.- Returns:
- a builder that can be used to build the new table.
-
createIfNotExists
Create a new table. Does nothing a table with the same name already exists, no matter its contents.Note: remember to call
IBaseBuilder.execute()
Note: to specify non-standard table names, use
createIfNotExists(Token)
withToken.literal(String)
- Parameters:
table
- that will be created, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb- Returns:
- a builder that can be used to build the new table.
-
createIfNotExists
Create a new table if it does not already exist. Does nothing if a table with the same name already exists, no matter its contents.Note: remember to call
IBaseBuilder.execute()
- Parameters:
table
- that will be created if not already.- Returns:
- a builder that can be used to build the new table.
-
alter
Alter an existing table.Note: remember to call
IBaseBuilder.execute()
Note: to specify non-standard table names, use
alter(Token)
withToken.literal(String)
- Parameters:
table
- that will be altered, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb- Returns:
- a builder that can be used to alter the table.
-
alter
Alter an existing table.Note: remember to call
IBaseBuilder.execute()
- Parameters:
table
- that will be altered.- Returns:
- a builder that can be used to alter the table.
-
alterIfExists
Alter an existing table if it exists.Note: remember to call
IBaseBuilder.execute()
Note: to specify non-standard table names, use
alterIfExists(Token)
withToken.literal(String)
- Parameters:
table
- that will be altered, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb- Returns:
- a builder that can be used to alter the table.
-
alterIfExists
Alter an existing table if it exists.Note: remember to call
IBaseBuilder.execute()
- Parameters:
table
- that will be altered if it exists.- Returns:
- a builder that can be used to alter the table.
-
drop
Drop an existing table.Note: to specify non-standard table names, use
drop(Token)
withToken.literal(String)
- Parameters:
table
- that will be dropped, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
-
drop
Drop an existing table.- Parameters:
table
- that will be dropped.
-
dropIfExists
Drop an existing table if it exists.Note: to specify non-standard table names, use
dropIfExists(Token)
withToken.literal(String)
- Parameters:
table
- that will be dropped, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb
-
dropIfExists
Drop an existing table if it exists.- Parameters:
table
- that will be dropped.
-
exists
Check if a table exists.Note: to specify non-standard table names, use
exists(Token)
withToken.literal(String)
- Parameters:
table
- to be checked, will be tokenized, for example "myTable" will reference table "my_table" for MariaDb- Returns:
- true if the table exists, false otherwise
-
exists
Check if a table exists.- Parameters:
table
- to be checked- Returns:
- true if the table exists, false otherwise
-
columnExists
Check if a column exists.Note: to specify non-standard table or column names, use
columnExists(Token, Token)
- Parameters:
table
- the table to check in, will be tokenized, for example "myTable" will reference table "my_table" for MariaDbcolumn
- the column to be checked, will be tokenized, for example "myColumn" will reference column "my_column" for MariaDb- Returns:
- true if the column exists, false otherwise
-
columnExists
Check if a column exists.- Parameters:
table
- the table to check incolumn
- the column to be checked- Returns:
- true if the column exists, false otherwise
-
createDatabaseAndUser
Creates a new database and user. The user will be granted all privileges on the database.- Parameters:
databaseName
- The name of the database to createusername
- The name of the user to createpassword
- The password of the user to create
-
close
void close()- Specified by:
close
in interfaceAutoCloseable
-