## org.h2.schema
Class Schema

    java.lang.Object
      org.h2.engine.DbObjectBase
          org.h2.schema.Schema

All Implemented Interfaces:
  DbObject

    public class Schema

extends DbObjectBase

A schema as created by the SQL statement CREATE SCHEMA

Field Summary

Fields inherited from class org.h2.engine.DbObjectBase
`comment, database, trace`

Fields inherited from interface org.h2.engine.DbObject
`AGGREGATE, COMMENT, CONSTANT, CONSTRAINT, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, TABLE_OR_VIEW, TRIGGER, USER, USER_DATATYPE`

Constructor Summary
`Schema(Database database, int id, java.lang.String schemaName, User owner, boolean system)` Create a new schema object.

Method Summary
`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, java.lang.String tableName, java.lang.String driver, java.lang.String url, java.lang.String user, java.lang.String password, java.lang.String originalSchema, java.lang.String originalTable, boolean emitUpdates, boolean force)` Add a linked table to the schema.
`Constant` `findConstant(java.lang.String constantName)` Try to find a user defined constant with this name.
`Constraint` `findConstraint(Session session, java.lang.String name)` Try to find a constraint with this name.
`Index` `findIndex(Session session, java.lang.String name)` Try to find an index with this name.
`Sequence` `findSequence(java.lang.String sequenceName)` Try to find a sequence with this name.
`Table` `findTableOrView(Session session, java.lang.String name)` Try to find a table or view with this name.
`TriggerObject` `findTrigger(java.lang.String name)` Try to find a trigger with this name.
`void` `freeUniqueName(java.lang.String name)` Release a unique object name.
`java.util.ArrayList<SchemaObject>` `getAll(int type)` Get all objects of the given type.
`java.util.ArrayList<Table>` `getAllTablesAndViews()` Get all tables and views.
`Constant` `getConstant(java.lang.String constantName)` Get the user defined constant with the given name.
`Constraint` `getConstraint(java.lang.String name)` Get the constraint with the given name.
`java.lang.String` `getCreateSQL()` Build a SQL statement to re-create this object.
`java.lang.String` `getCreateSQLForCopy(Table table, java.lang.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
`java.lang.String` `getDropSQL()` Build a SQL statement to drop this object.
`Index` `getIndex(java.lang.String name)` Get the index with the given name.
`User` `getOwner()` Get the owner of this schema.
`Sequence` `getSequence(java.lang.String sequenceName)` Get the sequence with the given name.
`Table` `getTableOrView(Session session, java.lang.String name)` Get the table or view with the given name.
`int` `getType()` Get the object type.
`java.lang.String` `getUniqueConstraintName(Session session, Table table)` Create a unique constraint name.
`java.lang.String` `getUniqueIndexName(Session session, Table table, java.lang.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, java.lang.String newName)` Rename an object.

Methods inherited from class org.h2.engine.DbObjectBase
`getChildren, getComment, getDatabase, getId, getModificationId, getName, getSQL, initDbObjectBase, invalidate, isTemporary, rename, setComment, setModified, setObjectName, setTemporary, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Schema

    public Schema(Database database,
                  int id,
                  java.lang.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)

Method Detail

### canDrop

    public boolean canDrop()

  Check if this schema can be dropped. System schemas can not be dropped.

  Returns:
    true if it can be dropped

### getCreateSQLForCopy

    public java.lang.String getCreateSQLForCopy(Table table,
                                                java.lang.String quotedName)

  Description copied from class: `DbObjectBase`
  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

  Specified by:
    `getCreateSQLForCopy` in interface `DbObject`
  Specified by:
    `getCreateSQLForCopy` in class `DbObjectBase`
  Parameters:
    `table` - the new table name
    `quotedName` - the new quoted name
  Returns:
    the SQL statement

### getDropSQL

    public java.lang.String getDropSQL()

  Description copied from class: `DbObjectBase`
  Build a SQL statement to drop this object.

  Specified by:
    `getDropSQL` in interface `DbObject`
  Specified by:
    `getDropSQL` in class `DbObjectBase`
  Returns:
    the SQL statement

### getCreateSQL

    public java.lang.String getCreateSQL()

  Description copied from class: `DbObjectBase`
  Build a SQL statement to re-create this object.

  Specified by:
    `getCreateSQL` in interface `DbObject`
  Specified by:
    `getCreateSQL` in class `DbObjectBase`
  Returns:
    the SQL statement

