Class AlterTable
- java.lang.Object
-
- mil.nga.geopackage.db.AlterTable
-
public class AlterTable extends Object
Builds and performs alter table statements- Since:
- 3.3.0
- Author:
- osbornb
-
-
Constructor Summary
Constructors Constructor Description AlterTable()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addColumn(GeoPackageCoreConnection db, String tableName, String columnName, String columnDef)
Add a columnstatic String
addColumnSQL(String tableName, String columnName, String columnDef)
Create the add column SQLstatic <T extends UserColumn>
voidalterColumn(GeoPackageCoreConnection db, String tableName, UserCustomColumn column)
Alter a columnstatic <T extends UserColumn>
voidalterColumn(GeoPackageCoreConnection db, UserTable<T> table, T column)
Alter a columnstatic <T extends UserColumn>
voidalterColumns(GeoPackageCoreConnection db, String tableName, Collection<UserCustomColumn> columns)
Alter columnsstatic <T extends UserColumn>
voidalterColumns(GeoPackageCoreConnection db, UserTable<T> table, Collection<T> columns)
Alter columnsstatic String
alterTable(String table)
Create the ALTER TABLE SQL command prefixstatic void
alterTable(GeoPackageCoreConnection db, String sql, TableMapping tableMapping)
Alter a table with a new table SQL creation statement and table mapping.static void
alterTable(GeoPackageCoreConnection db, UserTable<? extends UserColumn> newTable)
Alter a table with a new table schema assuming a default table mapping.static void
alterTable(GeoPackageCoreConnection db, UserTable<? extends UserColumn> newTable, TableMapping tableMapping)
Alter a table with a new table schema and table mapping.static void
copyTable(GeoPackageCoreConnection db, String tableName, String newTableName)
Copy the table and row contentstatic void
copyTable(GeoPackageCoreConnection db, String tableName, String newTableName, boolean transferContent)
Copy the tablestatic void
copyTable(GeoPackageCoreConnection db, UserTable<? extends UserColumn> table, String newTableName)
Copy the table and row contentstatic void
copyTable(GeoPackageCoreConnection db, UserTable<? extends UserColumn> table, String newTableName, boolean transferContent)
Copy the tablestatic void
dropColumn(GeoPackageCoreConnection db, String tableName, String columnName)
Drop a columnstatic void
dropColumn(GeoPackageCoreConnection db, UserTable<? extends UserColumn> table, String columnName)
Drop a columnstatic void
dropColumns(GeoPackageCoreConnection db, String tableName, Collection<String> columnNames)
Drop columnsstatic void
dropColumns(GeoPackageCoreConnection db, UserTable<? extends UserColumn> table, Collection<String> columnNames)
Drop columnsstatic void
renameColumn(GeoPackageCoreConnection db, String tableName, String columnName, String newColumnName)
Rename a columnstatic String
renameColumnSQL(String tableName, String columnName, String newColumnName)
Create the rename column SQLstatic void
renameTable(GeoPackageCoreConnection db, String tableName, String newTableName)
Rename a tablestatic String
renameTableSQL(String tableName, String newTableName)
Create the rename table SQL
-
-
-
Method Detail
-
alterTable
public static String alterTable(String table)
Create the ALTER TABLE SQL command prefix- Parameters:
table
- table name- Returns:
- alter table SQL prefix
-
renameTable
public static void renameTable(GeoPackageCoreConnection db, String tableName, String newTableName)
Rename a table- Parameters:
db
- connectiontableName
- table namenewTableName
- new table name
-
renameTableSQL
public static String renameTableSQL(String tableName, String newTableName)
Create the rename table SQL- Parameters:
tableName
- table namenewTableName
- new table name- Returns:
- rename table SQL
-
renameColumn
public static void renameColumn(GeoPackageCoreConnection db, String tableName, String columnName, String newColumnName)
Rename a column- Parameters:
db
- connectiontableName
- table namecolumnName
- column namenewColumnName
- new column name
-
renameColumnSQL
public static String renameColumnSQL(String tableName, String columnName, String newColumnName)
Create the rename column SQL- Parameters:
tableName
- table namecolumnName
- column namenewColumnName
- new column name- Returns:
- rename table SQL
-
addColumn
public static void addColumn(GeoPackageCoreConnection db, String tableName, String columnName, String columnDef)
Add a column- Parameters:
db
- connectiontableName
- table namecolumnName
- column namecolumnDef
- column definition
-
addColumnSQL
public static String addColumnSQL(String tableName, String columnName, String columnDef)
Create the add column SQL- Parameters:
tableName
- table namecolumnName
- column namecolumnDef
- column definition- Returns:
- add column SQL
-
dropColumn
public static void dropColumn(GeoPackageCoreConnection db, UserTable<? extends UserColumn> table, String columnName)
Drop a column- Parameters:
db
- connectiontable
- tablecolumnName
- column name
-
dropColumns
public static void dropColumns(GeoPackageCoreConnection db, UserTable<? extends UserColumn> table, Collection<String> columnNames)
Drop columns- Parameters:
db
- connectiontable
- tablecolumnNames
- column names
-
dropColumn
public static void dropColumn(GeoPackageCoreConnection db, String tableName, String columnName)
Drop a column- Parameters:
db
- connectiontableName
- table namecolumnName
- column name
-
dropColumns
public static void dropColumns(GeoPackageCoreConnection db, String tableName, Collection<String> columnNames)
Drop columns- Parameters:
db
- connectiontableName
- table namecolumnNames
- column names
-
alterColumn
public static <T extends UserColumn> void alterColumn(GeoPackageCoreConnection db, UserTable<T> table, T column)
Alter a column- Type Parameters:
T
- user column type- Parameters:
db
- connectiontable
- tablecolumn
- column
-
alterColumns
public static <T extends UserColumn> void alterColumns(GeoPackageCoreConnection db, UserTable<T> table, Collection<T> columns)
Alter columns- Type Parameters:
T
- user column type- Parameters:
db
- connectiontable
- tablecolumns
- columns
-
alterColumn
public static <T extends UserColumn> void alterColumn(GeoPackageCoreConnection db, String tableName, UserCustomColumn column)
Alter a column- Type Parameters:
T
- user column type- Parameters:
db
- connectiontableName
- table namecolumn
- column
-
alterColumns
public static <T extends UserColumn> void alterColumns(GeoPackageCoreConnection db, String tableName, Collection<UserCustomColumn> columns)
Alter columns- Type Parameters:
T
- user column type- Parameters:
db
- connectiontableName
- table namecolumns
- columns
-
copyTable
public static void copyTable(GeoPackageCoreConnection db, UserTable<? extends UserColumn> table, String newTableName)
Copy the table and row content- Parameters:
db
- connectiontable
- tablenewTableName
- new table name
-
copyTable
public static void copyTable(GeoPackageCoreConnection db, UserTable<? extends UserColumn> table, String newTableName, boolean transferContent)
Copy the table- Parameters:
db
- connectiontable
- tablenewTableName
- new table nametransferContent
- transfer row content to the new table
-
copyTable
public static void copyTable(GeoPackageCoreConnection db, String tableName, String newTableName)
Copy the table and row content- Parameters:
db
- connectiontableName
- table namenewTableName
- new table name
-
copyTable
public static void copyTable(GeoPackageCoreConnection db, String tableName, String newTableName, boolean transferContent)
Copy the table- Parameters:
db
- connectiontableName
- table namenewTableName
- new table nametransferContent
- transfer row content to the new table
-
alterTable
public static void alterTable(GeoPackageCoreConnection db, UserTable<? extends UserColumn> newTable)
Alter a table with a new table schema assuming a default table mapping.This removes views on the table, creates a new table, transfers the old table data to the new, drops the old table, and renames the new table to the old. Indexes, triggers, and views that reference deleted columns are not recreated. An attempt is made to recreate the others including any modifications for renamed columns.
Making Other Kinds Of Table Schema Changes:
- Parameters:
db
- connectionnewTable
- new table schema
-
alterTable
public static void alterTable(GeoPackageCoreConnection db, UserTable<? extends UserColumn> newTable, TableMapping tableMapping)
Alter a table with a new table schema and table mapping.Altering a table: Removes views on the table, creates a new table, transfers the old table data to the new, drops the old table, and renames the new table to the old. Indexes, triggers, and views that reference deleted columns are not recreated. An attempt is made to recreate the others including any modifications for renamed columns.
Creating a new table: Creates a new table and transfers the table data to the new. Triggers are not created on the new table. Indexes and views that reference deleted columns are not recreated. An attempt is made to create the others on the new table.
Making Other Kinds Of Table Schema Changes:
- Parameters:
db
- connectionnewTable
- new table schematableMapping
- table mapping
-
alterTable
public static void alterTable(GeoPackageCoreConnection db, String sql, TableMapping tableMapping)
Alter a table with a new table SQL creation statement and table mapping.Altering a table: Removes views on the table, creates a new table, transfers the old table data to the new, drops the old table, and renames the new table to the old. Indexes, triggers, and views that reference deleted columns are not recreated. An attempt is made to recreate the others including any modifications for renamed columns.
Creating a new table: Creates a new table and transfers the table data to the new. Triggers are not created on the new table. Indexes and views that reference deleted columns are not recreated. An attempt is made to create the others on the new table.
Making Other Kinds Of Table Schema Changes:
- Parameters:
db
- connectionsql
- new table SQLtableMapping
- table mapping
-
-