OrientDB Manual

SQL - ALTER CLASS

The Alter Class command alters a class in the schema.

Syntax

ALTER CLASS <class> <attribute-name> <attribute-value>

Where:

  • class is the class name to change
  • attribute-name, is the attribute name to alter. Supported attribute names are:
    • NAME, the class name. Accepts a string as value
    • SHORTNAME, the short name. Accepts a string as value. NULL to remove it
    • SUPERCLASS, the superclass name to assign. Accepts a string as value. NULL to remove it
    • OVERSIZE, the oversize factor. Accepts a decimal number as value
    • ADDCLUSTER, add a cluster to be part of the class (since v1.1.0)
    • REMOVECLUSTER, remove a cluster from a class. The cluster will be not deleted. (since v1.1.0)
    • STRICTMODE, enable or disable the strict mode. With the strict mode enabled you work in schema-full mode and you can't add new properties in record if the class
  • CLUSTERSELECTION sets the strategy used on selecting the cluster where to create new records. On class creation the settings is inherited by database's cluster-selection property. 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
    • CUSTOM, to set custom properties. Property name and value must be expressed using the syntax: "<name>=<value>" without spaces between name and value
  • attribute-value, is the new attribute value to set

See also

Examples

Change the name of the class 'Account':

ALTER CLASS Account NAME Seller

Change the oversize factor of the class 'Account':

ALTER CLASS Account OVERSIZE 2

Adds a cluster by name to a class (since v1.1.0):

ALTER CLASS Account ADDCLUSTER account2

Removes a cluster by id to a class (since v1.1.0):

ALTER CLASS Account REMOVECLUSTER 34

Add custom properties (in this case used in Record level security):

ALTER CLASS Post CUSTOM onCreate.fields=_allowRead,_allowUpdate
ALTER CLASS Post CUSTOM onCreate.identityType=role

Create a new cluster to the class and set the cluster-selection strategy as "balanced":

CREATE CLUSTER Employee_1
ALTER CLASS ADDCLUSTER Employee_1
ALTER CLASS CLUSTERSELECTION balanced

History

1.7

  • Added support for CLUSTERSELECTION that sets the strategy used on selecting the cluster where to create new records