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 the value.
    • SHORTNAME, a short name (alias) for the class. Accepts a string as the value. NULL to remove it.
    • SUPERCLASS, the superclass name to assign. Accepts a string as the value. NULL to remove it.
    • OVERSIZE, the oversize factor. Accepts a decimal number as the value.
    • ADDCLUSTER, add a cluster to be part of the class. If the cluster doesn't exist, a physical cluster is created automatically. See also Create Cluster command. Adding clusters to classes is also useful to store records in distributed servers. Look at Distributed Sharding
    • REMOVECLUSTER, remove a cluster from a class. The cluster will be not deleted.
    • 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 to the record if they're in the class's schema definition.
    • CLUSTERSELECTION sets the strategy used on selecting the cluster where to create new records. On class creation the setting is inherited by the database's cluster-selection property. For more information look also at Cluster Selection.
    • 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

To change the name of the class 'Account':

ALTER CLASS Account NAME Seller

To change the oversize factor of the class 'Account':

ALTER CLASS Account OVERSIZE 2

To add a cluster by name to a class. If the cluster doesn't exist, it's created automatically:

ALTER CLASS Account ADDCLUSTER account2

T remove a cluster by id to a class without dropping the cluster:

ALTER CLASS Account REMOVECLUSTER 34

To 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

To add a new cluster to a class and set its 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 to use when creating new records.