SQL - CREATE CLASS
The Create Class command creates a new class in the schema. NOTE: If a cluster with the same name exists in the database will be used as default cluster.
Syntax
CREATE CLASS <class> [EXTENDS <super-class>] [CLUSTER <clusterId>*]
Where:
- class is the class name to create. The first character must be alphabetic and others can be any alphanumeric characters plus underscore _ and dash -.
- super-class, optional, is the super-class to extend
- clusterId can be a list separated by comma (,)
By default OrientDB creates 1 cluster per class, but this can be changed by setting the property minimumclusters
at database level.
Cluster selection strategy
OrientDB, by default, inherits the cluster selection by the database. By default is round-robin, but you can always change it after creation with alter class command. The supported strategies are:
- default, uses always the Class's
defaultClusterId
property. This was the default before 1.7
- round-robin, put the Class's configured clusters in a ring and returns a different cluster every time restarting from the first when the ring is completed
- balanced, checks the records in all the clusters and returns the smaller cluster. This allows the cluster to have all the underlying clusters balanced on size. On adding a new cluster to an existent class, the new empty cluster will be filled before the others because more empty then the others. In distributed configuration when configure clusters on different servers this setting allows to keep the server balanced with the same amount of data. Calculation of cluster size is made every 5 or more seconds to avoid to slow down insertion
See also
Examples
Create the class 'Account':
CREATE CLASS Account
Create the class 'Car' that extends 'Vehicle':
CREATE CLASS Car extends Vehicle
Create the class 'Car' with clusterId 10:
CREATE CLASS Car CLUSTER 10
Abstract class
Create the class 'Person' as ABSTRACT:
CREATE CLASS Person ABSTRACT