Schema

A schema as created by the SQL statement CREATE SCHEMA

Methods
Schema(Database database, int id, String schemaName, User owner, boolean system)
Create a new schema object.
Schema(Database database, int id, String schemaName, User owner, boolean system)
Create a new schema object.
Parameters:
database - the database
id - the object id
schemaName - the schema name
owner - the owner of the schema
system - if this is a system schema (such a schema can not be dropped)
void add(SchemaObject obj)
Add an object to this schema.
void add(SchemaObject obj)
Add an object to this schema. This method must not be called within CreateSchemaObject; use Database.addSchemaObject() instead
Parameters:
obj - the object to add
boolean canDrop()
Check if this schema can be dropped.
boolean canDrop()
Check if this schema can be dropped. System schemas can not be dropped.
Returns:
true if it can be dropped
void checkRename()
void checkRename()
TableSynonym createSynonym(CreateSynonymData data)
Add a table synonym to the schema.
TableSynonym createSynonym(CreateSynonymData data)
Add a table synonym to the schema.
Parameters:
data - the create synonym information
Returns:
the created {@link TableSynonym} object
Table createTable(CreateTableData data)
Add a table to the schema.
Table createTable(CreateTableData data)
Add a table to the schema.
Parameters:
data - the create table information
Returns:
the created {@link Table} object
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.
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.
Parameters:
id - the object id
tableName - the table name of the alias
driver - the driver class name
url - the database URL
user - the user name
password - the password
originalSchema - the schema name of the target table
originalTable - the table name of the target table
emitUpdates - if updates should be emitted instead of delete/insert
force - create the object even if the database can not be accessed
Returns:
the {@link TableLink} object
Constant findConstant(String constantName)
Try to find a user defined constant with this name.
Constant findConstant(String constantName)
Try to find a user defined constant with this name. This method returns null if no object with this name exists.
Parameters:
constantName - the object name
Returns:
the object or null
Constraint findConstraint(Session session, String name)
Try to find a constraint with this name.
Constraint findConstraint(Session session, String name)
Try to find a constraint with this name. This method returns null if no object with this name exists.
Parameters:
session - the session
name - the object name
Returns:
the object or null
FunctionAlias findFunction(String functionAlias)
Try to find a user defined function with this name.
FunctionAlias findFunction(String functionAlias)
Try to find a user defined function with this name. This method returns null if no object with this name exists.
Parameters:
functionAlias - the object name
Returns:
the object or null
Index findIndex(Session session, String name)
Try to find an index with this name.
Index findIndex(Session session, String name)
Try to find an index with this name. This method returns null if no object with this name exists.
Parameters:
session - the session
name - the object name
Returns:
the object or null
Sequence findSequence(String sequenceName)
Try to find a sequence with this name.
Sequence findSequence(String sequenceName)
Try to find a sequence with this name. This method returns null if no object with this name exists.
Parameters:
sequenceName - the object name
Returns:
the object or null
Table findTableOrView(Session session, String name)
Try to find a table or view with this name.
Table findTableOrView(Session session, String name)
Try to find a table or view with this name. This method returns null if no object with this name exists. Local temporary tables are also returned. Synonyms are not returned or resolved.
Parameters:
session - the session
name - the object name
Returns:
the object or null
TriggerObject findTrigger(String name)
Try to find a trigger with this name.
TriggerObject findTrigger(String name)
Try to find a trigger with this name. This method returns null if no object with this name exists.
Parameters:
name - the object name
Returns:
the object or null
void freeUniqueName(String name)
Release a unique object name.
void freeUniqueName(String name)
Release a unique object name.
Parameters:
name - the object name
ArrayList getAll()
Get all objects.
ArrayList getAll()
Get all objects.
Returns:
a (possible empty) list of all objects
ArrayList getAll(int type)
Get all objects of the given type.
ArrayList getAll(int type)
Get all objects of the given type.
Parameters:
type - the object type
Returns:
a (possible empty) list of all objects
ArrayList getAllSynonyms()
ArrayList getAllSynonyms()
ArrayList getAllTablesAndViews()
Get all tables and views.
ArrayList getAllTablesAndViews()
Get all tables and views.
Returns:
a (possible empty) list of all objects
Constant getConstant(String constantName)
Get the user defined constant with the given name.
Constant getConstant(String constantName)
Get the user defined constant with the given name.
Parameters:
constantName - the constant name
Returns:
the constant
Throws:
DbException - if no such object exists
Constraint getConstraint(String name)
Get the constraint with the given name.
Constraint getConstraint(String name)
Get the constraint with the given name.
Parameters:
name - the constraint name
Returns:
the constraint
Throws:
DbException - if no such object exists
String getCreateSQL()
String getCreateSQL()
String getCreateSQLForCopy(Table table, String quotedName)
String getCreateSQLForCopy(Table table, String quotedName)
String getDropSQL()
String getDropSQL()
Index getIndex(String name)
Get the index with the given name.
Index getIndex(String name)
Get the index with the given name.
Parameters:
name - the index name
Returns:
the index
Throws:
DbException - if no such object exists
User getOwner()
Get the owner of this schema.
User getOwner()
Get the owner of this schema.
Returns:
the owner
Sequence getSequence(String sequenceName)
Get the sequence with the given name.
Sequence getSequence(String sequenceName)
Get the sequence with the given name.
Parameters:
sequenceName - the sequence name
Returns:
the sequence
Throws:
DbException - if no such object exists
TableSynonym getSynonym(String name)
Try to find a synonym with this name.
TableSynonym getSynonym(String name)
Try to find a synonym with this name. This method returns null if no object with this name exists.
Parameters:
name - the object name
Returns:
the object or null
ArrayList getTableEngineParams()
Get table engine params of this schema.
ArrayList getTableEngineParams()
Get table engine params of this schema.
Returns:
default table engine params
Table getTableOrView(Session session, String name)
Get the table or view with the given name.
Table getTableOrView(Session session, String name)
Get the table or view with the given name. Local temporary tables are also returned.
Parameters:
session - the session
name - the table or view name
Returns:
the table or view
Throws:
DbException - if no such object exists
Table getTableOrViewByName(String name)
Get the table with the given name, if any.
Table getTableOrViewByName(String name)
Get the table with the given name, if any.
Parameters:
name - the table name
Returns:
the table or null if not found
int getType()
int getType()
String getUniqueConstraintName(Session session, Table table)
Create a unique constraint name.
String getUniqueConstraintName(Session session, Table table)
Create a unique constraint name.
Parameters:
session - the session
table - the constraint table
Returns:
the unique name
String getUniqueIndexName(Session session, Table table, String prefix)
Create a unique index name.
String getUniqueIndexName(Session session, Table table, String prefix)
Create a unique index name.
Parameters:
session - the session
table - the indexed table
prefix - the index name prefix
Returns:
the unique name
boolean isEmpty()
Return whether is this schema is empty (does not contain any objects).
boolean isEmpty()
Return whether is this schema is empty (does not contain any objects).
Returns:
{@code true} if this schema is empty, {@code false} otherwise
void remove(SchemaObject obj)
Remove an object from this schema.
void remove(SchemaObject obj)
Remove an object from this schema.
Parameters:
obj - the object to remove
void removeChildrenAndResources(Session session)
void removeChildrenAndResources(Session session)
void rename(SchemaObject obj, String newName)
Rename an object.
void rename(SchemaObject obj, String newName)
Rename an object.
Parameters:
obj - the object to rename
newName - the new name
Table resolveTableOrView(Session session, String name)
Try to find a table or view with this name.
Table resolveTableOrView(Session session, String name)
Try to find a table or view with this name. This method returns null if no object with this name exists. Local temporary tables are also returned. If a synonym with this name exists, the backing table of the synonym is returned
Parameters:
session - the session
name - the object name
Returns:
the object or null
void setTableEngineParams(ArrayList tableEngineParams)
Set table engine params of this schema.
void setTableEngineParams(ArrayList tableEngineParams)
Set table engine params of this schema.
Parameters:
tableEngineParams - default table engine params