- OrientDB Tutorial
- OrientDB - Home
- OrientDB - Overview
- OrientDB - Installation
- OrientDB - Basic Concepts
- OrientDB - Data Types
- OrientDB - Console Modes
- OrientDB Database Commands
- OrientDB - Create Database
- OrientDB - Alter Database
- OrientDB - Backup Database
- OrientDB - Restore Database
- OrientDB - Connect Database
- OrientDB - Disconnect Database
- OrientDB - Info Database
- OrientDB - List Database
- OrientDB - Freeze Database
- OrientDB - Release Database
- OrientDB - Config Database
- OrientDB - Export Database
- OrientDB - Import Database
- OrientDB - Commit Database
- OrientDB - Rollback Database
- OrientDB - Optimize Database
- OrientDB - Drop Database
- OrientDB Record Commands
- OrientDB - Insert Record
- OrientDB - Display Records
- OrientDB - Load Record
- OrientDB - Reload Record
- OrientDB - Export Record
- OrientDB - Update Record
- OrientDB - Truncate Record
- OrientDB - Delete Record
- OrientDB Class Commands
- OrientDB - Create Class
- OrientDB - Alter Class
- OrientDB - Truncate Class
- OrientDB - Drop Class
- OrientDB Cluster Commands
- OrientDB - Create Cluster
- OrientDB - Alter Cluster
- OrientDB - Truncate Cluster
- OrientDB - Drop Cluster
- OrientDB Property Commands
- OrientDB - Create Property
- OrientDB - Alter Property
- OrientDB - Drop Property
- OrientDB Vertex Commands
- OrientDB - Create Vertex
- OrientDB - Move Vertex
- OrientDB - Delete Vertex
- OrientDB Edge Commands
- OrientDB - Create Edge
- OrientDB - Update Edge
- OrientDB - Delete Edge
- OrientDB Advanced Concepts
- OrientDB - Functions
- OrientDB - Sequences
- OrientDB - Indexes
- OrientDB - Transactions
- OrientDB - Hooks
- OrientDB - Caching
- OrientDB - Logging
- OrientDB - Performance Tuning
- OrientDB - Upgrading
- OrientDB - Security
- OrientDB - Studio
- OrientDB Interfaces
- OrientDB - Java Interface
- OrientDB - Python Interface
- OrientDB Useful Resources
- OrientDB - Quick Guide
- OrientDB - Useful Resources
- OrientDB - Discussion
OrientDB - Alter Class
Class and Property in OrientDB are used to build a schema with the respective attributes such as class name, super-class, cluster, number of clusters, Abstract, etc. If you want to modify or update any attribute of existing classes in the schema then you have to use Alter Class command.
The following statement is the basic syntax of the Alter Class Command.
ALTER CLASS <class> <attribute-name> <attribute-value>
Following are the details about the options in the above syntax.
<class> − Defines the class name.
<attribute-name> − Defines the attribute you want to change.
<attribute-value> − Defines the value you want to set for the attribute.
The following table defines the list of attributes that support Alter Class command.
Attribute | Type | Description |
---|---|---|
NAME | String | Changes the class name. |
SHORTNAME | String | Defines a short name, (that is, an alias), for the class. Use NULL to remove a short name assignment. |
SUPERCLASS | String | Defines a super-class for the class. To add a new class, you can use the syntax +<class>, to remove it use -<class>. |
OVERSIZE | Decimal number | Defines the oversize factor. |
ADDCLUSTER | String | Adds a cluster to the class. If the cluster doesn't exist, it creates a physical cluster. Adding clusters to a class is also useful in storing records in distributed servers. |
REMOVECLUSTER | String | Removes a cluster from a class. It does not delete the cluster, only removes it from the class. |
STRICTMODE | - | Enables or disables strict mode. When in strict mode, you work in schema-full mode and cannot add new properties to a record if they are part of the class' schema definition. |
CLUSTERSELECTION | - | Defines the selection strategy in choosing which cluster it uses for new records. |
CUSTOM | - | Defines custom properties. Property names and values must follow the syntax <propertyname>=<value> without spaces between the name and value. |
ABSTRACT | Boolean | Converts class to an abstract class or the opposite. |
Example
Let us try few examples that will update or modify the attributes of the existing class.
The following query is used to define a super-class ‘Person’ for an existing class ‘Employee’.
orientdb> ALTER CLASS Employee SUPERCLASS Person
If the above query is executed successfully, you will get the following output.
Class altered successfully
The following query is used to add a super-class ‘Person’ for an existing class ‘Employee’.
orientdb> ALTER CLASS Employee SUPERCLASS +Person
If the above query is executed successfully, you will get the following output.
Class altered successfully