| java.lang.Object org.hsqldb.TableWorks
TableWorks | class TableWorks (Code) | | The methods in this class perform alterations to the structure of an
existing table which may result in a new Table object
author: fredt@users version: 1.8.0 since: 1.7.0 |
Method Summary | |
void | addColumn(Column column, int colIndex) | void | addOrDropPrimaryKey(int[] cols, boolean identity) | void | addPrimaryKey(int[] cols, HsqlName name) | void | checkConvertColDataType(Column oldCol, Column newCol) | void | createCheckConstraint(Constraint c, HsqlName name) | void | createForeignKey(int[] fkcol, int[] expcol, HsqlName name, Table mainTable, int deleteAction, int updateAction) Creates a foreign key according to current sql.strict_fk or
sql.strong_fk settings. | Index | createIndex(int[] col, HsqlName name, boolean unique, boolean constraint, boolean forward) | void | createUniqueConstraint(int[] col, HsqlName name) A unique constraint relies on a unique indexe on the table. | void | dropColumn(int colIndex) | void | dropConstraint(String name) | void | dropFKConstraint(Constraint c) | void | dropIndex(String indexname) Because of the way indexes and column data are held in memory and
on disk, it is necessary to recreate the table when an index is added
to a non-empty table.
Originally, this method would break existing foreign keys as the
table order in the DB was changed. | Table | getTable() | void | reTypeColumn(Column oldCol, Column newCol) | void | retypeColumn(Column column, int colindex) | void | setColDefaultExpression(int colIndex, Expression def) | void | setColNullability(Column column, boolean nullable) |
addOrDropPrimaryKey | void addOrDropPrimaryKey(int[] cols, boolean identity) throws HsqlException(Code) | | |
createForeignKey | void createForeignKey(int[] fkcol, int[] expcol, HsqlName name, Table mainTable, int deleteAction, int updateAction) throws HsqlException(Code) | | Creates a foreign key according to current sql.strict_fk or
sql.strong_fk settings. Foreign keys are enforced via indexes on both
the referencing (child) and referenced (parent) tables.
In versions 1.7.0 and 1.7.1 some non-standard features were supported
for compatibility with older databases. These allowed foreign keys
to be created without the prior existence of a unique constraint on
the referenced columns.
In version 1.7.2, a unique constraint on the referenced columns must
exist.
The non-unique index on the referencing table is now always created
whether or not a PK or unique constraint index on the columns exist.
This closes the loopholes opened by the introduction of ALTER TABLE
for adding foreign keys.
Foriegn keys on temp tables can reference other temp tables with the
same rules above. Foreign keys on permanent tables cannot reference
temp tables.
Duplicate foreign keys are now disallowed.
-- The unique index on the referenced table must always belong to a
constraint (PK or UNIQUE). Otherwise after a SHUTDOWN and restart the
index will not exist at the time of creation of the foreign key when
the foreign key is referencing the same table.
-- The non-unique index on the referencing table is always created
regardless of any existing index. This allows the foreign key
constraint to be dropped when required.
(fred@users)
Parameters: fkcol - Parameters: expcol - Parameters: name - foreign key name Parameters: expTable - Parameters: deleteAction - Parameters: updateAction - throws: HsqlException - |
createIndex | Index createIndex(int[] col, HsqlName name, boolean unique, boolean constraint, boolean forward) throws HsqlException(Code) | | Because of the way indexes and column data are held in memory and
on disk, it is necessary to recreate the table when an index is added
to a non-empty table cached table.
With empty tables, Index objects are simply added
With MEOMRY and TEXT tables, a new index is built up and nodes for
earch row are interlinked (fredt@users)
Parameters: col - Parameters: name - Parameters: unique - Parameters: constraint - Parameters: forward - new index throws: HsqlException - normally for lack of resources |
createUniqueConstraint | void createUniqueConstraint(int[] col, HsqlName name) throws HsqlException(Code) | | A unique constraint relies on a unique indexe on the table. It can
cover a single column or multiple columns.
All unique constraint names are generated by Database.java as unique
within the database. Duplicate constraints (more than one unique
constriant on the same set of columns are still allowed but the
names will be different. (fredt@users)
Parameters: col - Parameters: name - throws: HsqlException - |
dropIndex | void dropIndex(String indexname) throws HsqlException(Code) | | Because of the way indexes and column data are held in memory and
on disk, it is necessary to recreate the table when an index is added
to a non-empty table.
Originally, this method would break existing foreign keys as the
table order in the DB was changed. The new table is now linked
in place of the old table (fredt@users)
Parameters: indexname - throws: HsqlException - |
setColDefaultExpression | void setColDefaultExpression(int colIndex, Expression def) throws HsqlException(Code) | | performs the work for changing the default value of a column
|
setColNullability | void setColNullability(Column column, boolean nullable) throws HsqlException(Code) | | performs the work for changing the nullability of a column
|
|
|