### getType

    public int getType()

  Description copied from class: `DbObjectBase`
  Get the object type.

  Specified by:
    `getType` in interface `DbObject`
  Specified by:
    `getType` in class `DbObjectBase`
  Returns:
    the object type

### removeChildrenAndResources

    public void removeChildrenAndResources(Session session)

  Description copied from class: `DbObjectBase`
  Remove all dependent objects and free all resources (files, blocks in files) of this object.

  Specified by:
    `removeChildrenAndResources` in interface `DbObject`
  Specified by:
    `removeChildrenAndResources` in class `DbObjectBase`
  Parameters:
    `session` - the session

### checkRename

    public void checkRename()

  Description copied from class: `DbObjectBase`
  Check if this object can be renamed. System objects may not be renamed.

  Specified by:
    `checkRename` in interface `DbObject`
  Specified by:
    `checkRename` in class `DbObjectBase`

### getOwner

    public User getOwner()

  Get the owner of this schema.

  Returns:
    the owner

### add

    public void add(SchemaObject obj)

  Add an object to this schema.

  Parameters:
    `obj` - the object to add

### rename

    public void rename(SchemaObject obj,
                       java.lang.String newName)

  Rename an object.

  Parameters:
    `obj` - the object to rename
    `newName` - the new name

### findTableOrView

    public Table findTableOrView(Session session,
                                 java.lang.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.

  Parameters:
    `session` - the session
    `name` - the object name
  Returns:
    the object or null

### findIndex

    public Index findIndex(Session session,
                           java.lang.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

### findTrigger

    public TriggerObject findTrigger(java.lang.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

### findSequence

    public Sequence findSequence(java.lang.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

### findConstraint

    public Constraint findConstraint(Session session,
                                     java.lang.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

### findConstant

    public Constant findConstant(java.lang.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

### freeUniqueName

    public void freeUniqueName(java.lang.String name)

  Release a unique object name.

  Parameters:
    `name` - the object name

### getUniqueConstraintName

    public java.lang.String getUniqueConstraintName(Session session,
                                                    Table table)

  Create a unique constraint name.

  Parameters:
    `session` - the session
    `table` - the constraint table
  Returns:
    the unique name

### getUniqueIndexName

    public java.lang.String getUniqueIndexName(Session session,
                                               Table table,
                                               java.lang.String prefix)

  Create a unique index name.

  Parameters:
    `session` - the session
    `table` - the indexed table
    `prefix` - the index name prefix
  Returns:
    the unique name

### getTableOrView

    public Table getTableOrView(Session session,
                                java.lang.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:
    `SQLException` - if no such object exists

### getIndex

    public Index getIndex(java.lang.String name)

  Get the index with the given name.

  Parameters:
    `name` - the index name
  Returns:
    the index
  Throws:
    `SQLException` - if no such object exists

### getConstraint

    public Constraint getConstraint(java.lang.String name)

  Get the constraint with the given name.

  Parameters:
    `name` - the constraint name
  Returns:
    the constraint
  Throws:
    `SQLException` - if no such object exists

### getConstant

    public Constant getConstant(java.lang.String constantName)

  Get the user defined constant with the given name.

  Parameters:
    `constantName` - the constant name
  Returns:
    the constant
  Throws:
    `SQLException` - if no such object exists

### getSequence

    public Sequence getSequence(java.lang.String sequenceName)

  Get the sequence with the given name.

  Parameters:
    `sequenceName` - the sequence name
  Returns:
    the sequence
  Throws:
    `SQLException` - if no such object exists

### getAll

    public java.util.ArrayList<SchemaObject> getAll(int type)

  Get all objects of the given type.

  Parameters:
    `type` - the object type
  Returns:
    a (possible empty) list of all objects

### getAllTablesAndViews

    public java.util.ArrayList<Table> getAllTablesAndViews()

  Get all tables and views.

  Returns:
    a (possible empty) list of all objects

### remove

    public void remove(SchemaObject obj)

  Remove an object from this schema.

  Parameters:
    `obj` - the object to remove

### createTable

    public Table createTable(CreateTableData data)

  Add a table to the schema.

  Parameters:
    `data` - the create table information
  Returns:
    the created `Table` object

### createTableLink

    public TableLink createTableLink(int id,
                                     java.lang.String tableName,
                                     java.lang.String driver,
                                     java.lang.String url,
                                     java.lang.String user,
                                     java.lang.String password,
                                     java.lang.String originalSchema,
                                     java.lang.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 `TableLink` object