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 - SQLExceptionvoid createIndex(String indexName, String tableName, String... columnNames) throws SQLException
indexName - tableName - columnNames - SQLExceptionvoid addFKConstraint(String tableName, String constraintName, String keyColumn, String referenceTableName, String referenceColumn, boolean ignoreFailure) throws SQLException
tableName - constraintName - keyColumn - referenceColumn - SQLExceptionvoid addFKConstraint(String tableName, String constraintName, String[] keyColumns, String referenceTableName, String[] referenceColumns, boolean ignoreFailure) throws SQLException
tableName - constraintName - keyColumn - referenceColumn - SQLExceptionvoid addColumn(String tableName, DBAccessor.DBColumnInfo columnInfo) throws SQLException
tableName - columnInfo - SQLExceptionvoid renameColumn(String tableName, String oldColumnName, DBAccessor.DBColumnInfo columnInfo) throws SQLException
tableName - oldColumnName - columnInfo - SQLExceptionvoid 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 - SQLExceptionboolean insertRow(String tableName, String[] columnNames, String[] values, boolean ignoreFailure) throws SQLException
tableName - columnNames - values - ignoreFailure - SQLExceptionint updateTable(String tableName, String columnName, Object value, String whereClause) throws SQLException
tableName - columnName - value - whereClause - SQLExceptionvoid executeScript(String filePath) throws SQLException, IOException
filePath - SQLExceptionIOExceptionvoid executeQuery(String query) throws SQLException
query - SQLExceptionResultSet executeSelect(String query) throws SQLException
query - SQLExceptionvoid executeQuery(String query, boolean ignoreFailure) throws SQLException
query - ignoreFailure - SQLExceptionvoid dropTable(String tableName) throws SQLException
tableName - SQLExceptionvoid truncateTable(String tableName) throws SQLException
tableName - SQLExceptionvoid dropColumn(String tableName, String columnName) throws SQLException
tableName - columnName - SQLExceptionvoid dropSequence(String sequenceName) throws SQLException
sequenceName - SQLExceptionvoid dropConstraint(String tableName, String constraintName) throws SQLException
tableName - constraintName - SQLExceptionvoid dropConstraint(String tableName, String constraintName, boolean ignoreFailure) throws SQLException
tableName - constraintName - SQLExceptionboolean tableExists(String tableName) throws SQLException
tableName - SQLExceptionboolean tableHasData(String tableName) throws SQLException
tableName - SQLExceptionboolean tableHasColumn(String tableName, String columnName) throws SQLException
tableName - columnName - SQLExceptionboolean tableHasForeignKey(String tableName, String fkName) throws SQLException
tableName - fkName - SQLExceptionboolean tableHasForeignKey(String tableName, String refTableName, String columnName, String refColumnName) throws SQLException
tableName - refTableName - columnName - refColumnName - SQLExceptionboolean tableHasForeignKey(String tableName, String referenceTableName, String[] keyColumns, String[] referenceColumns) throws SQLException
tableName - referenceTableName - keyColumns - referenceColumns - SQLExceptionorg.eclipse.persistence.sessions.DatabaseSession getNewDatabaseSession()
Copyright © 2016. All rights reserved.