Orientdb 简明教程
OrientDB - Alter Property
Alter Property 是用来修改或更新特定类的属性的命令。更改属性表示修改表中的字段。在本章中,你可以了解如何更新属性。
Alter Property is a command used to modify or update the Property of a particular class. Altering the property means modifying the fields of a table. In this chapter, you can learn how to update the property.
以下语句是 Alter Property 命令的基本语法。
The following statement is the basic syntax of Alter Property Command.
ALTER PROPERTY <class>.<property> <attribute-name> <attribute-value>
以下是上文中选项的详细信息。
Following are the details about the options in the above syntax.
<class> − 定义属性所属的类。
<class> − Defines the class to which the property belongs.
<property> − 定义要更新的属性。
<property> − Defines the property you want to update.
<attribute-name> − 定义要更新的属性的属性。
<attribute-name> − Defines the attribute of a property you want to update.
<attribute-value> − 定义要设置在属性上的值。
<attribute-value> − Defines the value you want to set on the attribute.
下表定义了用于更改属性的属性列表。
The following table defines the list of attributes to alter the property.
Attribute |
Type |
Description |
LINKEDCLASS |
String |
Defines the linked class name. Use NULL to remove an existing value. |
LINKEDTYPE |
String |
Defines the link type. Use NULL to remove an existing value. |
MIN |
Integer |
Defines the minimum value as a constraint. Use NULL to remove an existing constraint. |
MANDATORY |
Boolean |
Defines whether the property requires a value. |
MAX |
Integer |
Defines the maximum value as a constraint. Use NULL to remove an existing constraint. |
NAME |
String |
Defines the property name. |
NOTNULL |
Boolean |
Defines whether the property can have a NULL value. |
REGEX |
String |
Defines a Regular Expression as constraint. Use NULL to remove an existing constraint. |
TYPE |
String |
Defines a property type. |
COLLATE |
String |
Sets collate to one of the defined comparison strategies. By default, it is set to case-sensitive (cs). You can also set it to case-insensitive (ci). |
READONLY |
Boolean |
Defines whether the property value is immutable. That is, if it is possible to change it after the first assignment. Use with DEFAULT to have immutable values on creation. |
CUSTOM |
String |
Defines custom properties. The syntax for custom properties is <custom-name> = <custom-value>, such as stereotype = icon. |
DEFAULT |
Defines the default value or function. |
Note - 如果要更改 NAME 或 TYPE,则此命令将根据数据量花费一些时间进行更新。
Note − if you are altering NAME or TYPE, this command will take some time to update depending on the amount of data.
Example
尝试一些下面给出的查询来理解 Alter 属性。
Try some queries which are given below to understand Alter property.
执行以下查询,将 Customer 类中属性的名称从“age”更改为“born”。
Execute the following query to change the name of the property from ‘age’ to ‘born’ in the class Customer.
orinetdb {db = demo}> ALTER PROPERTY Customer.age NAME born
如果成功执行了以上查询,您会获得以下输出。
If the above query is executed successfully, you will get the following output.
Property altered successfully
执行以下查询,将“name”设为类“Customer”的强制属性。
Execute the following query to make ‘name’ as the mandatory property of the class ‘Customer’.
orientdb {db = demo}> ALTER PROPERTY Customer.name MANDATORY TRUE
如果成功执行了以上查询,您会获得以下输出。
If the above query is executed successfully, you will get the following output.
Property altered successfully