Orientdb-alter-class

提供:Dev Guides
移動先:案内検索

OrientDB-クラスの変更

OrientDBのクラスとプロパティは、クラス名、スーパークラス、クラスター、クラスター数、抽象などのそれぞれの属性を持つスキーマを構築するために使用されます。 スキーマ内の既存のクラスの属性を変更または更新する場合は、 Alter Class コマンドを使用する必要があります。

次のステートメントは、クラス変更コマンドの基本的な構文です。

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

上記の構文のオプションに関する詳細を次に示します。

*<class>* -クラス名を定義します。
*<属性名>* -変更する属性を定義します。
*<attribute-value>* -属性に設定する値を定義します。

次の表は、クラス変更コマンドをサポートする属性のリストを定義しています。

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.

既存のクラスの属性を更新または変更するいくつかの例を試してみましょう。

次のクエリは、既存のクラス「従業員」のスーパークラス「個人」を定義するために使用されます。

orientdb> ALTER CLASS Employee SUPERCLASS Person

上記のクエリが正常に実行されると、次の出力が得られます。

Class altered successfully

次のクエリは、既存のクラス「従業員」にスーパークラス「人」を追加するために使用されます。

orientdb> ALTER CLASS Employee SUPERCLASS +Person

上記のクエリが正常に実行されると、次の出力が得られます。

Class altered successfully