Interface BBjAdminTable
- All Superinterfaces:
BBjAdminCommitPropertyWriter
,BBjAdminCommitWriter
,BBjAdminPropertyReader
,BBjAdminPropertyWriter
,Remote
,Serializable
- All Known Subinterfaces:
BBjAdminBBjTable
,BBjAdminESQLTable
,BBjAdminLegacyTable
Represents an individual table in a database. The BBjAdminTable contains the properties describing the various parts of the table as well as methods to get the list of available columns, indexes, etc. Note that table definitions can differ from the actual structure of the table's data file so it is important to make sure that the definition matches the data file to eliminate confusion. For example a table definition can contain index definitions that are not actually present on the table's data file. This means that while the table definition says a particular set of columns are indexed, unless those are actually present on the data file, that index is not usable by the SQL engine's optimizer.
There are several ways to make changes to table definitions. One is using the Enterprise Manager. You can also make changes programmatically. The easiest way to change table structure is to use the SQL ALTER TABLE statement. The ALTER TABLE docs can be found here: ALTER TABLE.
ALTER TABLE statements are executed from an SQL tools such as the Enterprise Manager or your JDBC/ODBC program and look something like this:
ALTER TABLE my_table ADD COLUMN my_col VARCHAR(25)
ALTER TABLE my_table DROP COLUMN my_old_col
ALTER TABLE my_table ALTER COLUMN last_name VARCHAR (100)
Note that each ALTER TABLE statement will rewrite the entire data file to adjust the record layout/size so keep that in mind when using ALTER TABLE.
An alternative approach is to use the Admin API. With this method you can make numerous changes to the structure at one time and then only rewrite the data file once. This is more complex but more flexible as well (this is used by the Enterprise Manager). This can be done from a BBj or Java program. There is a handy method to change a table definition using a string template which many may find helpful. Here is a short example to give you an idea of how you could do this in BBj. One thing to keep in mind is that the Admin API gives you the ability to change the table definition without changing the data file, or to change the data file as well. Make sure to use the correct method to get the desired effect. The example below shows how you could add a new column to the CATEGORY table in the ChileCompany database, and also change the size of another column at the same time. You can play around with the ChileCompany DB to get a feel for it. Note the string template. We changed DESC to 130 characters and added NEW_COL at the end:
BBj Sample Code
declare BBjAdminBase admin!
declare BBjAdminDatabase db!
declare BBjAdminTable table!
REM Get a connection to the Admin system and then grab the database object
admin! = BBjAdminFactory.getBBjAdmin("admin","admin123")
db! = admin!.getDatabase("ChileCompany")
REM Get the table instance and change the column definitions.
table! = db!.getTable("CATEGORY")
tmpl$ = "PROD_CAT:C(2),DESC:C(130),COST_METHOD:C(5),COST_ACCOUNT:C(8),SALE_ACCOUNT:C(8),INV_ACCOUNT:C(8),NEW_COL:C(10**)"
table!.setTemplate(tmpl$)
REM This call tells the call to commit() to rewrite the data file. If you don't want
REM to rewrite the data file, set this to 0 (false)
table!.setShouldCommitUpdateDataFile(1)
REM Write your changes and update the data file.
table!.commit()
BBj Sample - Create FULLTEXT Index
The easiest way is with SQL using:
CREATE FULLTEXT INDEX ON my_table(col1, col2)
With the Admin API you can do it as well. To use the Admin API use the following example:
api! = BBjAdminFactory.getBBjAdmin("admin", "admin123")
db! = api!.getDatabase("MyDatabase")
table! = db!.getTable("MY_TABLE")
REM Specify the list of columns to include in the FULLTEXT index
indexCols! = api!.createBBjList()
indexCols!.add("COL1")
indexCols!.add("COL2")
table!.setList(BBjAdminTable.FULLTEXT_COLUMNS, indexCols!)
REM Save the table definition which will create the FULLTEXT index. Note, this
REM may take a while if the table large.
table!.commit()
REM Make sure to cleanup the API instance.
api!.release()
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Data file type for the table. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
Lucene analyzer class to use on the FULLTEXT index if one is present on this table.static final String
Path to the data file.static final String
Read-only full path to the data file.static final String
Description of the table.static final String
A placeholder value returned for tables that use an encryption string for the table.static final String
File encryption string if this table's data file is encrypted.static final String
File password to use for this table if it is password protected.static final String
A placeholder value returned for tables that use a password (not encrypted) for the table.static final String
File type defined for this table.static final int
Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.static final int
Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.static final int
Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.static final int
Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.static final int
Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.static final int
Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.static final int
Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.static final int
Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.static final int
Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.static final int
Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.static final int
Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.static final int
Used in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.static final String
List of the columns that make up the FULLTEXT index if one is present.static final String
True if the FULLTEXT index on this table (if there is one) is enabled.static final String
Key size if this is a single keyed file or 0 if it is multi-keyed.static final String
Date of the last time this table was successfully analyzed.static final String
If table analysis failed on the table, this is the exception that was generated.static final String
Maximum number of rows allowed in the table's data file or 0 if no limit.static final String
Name of the table.static final String
Original name of the table.static final String
Record size of the table's data file.static final String
Number of rows in the table.static final String
Schema name for the table.static final String
Lucene stopwords language code to use for the FULLTEXT index if one is present on this table.static final String
String template used to define the table. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new instance of a BBjAdminColumn on the table.Creates a new instance of a BBjAdminCrossReference (foreign key).Creates a new instance of a BBjAdminIndex on the table.Gets an instance of BBjAdminColumn from the table for the specified column name.Get a list of the columns in the table.Returns a list of the cross references (foreign keys) on this table.Used primarily by GUI applications like the Enterprise Manager to dynamically generate an admin UI.Get a list of the indexes in the table.Derives and returns a list of indexes from the data file associated with this table even before the table has ever been committed to the database.int
getMaxColumnValueLength
(String p_column) Get a BBj string template from the column definitions.getTemplate
(boolean p_detailed) Get a BBj string template from the column definitions.Returns the triggers on this table's data file if there are any, or null if there are none.getType()
Get the data file type of the data file used by the table.void
Rebuilds the current FULLTEXT index if one is present.void
setColumns
(BBjAdminList<BBjAdminColumn> p_columns) Set a new list of columns for this table (not committed).void
setCrossReferences
(BBjAdminList<BBjAdminCrossReference> p_crossReferences) Sets the list of cross references (foreign keys) on this table.void
setDescriptiveProperties
(BBjAdminList<BBjAdminProperty> p_descriptiveProps) Used primarily by GUI applications like the Enterprise Manager to dynamically generate an admin UI.void
setIndexes
(BBjAdminList<BBjAdminIndex> p_indexes) Set a new list of indexes for this table (not committed).void
setShouldCommitUpdateDataFile
(boolean p_update) Sets whether a commit should also update/create the data file, or if is should only make changes to the data dictionary.void
setTemplate
(String p_template) Very powerful, helpful method to set all the column definitions at one time from a standard BBj string template.boolean
Should commit update the data file?void
shouldCommitUpdateDataFile
(boolean p_update) Deprecated.void
Starts table analysis on this table.Methods inherited from interface com.basis.api.admin.BBjAdminCommitPropertyWriter
getChangedProperties, getClearedProperties, getOriginalProperties
Methods inherited from interface com.basis.api.admin.BBjAdminCommitWriter
commit, rollback
Methods inherited from interface com.basis.api.admin.BBjAdminPropertyReader
checkValueEqual, contains, contains, getBoolean, getDouble, getInt, getList, getLong, getProperties, getString, getType, getTypes, getValue
Methods inherited from interface com.basis.api.admin.BBjAdminPropertyWriter
addType, canAddNewProperties, canClear, clear, clearProperties, clearProperty, getReadOnly, hasChanged, isReadOnly, setBoolean, setDouble, setInt, setList, setLong, setProperties, setString, setValue
-
Field Details
-
ENCRYPTION_PLACEHOLDER
A placeholder value returned for tables that use an encryption string for the table. We don't return the actual encryption string for security purposes. If the value for ENCRYPTION_STRING contains this value, that means it is encrypted.- See Also:
-
FILE_PASSWORD_PLACEHOLDER
A placeholder value returned for tables that use a password (not encrypted) for the table. We don't return the actual password for security purposes. If the value for FILE_PASSWORD contains this value, that means it is password protected.- See Also:
-
NAME
Name of the table.- See Also:
-
ORIGINAL_NAME
Original name of the table. This is read-only.- See Also:
-
DESCRIPTION
Description of the table.- See Also:
-
DATA_FILE
Path to the data file. This should usually be relative to the DATA global or another user defined property. For example, do not use /mydata/CUSTOMER, instead use (DATA)CUSTOMER. This makes the database much more portable.- See Also:
-
DATA_FILE_FULL_PATH
Read-only full path to the data file.- See Also:
-
TEMPLATE
String template used to define the table.- See Also:
-
LAST_ANALYSIS
Date of the last time this table was successfully analyzed.- See Also:
-
LAST_ANALYSIS_EXCEPTION
If table analysis failed on the table, this is the exception that was generated.- See Also:
-
ROW_COUNT
Number of rows in the table.- See Also:
-
SCHEMA
Schema name for the table.- See Also:
-
FILE_TYPE
File type defined for this table.- See Also:
-
FILE_PASSWORD
File password to use for this table if it is password protected.- See Also:
-
ENCRYPTION_STRING
File encryption string if this table's data file is encrypted.- See Also:
-
ALERT_TYPE
- See Also:
-
KEY_SIZE
Key size if this is a single keyed file or 0 if it is multi-keyed.- See Also:
-
RECORD_SIZE
Record size of the table's data file.- See Also:
-
MAX_ROW_COUNT
Maximum number of rows allowed in the table's data file or 0 if no limit.- See Also:
-
FULLTEXT_COLUMNS
List of the columns that make up the FULLTEXT index if one is present.- See Also:
-
FULLTEXT_INDEX_ENABLED
True if the FULLTEXT index on this table (if there is one) is enabled. If disabled, the index will not build automatically or remain in sync.- See Also:
-
ANALYZER
Lucene analyzer class to use on the FULLTEXT index if one is present on this table.- See Also:
-
STOPWORDS_LANG
Lucene stopwords language code to use for the FULLTEXT index if one is present on this table.- See Also:
-
FILE_TYPE_DIRECT_SORT
static final int FILE_TYPE_DIRECT_SORTUsed in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.- See Also:
-
FILE_TYPE_STRING
static final int FILE_TYPE_STRINGUsed in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.- See Also:
-
FILE_TYPE_PROGRAM
static final int FILE_TYPE_PROGRAMUsed in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.- See Also:
-
FILE_TYPE_DIRECTORY
static final int FILE_TYPE_DIRECTORYUsed in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.- See Also:
-
FILE_TYPE_MKEYED
static final int FILE_TYPE_MKEYEDUsed in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.- See Also:
-
FILE_TYPE_MKEYED_RECOVERABLE
static final int FILE_TYPE_MKEYED_RECOVERABLEUsed in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.- See Also:
-
FILE_TYPE_MKEYED_64BIT
static final int FILE_TYPE_MKEYED_64BITUsed in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.- See Also:
-
FILE_TYPE_MKEYED_64BIT_RECOVERABLE
static final int FILE_TYPE_MKEYED_64BIT_RECOVERABLEUsed in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.- See Also:
-
FILE_TYPE_XKEYED
static final int FILE_TYPE_XKEYEDUsed in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.- See Also:
-
FILE_TYPE_XKEYED_RECOVERABLE
static final int FILE_TYPE_XKEYED_RECOVERABLEUsed in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.- See Also:
-
FILE_TYPE_VKEYED
static final int FILE_TYPE_VKEYEDUsed in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.- See Also:
-
FILE_TYPE_ESQL
static final int FILE_TYPE_ESQLUsed in conjunction with the FILE_TYPE property indicating the type of file housing the data for the table.- See Also:
-
-
Method Details
-
shouldCommitUpdateDataFile
boolean shouldCommitUpdateDataFile()Should commit update the data file?- Returns:
- True if the definition is currently set to update the data file to match the definition on
a call to the
BBjAdminCommitWriter.commit()
method.
-
shouldCommitUpdateDataFile
Deprecated.Sets whether a commit should also update/create the data file, or if is should only make changes to the data dictionary.- Parameters:
p_update
-
-
setShouldCommitUpdateDataFile
void setShouldCommitUpdateDataFile(boolean p_update) Sets whether a commit should also update/create the data file, or if is should only make changes to the data dictionary.- Parameters:
p_update
-
-
getType
Get the data file type of the data file used by the table.- Returns:
- The type of the file. One of the
BBjAdminTable.Type
enum. - Throws:
BBjAdminException
-
getTemplate
Get a BBj string template from the column definitions.- Returns:
- BBj string template that matches the column definitions.
- Throws:
BBjAdminException
-
getTemplate
Get a BBj string template from the column definitions.- Parameters:
p_detailed
- True if you want the detailed attributes filled in as well.- Returns:
- The string template defining the columns that make up the table.
- Throws:
BBjAdminException
-
setTemplate
Very powerful, helpful method to set all the column definitions at one time from a standard BBj string template. This method can save a lot of busy work coding column definitions and is a great way to make multiple changes quickly and succinctly.- Parameters:
p_template
- Standard BBj string template to use to define the columns for the table.- Throws:
BBjAdminException
-
getColumns
Get a list of the columns in the table. Add/remove columns to/from this list to make changes to the table definition. Call theBBjAdminCommitWriter.commit()
method to save the changes. Call thesetShouldCommitUpdateDataFile(boolean)
passing in true to have theBBjAdminCommitWriter.commit()
call update the table's data file structure to match the definitions.- Returns:
- The list of
BBjAdminColumn
objects that define the table. - Throws:
BBjAdminException
-
getCrossReferences
Returns a list of the cross references (foreign keys) on this table.- Returns:
- List of all the
BBjAdminCrossReference
objects on this table. This will not return anything on legacy data dictionaries unless the table is an ESQL table. Enhanced dictionaries support cross references (foreign keys). - Throws:
BBjAdminException
-
setColumns
Set a new list of columns for this table (not committed).- Parameters:
p_columns
-- Throws:
BBjAdminException
-
setCrossReferences
void setCrossReferences(BBjAdminList<BBjAdminCrossReference> p_crossReferences) throws BBjAdminException Sets the list of cross references (foreign keys) on this table.- Parameters:
p_crossReferences
-- Throws:
BBjAdminException
-
getIndexes
Get a list of the indexes in the table.- Returns:
- The list of indexes defined on the table. This returns the indexes from the data dictionary
and may be different than those defined on the data file. Call
getIndexesFromDataFile()
to return the indexes actually present on the table's data file. - Throws:
BBjAdminException
-
setIndexes
Set a new list of indexes for this table (not committed).- Parameters:
p_indexes
-- Throws:
BBjAdminException
-
createIndex
Creates a new instance of a BBjAdminIndex on the table. The index needs to be added to the list returned ingetIndexes()
.- Returns:
- The new
BBjAdminIndex
created. Make sure to add the returned object to the list returned ingetIndexes()
. - Throws:
BBjAdminException
-
createColumn
Creates a new instance of a BBjAdminColumn on the table. You still need to add the column to the list returned in a call togetColumns()
.- Returns:
- New
BBjAdminColumn
object created. - Throws:
BBjAdminException
-
createCrossReference
Creates a new instance of a BBjAdminCrossReference (foreign key). You still need to add the cross reference to the list returned by a call togetCrossReferences()
.- Returns:
- The newly created
BBjAdminCrossReference
. - Throws:
BBjAdminException
-
getColumn
Gets an instance of BBjAdminColumn from the table for the specified column name. If the column is not valid, returns null.- Parameters:
p_column
- Name of the column.- Returns:
- Column instance for the specified column.
- Throws:
BBjAdminException
-
getMaxColumnValueLength
- Throws:
BBjAdminException
-
startAnalysis
Starts table analysis on this table.- Throws:
BBjAdminException
-
getTriggers
Returns the triggers on this table's data file if there are any, or null if there are none.- Returns:
- The triggers currently defined on this table.
- Throws:
BBjAdminException
-
getIndexesFromDataFile
Derives and returns a list of indexes from the data file associated with this table even before the table has ever been committed to the database. This call examines the physical data file and its current key structure.- Returns:
- List of the indices currently present on the table's data file. This only uses the data dictionary information for index names.
- Throws:
BBjAdminException
-
getDescriptiveProperties
Used primarily by GUI applications like the Enterprise Manager to dynamically generate an admin UI. To get property values for general purposes, you should call the getXXX() methods.- Returns:
- BBjAdminList containing BBjAdminProperty objects for each available property.
- Throws:
BBjAdminException
-
setDescriptiveProperties
void setDescriptiveProperties(BBjAdminList<BBjAdminProperty> p_descriptiveProps) throws BBjAdminException Used primarily by GUI applications like the Enterprise Manager to dynamically generate an admin UI. To set property values for general purposes, you should call the setXXX() methods.- Throws:
BBjAdminException
-
rebuildFullTextIndex
Rebuilds the current FULLTEXT index if one is present. This call should really only be called if there is known synchronization issues between the data in the data file and the data in the FULLTEXT index, or if you restore a data file from backup but do not also restore the MY_FILE.textsearch directory at the same time.- Throws:
BBjAdminException
-
setShouldCommitUpdateDataFile(boolean)