📅  最后修改于: 2020-11-26 05:27:52             🧑  作者: Mango
OrientDB中的类和属性用于使用各自的属性(例如,类名,超类,集群,集群数,抽象等)构建模式。如果要修改或更新模式中现有类的任何属性,则您必须使用Alter Class命令。
以下语句是Alter Class命令的基本语法。
ALTER CLASS
以下是上述语法中有关选项的详细信息。
下表定义了支持Alter Class命令的属性列表。
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 + |
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 |
ABSTRACT | Boolean | Converts class to an abstract class or the opposite. |
让我们尝试一些示例,这些示例将更新或修改现有类的属性。
以下查询用于为现有类“ Employee”定义超类“ Person”。
orientdb> ALTER CLASS Employee SUPERCLASS Person
如果上面的查询成功执行,您将获得以下输出。
Class altered successfully
以下查询用于为现有类“ Employee”添加超类“ Person”。
orientdb> ALTER CLASS Employee SUPERCLASS +Person
如果上面的查询成功执行,您将获得以下输出。
Class altered successfully