Package org.h2.engine
Class DbObject
java.lang.Object
org.h2.engine.DbObject
- All Implemented Interfaces:
org.h2.util.HasSQL
- Direct Known Subclasses:
Comment
,Right
,RightOwner
,Setting
A database object such as a table, an index, or a user.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
This object is a user-defined aggregate function.protected String
The comment (if set).static final int
This object is a comment.static final int
This object is a constant.static final int
This object is a constraint (check constraint, unique constraint, or referential constraint).protected Database
The database.static final int
This object is a domain.static final int
This object is an alias for a Java function.static final int
This object is an index.static final int
This object is a right.static final int
This object is a role.static final int
This object is a schema.static final int
This object is a sequence.static final int
This object is a setting.static final int
This object is a synonym.static final int
The object is of the type table or view.protected org.h2.message.Trace
The trace module.static final int
This object is a trigger.static final int
This object is a 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Check if renaming is allowed.Get the list of dependent children (for tables, this includes indexes and so on).Get the current comment of this object.abstract String
Construct the CREATE ...getCreateSQLForCopy
(org.h2.table.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 tableConstruct the CREATE ...final Database
Get the database.Construct a DROP ...final int
getId()
Get the unique object id.final long
final String
getName()
Get the name.getSQL
(int sqlFlags) Get the SQL statement of this expression.getSQL
(StringBuilder builder, int sqlFlags) Appends the SQL statement of this object to the specified builder.abstract int
getType()
Get the object type.protected void
Set the main attributes to null to make sure the object is no longer used.boolean
Check if this object is temporary (for example, a temporary table).final boolean
isValid()
abstract void
removeChildrenAndResources
(SessionLocal session) Delete all dependent children objects and resources of this object.void
Rename the object.void
setComment
(String comment) Change the comment of this object.final void
Tell the object that is was modified.protected final void
setObjectName
(String name) void
setTemporary
(boolean temporary) Tell this object that it is temporary or not.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
-
Field Details
-
TABLE_OR_VIEW
public static final int TABLE_OR_VIEWThe object is of the type table or view.- See Also:
-
INDEX
public static final int INDEXThis object is an index.- See Also:
-
USER
public static final int USERThis object is a user.- See Also:
-
SEQUENCE
public static final int SEQUENCEThis object is a sequence.- See Also:
-
TRIGGER
public static final int TRIGGERThis object is a trigger.- See Also:
-
CONSTRAINT
public static final int CONSTRAINTThis object is a constraint (check constraint, unique constraint, or referential constraint).- See Also:
-
SETTING
public static final int SETTINGThis object is a setting.- See Also:
-
ROLE
public static final int ROLEThis object is a role.- See Also:
-
RIGHT
public static final int RIGHTThis object is a right.- See Also:
-
FUNCTION_ALIAS
public static final int FUNCTION_ALIASThis object is an alias for a Java function.- See Also:
-
SCHEMA
public static final int SCHEMAThis object is a schema.- See Also:
-
CONSTANT
public static final int CONSTANTThis object is a constant.- See Also:
-
DOMAIN
public static final int DOMAINThis object is a domain.- See Also:
-
COMMENT
public static final int COMMENTThis object is a comment.- See Also:
-
AGGREGATE
public static final int AGGREGATEThis object is a user-defined aggregate function.- See Also:
-
SYNONYM
public static final int SYNONYMThis object is a synonym.- See Also:
-
database
The database. -
trace
protected org.h2.message.Trace traceThe trace module. -
comment
The comment (if set).
-
-
Constructor Details
-
DbObject
Initialize some attributes of this object.- Parameters:
db
- the databaseobjectId
- the object idname
- the nametraceModuleId
- the trace module id
-
-
Method Details
-
setModified
public final void setModified()Tell the object that is was modified. -
getModificationId
public final long getModificationId() -
setObjectName
-
getSQL
Description copied from interface:org.h2.util.HasSQL
Get the SQL statement of this expression. This may not always be the original SQL statement, specially after optimization.- Specified by:
getSQL
in interfaceorg.h2.util.HasSQL
- Parameters:
sqlFlags
- formatting flags- Returns:
- the SQL statement
-
getSQL
Description copied from interface:org.h2.util.HasSQL
Appends the SQL statement of this object to the specified builder.- Specified by:
getSQL
in interfaceorg.h2.util.HasSQL
- Parameters:
builder
- string buildersqlFlags
- formatting flags- Returns:
- the specified string builder
-
getChildren
Get the list of dependent children (for tables, this includes indexes and so on).- Returns:
- the list of children, or
null
-
getDatabase
Get the database.- Returns:
- the database
-
getId
public final int getId()Get the unique object id.- Returns:
- the object id
-
getName
Get the name.- Returns:
- the name
-
invalidate
protected void invalidate()Set the main attributes to null to make sure the object is no longer used. -
isValid
public final boolean isValid() -
getCreateSQLForCopy
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- Parameters:
table
- the new tablequotedName
- the quoted name- Returns:
- the SQL statement
-
getCreateSQLForMeta
Construct the CREATE ... SQL statement for this object for meta table.- Returns:
- the SQL statement
-
getCreateSQL
Construct the CREATE ... SQL statement for this object.- Returns:
- the SQL statement
-
getDropSQL
Construct a DROP ... SQL statement for this object.- Returns:
- the SQL statement
-
getType
public abstract int getType()Get the object type.- Returns:
- the object type
-
removeChildrenAndResources
Delete all dependent children objects and resources of this object.- Parameters:
session
- the session
-
checkRename
public void checkRename()Check if renaming is allowed. Does nothing when allowed. -
rename
Rename the object.- Parameters:
newName
- the new name
-
isTemporary
public boolean isTemporary()Check if this object is temporary (for example, a temporary table).- Returns:
- true if is temporary
-
setTemporary
public void setTemporary(boolean temporary) Tell this object that it is temporary or not.- Parameters:
temporary
- the new value
-
setComment
Change the comment of this object.- Parameters:
comment
- the new comment, or null for no comment
-
getComment
Get the current comment of this object.- Returns:
- the comment, or null if not set
-
toString
-