|
|
| int db::Database::update_table |
( |
const NameChar * |
table_name, |
|
|
const FieldDescSet & |
new_fields, |
|
|
const IndexDescSet & |
new_indexes | |
|
) |
| | |
Update a table's field and indexes.
This function updates the indexes and fields in a table to match the description provided by fields and indexes. Existing fields and indexes that are not listed in fields or indexes will be removed from the database. A field cannot be removed unless all indexes on that field are also explicitly removed.
- Parameters:
-
| table_name | Table to be updated. (required) |
| new_fields | New description of the table's fields. |
| new_indexes | New description of the table's indexes. |
- Returns:
- DB_NOERROR When successful.
- DB_EINDEX Index error. Duplicate indexes for unique index.
- DB_EINVAL Caused by: invalid table_name, invalid fields description, invalid indexes description.
- DB_EFIELD General field error.
- DB_ENAME table_name is not in a valid format. Valid name is letter(aA-zZ)+zero or more aplhanumeric characters. Underscore is considered a valid character.
- DB_ENOTFOUND Not found. Unable to find field with the name specified.
- DB_ESTATE Object state is not compatible with the method called or arguments. Caused by: Table is being used (opened or has a lock on it),
- Note:
- This function can be used to dynamically alter a table's schema. First call describe_table to retrieve a FieldDescSet and IndexDescSet. Modify these objects and then update the table schema with update_table.
Do not call this function while a transaction is active. If necessary, call tx_commit or tx_abort to finish the current transaction. This function is not atomic.
|