public class Schema extends DbObjectBase
comment, database, trace
AGGREGATE, COMMENT, CONSTANT, CONSTRAINT, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, TABLE_OR_VIEW, TRIGGER, USER, USER_DATATYPE
Constructor and Description |
---|
Schema(Database database,
int id,
String schemaName,
User owner,
boolean system)
Create a new schema object.
|
Modifier and Type | Method and Description |
---|---|
void |
add(SchemaObject obj)
Add an object to this schema.
|
boolean |
canDrop()
Check if this schema can be dropped.
|
void |
checkRename()
Check if this object can be renamed.
|
Table |
createTable(CreateTableData data)
Add a table to the schema.
|
TableLink |
createTableLink(int id,
String tableName,
String driver,
String url,
String user,
String password,
String originalSchema,
String originalTable,
boolean emitUpdates,
boolean force)
Add a linked table to the schema.
|
Constant |
findConstant(String constantName)
Try to find a user defined constant with this name.
|
Constraint |
findConstraint(Session session,
String name)
Try to find a constraint with this name.
|
FunctionAlias |
findFunction(String functionAlias)
Try to find a user defined function with this name.
|
Index |
findIndex(Session session,
String name)
Try to find an index with this name.
|
Sequence |
findSequence(String sequenceName)
Try to find a sequence with this name.
|
Table |
findTableOrView(Session session,
String name)
Try to find a table or view with this name.
|
TriggerObject |
findTrigger(String name)
Try to find a trigger with this name.
|
void |
freeUniqueName(String name)
Release a unique object name.
|
ArrayList<SchemaObject> |
getAll()
Get all objects.
|
ArrayList<SchemaObject> |
getAll(int type)
Get all objects of the given type.
|
ArrayList<Table> |
getAllTablesAndViews()
Get all tables and views.
|
Constant |
getConstant(String constantName)
Get the user defined constant with the given name.
|
Constraint |
getConstraint(String name)
Get the constraint with the given name.
|
String |
getCreateSQL()
Build a SQL statement to re-create this object.
|
String |
getCreateSQLForCopy(Table table,
String quotedName)
Build a SQL statement to re-create the object, or to create a copy of the
object with a different name or referencing a different table
|
String |
getDropSQL()
Build a SQL statement to drop this object.
|
Index |
getIndex(String name)
Get the index with the given name.
|
User |
getOwner()
Get the owner of this schema.
|
Sequence |
getSequence(String sequenceName)
Get the sequence with the given name.
|
Table |
getTableOrView(Session session,
String name)
Get the table or view with the given name.
|
int |
getType()
Get the object type.
|
String |
getUniqueConstraintName(Session session,
Table table)
Create a unique constraint name.
|
String |
getUniqueIndexName(Session session,
Table table,
String prefix)
Create a unique index name.
|
void |
remove(SchemaObject obj)
Remove an object from this schema.
|
void |
removeChildrenAndResources(Session session)
Remove all dependent objects and free all resources (files, blocks in
files) of this object.
|
void |
rename(SchemaObject obj,
String newName)
Rename an object.
|
getChildren, getComment, getDatabase, getId, getModificationId, getName, getSQL, initDbObjectBase, invalidate, isTemporary, rename, setComment, setModified, setObjectName, setTemporary, toString
public Schema(Database database, int id, String schemaName, User owner, boolean system)
database
- the databaseid
- the object idschemaName
- the schema nameowner
- the owner of the schemasystem
- if this is a system schema (such a schema can not be
dropped)public boolean canDrop()
public String getCreateSQLForCopy(Table table, String quotedName)
DbObject
table
- the new tablequotedName
- the quoted namepublic String getDropSQL()
DbObjectBase
getDropSQL
in interface DbObject
getDropSQL
in class DbObjectBase
public String getCreateSQL()
DbObjectBase
getCreateSQL
in interface DbObject
getCreateSQL
in class DbObjectBase
public int getType()
DbObject
public void removeChildrenAndResources(Session session)
DbObjectBase
removeChildrenAndResources
in interface DbObject
removeChildrenAndResources
in class DbObjectBase
session
- the sessionpublic void checkRename()
DbObjectBase
checkRename
in interface DbObject
checkRename
in class DbObjectBase
public User getOwner()
public void add(SchemaObject obj)
obj
- the object to addpublic void rename(SchemaObject obj, String newName)
obj
- the object to renamenewName
- the new namepublic Table findTableOrView(Session session, String name)
session
- the sessionname
- the object namepublic Index findIndex(Session session, String name)
session
- the sessionname
- the object namepublic TriggerObject findTrigger(String name)
name
- the object namepublic Sequence findSequence(String sequenceName)
sequenceName
- the object namepublic Constraint findConstraint(Session session, String name)
session
- the sessionname
- the object namepublic Constant findConstant(String constantName)
constantName
- the object namepublic FunctionAlias findFunction(String functionAlias)
functionAlias
- the object namepublic void freeUniqueName(String name)
name
- the object namepublic String getUniqueConstraintName(Session session, Table table)
session
- the sessiontable
- the constraint tablepublic String getUniqueIndexName(Session session, Table table, String prefix)
session
- the sessiontable
- the indexed tableprefix
- the index name prefixpublic Table getTableOrView(Session session, String name)
session
- the sessionname
- the table or view nameDbException
- if no such object existspublic Index getIndex(String name)
name
- the index nameDbException
- if no such object existspublic Constraint getConstraint(String name)
name
- the constraint nameDbException
- if no such object existspublic Constant getConstant(String constantName)
constantName
- the constant nameDbException
- if no such object existspublic Sequence getSequence(String sequenceName)
sequenceName
- the sequence nameDbException
- if no such object existspublic ArrayList<SchemaObject> getAll()
public ArrayList<SchemaObject> getAll(int type)
type
- the object typepublic ArrayList<Table> getAllTablesAndViews()
public void remove(SchemaObject obj)
obj
- the object to removepublic Table createTable(CreateTableData data)
data
- the create table informationTable
objectpublic TableLink createTableLink(int id, String tableName, String driver, String url, String user, String password, String originalSchema, String originalTable, boolean emitUpdates, boolean force)
id
- the object idtableName
- the table name of the aliasdriver
- the driver class nameurl
- the database URLuser
- the user namepassword
- the passwordoriginalSchema
- the schema name of the target tableoriginalTable
- the table name of the target tableemitUpdates
- if updates should be emitted instead of delete/insertforce
- create the object even if the database can not be accessedTableLink
objectCopyright © 2012 JBoss by Red Hat. All Rights Reserved.