WARNING

This text was automatically converted from troff me macros to HTML. Information may have been lost, added, or changed in the process. Lars Aronsson and Lysator do not guarantee the correctness of this HTML document.

NAME

create *- create a new class

SYNOPSIS

create classname (attributename = type { , attributename = type})
 [key (attributename [[using] operator]
   { , attributename [[using] operator] } )]
 [inherits ( classname {, classname} )]
 [archive = archive_mode]
 [store = ``smgr name'']
 [arch_store = ``smgr name'']

DESCRIPTION

Create will enter a new class into the current data base. The class will be owned by the user issuing the command. The name of the class is classname and the attributes are as specified in the list of attributenames: attributename, attributename, etc. The attributes are created with the type specified by type.

The key clause is used to specify that a field or a collection of fields is unique. If no key clause is specified, POSTGRES will still give every instance a unique object-id ( OID ). This clause allows other fields to be additional keys. Moreover, the using operator part of the clause allows the user to specify what operator should be used for the uniqueness test. For example, integers are all unique if = is used for the check, but not if < is used instead. If no operator is specified, = is used by default. Any specified operator must be a binary operator returning a boolean. If there is no compatible index to allow the key clause to be rapidly checked, POSTGRES defaults to not checking rather than performing an exhaustive search on each key update.

The inherits clause specifies a collection of class names from which this class automatically inherits all fields. If any inherited field name appears more than once, POSTGRES reports an error. Moreover, POSTGRES automatically allows the created class to inherit functions on classes above it in the inheritance hierarchy. Inheritance of functions is done according to the conventions of the Common Lisp Object System (CLOS).

In addition, classname is automatically created as a type. Therefore, one or more instances from the class are automatically a type and can be used in addattr or other create statements. See introduction (commands) for a further discussion of this point.

The store and arch_store keywords may be used to specify a storage manager to use for the new class. The released version of POSTGRES supports only ``magnetic disk'' as a storage manager name; the research system at Berkeley provides additional storage managers. Store controls the location of current data, and arch_store controls the location of historical data. Arch_store may only be specified if archive is also specified. If either store or arch_store is not declared, it defaults to ``magnetic disk.''

The class is created as a heap with no initial data. A class can have no more than 1600 domains (realistically, this is limited by the fact that tuple sizes must be less than 8K), but this limit may be configured lower at some sites. A class cannot have the same name as a system catalog class.

Archive specifies whether historical data is to be saved or discarded. Arch_mode may be one of:

none: no historical access is supported
light: historical access is allowed and optimized for light update activity
heavy: historical access is allowed and optimized for heavy update activity
and defaults to none. For details of the optimization, see [STON87]. Once the archive status is set, there is no way to change it.

EXAMPLE

/* Create class emp with attributes name, sal and bdate */ create emp (name = char16, salary = float4, bdate = abstime)

/* Create class permemp with pension information * inheriting all fields of emp */ create permemp (plan = char16) inherits (emp)

/* Create a class foo on mag disk, * and archive historical data */ create foo (bar = int4) archive = heavy store = "magnetic disk"

SEE ALSO

destroy(commands).

BUGS

Key is not implemented in Version 4.0.

Optional specifications (inherits, archive, store) must be supplied in the order given above, if they are supplied at all.