Package org.h2.table

# Class TableSynonym

java.lang.Object
org.h2.engine.DbObject
org.h2.schema.SchemaObject
org.h2.table.TableSynonym

All Implemented Interfaces:
  `HasSQL`

public class TableSynonym extends SchemaObject
Synonym for an existing table or view. All DML requests are forwarded to the backing table. Adding indices to a synonym or altering the table is not supported.

## Field Summary

### Fields inherited from class org.h2.engine.DbObject

`AGGREGATE, comment, COMMENT, CONSTANT, CONSTRAINT, database, DOMAIN, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, trace, TRIGGER, USER`

### Fields inherited from interface org.h2.util.HasSQL

`ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS`

## Constructor Summary

Constructors
Constructor
Description
`TableSynonym(CreateSynonymData data)`

## Method Summary

Modifier and Type
Method
Description
`void`
`checkRename()`
Check if renaming is allowed.
`String`
`getCreateSQL()`
Construct the CREATE ...
`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()`
Construct a DROP ...
`Table`
`getSynonymFor()`
`String`
`getSynonymForName()`
`Schema`
`getSynonymForSchema()`
`int`
`getType()`
Get the object type.
`boolean`
`isInvalid()`
`void`
`removeChildrenAndResources(SessionLocal session)`
Delete all dependent children objects and resources of this object.
`void`
`rename(String newName)`
Rename the object.
`void`
`updateData(CreateSynonymData data)`
Set (update) the data.
`void`
`updateSynonymFor()`
Update the table that this is a synonym for, to know about this synonym.

### Methods inherited from class org.h2.schema.SchemaObject

`getSchema, getSQL, getSQL`

### Methods inherited from class org.h2.engine.DbObject

`getChildren, getComment, getCreateSQLForMeta, getDatabase, getId, getModificationId, getName, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.h2.util.HasSQL

`getTraceSQL`

## Constructor Details

### TableSynonym

public TableSynonym(CreateSynonymData data)

## Method Details

### getSynonymFor

public Table getSynonymFor()

Returns:
  the table this is a synonym for

### updateData

public void updateData(CreateSynonymData data)
Set (update) the data.

Parameters:
  `data` - the new data

### getType

public int getType()
Description copied from class: `DbObject`
Get the object type.

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

### getCreateSQLForCopy

public String getCreateSQLForCopy(Table table, String quotedName)
Description copied from class: `DbObject`
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

Overrides:
  `getCreateSQLForCopy` in class `DbObject`
Parameters:
  `table` - the new table
  `quotedName` - the quoted name
Returns:
  the SQL statement

### rename

public void rename(String newName)
Description copied from class: `DbObject`
Rename the object.

Overrides:
  `rename` in class `DbObject`
Parameters:
  `newName` - the new name

### removeChildrenAndResources

public void removeChildrenAndResources(SessionLocal session)
Description copied from class: `DbObject`
Delete all dependent children objects and resources of this object.

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

### getCreateSQL

public String getCreateSQL()
Description copied from class: `DbObject`
Construct the CREATE ... SQL statement for this object.

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

### getDropSQL

public String getDropSQL()
Description copied from class: `DbObject`
Construct a DROP ... SQL statement for this object.

Overrides:
  `getDropSQL` in class `DbObject`
Returns:
  the SQL statement

### checkRename

public void checkRename()
Description copied from class: `DbObject`
Check if renaming is allowed. Does nothing when allowed.

Overrides:
  `checkRename` in class `DbObject`

### getSynonymForName

public String getSynonymForName()

Returns:
  the table this synonym is for

### getSynonymForSchema

public Schema getSynonymForSchema()

Returns:
  the schema this synonym is for

### isInvalid

public boolean isInvalid()

Returns:
  true if this synonym currently points to a real table

### updateSynonymFor

public void updateSynonymFor()
Update the table that this is a synonym for, to know about this synonym.