Orientdb 简明教程
OrientDB - Create Property
OrientDB 中的 Property 类似于数据库表中的类字段和列。创建属性是一个用于为特定类创建属性的命令。您在命令中使用的类名称必须存在。
Property in OrientDB works like a field of class and column in the database table. Create Property is a command used to create a property for a particular class. The class name that you used in the command must exist.
以下语句是 Create Property 命令的基本语法。
The following statement is the basic syntax of Create Property command.
CREATE PROPERTY <class-name>.<property-name> <property-type> [<linked-type>][ <linked-class>]
以下是上文中选项的详细信息。
Following are the details about the options in the above syntax.
<class-name> − 定义要为其创建属性的类。
<class-name> − Defines the class you want to create the property in.
<property-name> − 定义属性的逻辑名称。
<property-name> − Defines the logical name of the property.
<property-type> − 定义要创建的属性类型。
<property-type> − Defines the type of property you want to create.
<linked-type> − 定义容器类型,用于容器属性类型。
<linked-type> − Defines the container type, used in container property type.
<linked-class> − 定义容器类,用于容器属性类型。
<linked-class> − Defines the container class, used in container property type.
下表为属性提供数据类型,以便 OrientDB 知道要存储的数据类型。
The following table provides the data type for property so that OrientDB knows the type of data to store.
BOOLEAN |
INTEGER |
SHORT |
LONG |
FLOAT |
DATE |
STRING |
EMBEDDED |
LINK |
BYTE |
BINARY |
DOUBLE |
除了这些之外,还有几个其他作为容器的属性类型。
In addition to these there are several other property types that work as containers.
EMBEDDEDLIST |
EMBEDDEDSET |
EMBEDDEDMAP |
LINKLIST |
LINKSET |
LINKMAP |
Example
尝试使用以下示例在类型为 String 的类 Employee 上创建属性名称。
Try the following example to create a property name on the class Employee, of the String type.
orientdb> CREATE PROPERTY Employee.name STRING
如果成功执行了以上查询,您会获得以下输出。
If the above query is executed successfully, you will get the following output.
Property created successfully with id = 1