Name

duro::table - create, delete, and manipulate duro tables

Synopsis

duro::table arg ?arg ...?

Description

duro::table add tablename dbname txId

This subcommand adds the table tablename to the database dbname.

duro::table attrs tablename txId

This subcommand returns a list of lists. The first element in sublist is the name of an attribute of table tablename and the second element is the type of the attribute. The third element, if present, is the default value. The order of the sublists is undefined.

duro::table contains tablename tuple txId

Returns 1 if the table tablename contains the tuple tuple, 0 if the table does not contain the tuple.

A tuple is represented by a list containing pairs of elements. The first element in each pair contains the attribute name and the second element of each pair is the attribute value.

duro::table create ?flag? tablename attrs keys txId

This subcommand creates a real table with the name tablename under the control of the transaction specified by txId.

The attributes are specified by the argument attrs. attrs must be a list of lists, with one sublist for each attribute. The sublist must contain two or three elements. The first element of the sublist is the attribute name. The second element is the attribute type. The third element, if given, specifies the default value for the attribute.

A type is specified as follows:

The keys argument specifies the candidate keys and, like attrs, must be a list of lists. Each sublist defines a key. The sublist elements specify the attribute names of a key.

If flag is given, it must be either -global or -local. If -global is specified, the table will become a global (persistent) table in the database the transaction specified by txId interacts with. If -local is specified, the table will become a local (transient) table. Default is -global.

duro::table def tablename txId

If the table tablename is a virtual table, this subcommand returns the expression that defines the table.

If the table is a real table, the table name is returned.

duro::table drop tablename txId

This subcommand deletes the table tablename under the control of the transaction specified by txId.

duro::table expr ?flag? tablename expression txId

This subcommand creates a virtual table under the control of the transaction specified by txId.

The expression argument specifies the relational expression which defines the virtual table.

If flag is specified, it must be either -global or -local. If -global is specified, the table will become a global (persistent) table in the database the transaction specified by txId interacts with. If -local is specified, the table will become a local (transient) table. Default is -local.

duro::table keys tablename txId

This subcommand returns the keys of table tablename.

duro::table rename oldname newname txId

This subcommand renames the table oldname as newname.

Examples

Creating a real table

duro::table create P {
        {P# P#}
        {PNAME NAME}
        {COLOR COLOR}
        {WEIGHT WEIGHT}
        {CITY STRING}
} {{P#}} $tx

(where tx contains the ID of the currently active transaction) is equivalent to the following Tutorial D statement:

VAR P REAL RELATION { P# P#,
                      PNAME NAME,
                      COLOR COLOR,
                      WEIGHT WEIGHT,
                      CITY CHAR }
                    KEY { P# };

Creating a virtual table

duro::table expr -global PART_CITIES {P { P#, CITY }} $tx

is equivalent to the following Tutorial D statement:

VAR PART_CITIES VIRTUAL P { P#, CITY };

(Examples taken taken from TTM, chapter 6, with a minor modification)

See Also

Expressions

$Id$