public interface DBAccessor
Modifier and Type | Interface and Description |
---|---|
static class |
DBAccessor.DBColumnInfo
Capture column type
|
Modifier and Type | Method and Description |
---|---|
void |
addColumn(String tableName,
DBAccessor.DBColumnInfo columnInfo)
Add column to existing table
|
void |
addFKConstraint(String tableName,
String constraintName,
String[] keyColumns,
String referenceTableName,
String[] referenceColumns,
boolean ignoreFailure)
Add foreign key for a relation
|
void |
addFKConstraint(String tableName,
String constraintName,
String keyColumn,
String referenceTableName,
String referenceColumn,
boolean ignoreFailure)
Add foreign key for a relation
|
void |
alterColumn(String tableName,
DBAccessor.DBColumnInfo columnInfo)
Alter column from existing table, only supports varchar extension
Use following sequence for more complex stuff: addColumn(String, org.apache.ambari.server.orm.DBAccessor.DBColumnInfo)
updateTable(String, String, Object, String)
dropColumn(String, String)
renameColumn(String, String, org.apache.ambari.server.orm.DBAccessor.DBColumnInfo) |
void |
createIndex(String indexName,
String tableName,
String... columnNames)
Create new index
|
void |
createTable(String tableName,
List<DBAccessor.DBColumnInfo> columnInfo,
String... primaryKeyColumns)
Create new table
|
void |
dropColumn(String tableName,
String columnName)
Drop a column from table
|
void |
dropConstraint(String tableName,
String constraintName)
Drop a constraint from table
|
void |
dropConstraint(String tableName,
String constraintName,
boolean ignoreFailure)
Drop a constraint from table
|
void |
dropSequence(String sequenceName)
Drop sequence
|
void |
dropTable(String tableName)
Drop table from schema
|
void |
executeQuery(String query)
Execute ad-hoc query on DB.
|
void |
executeQuery(String query,
boolean ignoreFailure)
Execute query on DB
|
void |
executeScript(String filePath)
Helper method to run third party scripts like Quartz DDL
|
ResultSet |
executeSelect(String query)
Execute select query
|
org.eclipse.persistence.sessions.DatabaseSession |
getNewDatabaseSession()
Get a new DB session
|
boolean |
insertRow(String tableName,
String[] columnNames,
String[] values,
boolean ignoreFailure)
Insert row into table
|
void |
renameColumn(String tableName,
String oldColumnName,
DBAccessor.DBColumnInfo columnInfo)
Rename existing column
|
boolean |
tableExists(String tableName)
Verify if table exists by looking at metadata.
|
boolean |
tableHasColumn(String tableName,
String columnName)
Verify if table already has a column defined.
|
boolean |
tableHasData(String tableName)
Verify if table has any data
|
boolean |
tableHasForeignKey(String tableName,
String fkName)
Verify if table has a FK constraint.
|
boolean |
tableHasForeignKey(String tableName,
String referenceTableName,
String[] keyColumns,
String[] referenceColumns)
Verify if table already has a FK constraint.
|
boolean |
tableHasForeignKey(String tableName,
String refTableName,
String columnName,
String refColumnName)
Verify if table already has a FK constraint.
|
void |
truncateTable(String tableName)
Delete all table data
|
int |
updateTable(String tableName,
String columnName,
Object value,
String whereClause)
Simple update operation on table
|
void createTable(String tableName, List<DBAccessor.DBColumnInfo> columnInfo, String... primaryKeyColumns) throws SQLException
tableName
- columnInfo
- primaryKeyColumns
- SQLException
void createIndex(String indexName, String tableName, String... columnNames) throws SQLException
indexName
- tableName
- columnNames
- SQLException
void addFKConstraint(String tableName, String constraintName, String keyColumn, String referenceTableName, String referenceColumn, boolean ignoreFailure) throws SQLException
tableName
- constraintName
- keyColumn
- referenceColumn
- SQLException
void addFKConstraint(String tableName, String constraintName, String[] keyColumns, String referenceTableName, String[] referenceColumns, boolean ignoreFailure) throws SQLException
tableName
- constraintName
- keyColumn
- referenceColumn
- SQLException
void addColumn(String tableName, DBAccessor.DBColumnInfo columnInfo) throws SQLException
tableName
- columnInfo
- SQLException
void renameColumn(String tableName, String oldColumnName, DBAccessor.DBColumnInfo columnInfo) throws SQLException
tableName
- oldColumnName
- columnInfo
- SQLException
void alterColumn(String tableName, DBAccessor.DBColumnInfo columnInfo) throws SQLException
addColumn(String, org.apache.ambari.server.orm.DBAccessor.DBColumnInfo)
updateTable(String, String, Object, String)
dropColumn(String, String)
renameColumn(String, String, org.apache.ambari.server.orm.DBAccessor.DBColumnInfo)
tableName
- columnInfo
- SQLException
boolean insertRow(String tableName, String[] columnNames, String[] values, boolean ignoreFailure) throws SQLException
tableName
- columnNames
- values
- ignoreFailure
- SQLException
int updateTable(String tableName, String columnName, Object value, String whereClause) throws SQLException
tableName
- columnName
- value
- whereClause
- SQLException
void executeScript(String filePath) throws SQLException, IOException
filePath
- SQLException
IOException
void executeQuery(String query) throws SQLException
query
- SQLException
ResultSet executeSelect(String query) throws SQLException
query
- SQLException
void executeQuery(String query, boolean ignoreFailure) throws SQLException
query
- ignoreFailure
- SQLException
void dropTable(String tableName) throws SQLException
tableName
- SQLException
void truncateTable(String tableName) throws SQLException
tableName
- SQLException
void dropColumn(String tableName, String columnName) throws SQLException
tableName
- columnName
- SQLException
void dropSequence(String sequenceName) throws SQLException
sequenceName
- SQLException
void dropConstraint(String tableName, String constraintName) throws SQLException
tableName
- constraintName
- SQLException
void dropConstraint(String tableName, String constraintName, boolean ignoreFailure) throws SQLException
tableName
- constraintName
- SQLException
boolean tableExists(String tableName) throws SQLException
tableName
- SQLException
boolean tableHasData(String tableName) throws SQLException
tableName
- SQLException
boolean tableHasColumn(String tableName, String columnName) throws SQLException
tableName
- columnName
- SQLException
boolean tableHasForeignKey(String tableName, String fkName) throws SQLException
tableName
- fkName
- SQLException
boolean tableHasForeignKey(String tableName, String refTableName, String columnName, String refColumnName) throws SQLException
tableName
- refTableName
- columnName
- refColumnName
- SQLException
boolean tableHasForeignKey(String tableName, String referenceTableName, String[] keyColumns, String[] referenceColumns) throws SQLException
tableName
- referenceTableName
- keyColumns
- referenceColumns
- SQLException
org.eclipse.persistence.sessions.DatabaseSession getNewDatabaseSession()
Copyright © 2016. All rights reserved.