Orientdb 简明教程
OrientDB - Create Vertex
OrientDB 数据库不仅是文档数据库,还是图形数据库。新概念(如顶点和边)用于以图形形式存储数据。它对顶点应用多态性。顶点的基类是 V。
OrientDB database is not only a Document database but also a Graph database. New concepts such as Vertex and Edge are used to store the data in the form of graph. It applies polymorphism on vertices. The base class for Vertex is V.
在本教程中,您可以了解如何创建顶点来存储图形数据。
In this chapter you can learn how to create vertex to store graph data.
以下是 Create Vertex Command 的基本语法。
The following statement is the basic syntax of Create Vertex Command.
CREATE VERTEX [<class>] [CLUSTER <cluster>] [SET <field> = <expression>[,]*]
以下是上文中选项的详细信息。
Following are the details about the options in the above syntax.
<class> − 定义顶点所属的类。
<class> − Defines the class to which the vertex belongs.
<cluster> −定义存储顶点的群集。
<cluster> − Defines the cluster in which it stores the vertex.
<field> −定义希望设置的字段。
<field> − Defines the field you want to set.
<expression> −定义要为该字段设置的表达式。
<expression> − Defines the express to set for the field.
Example
尝试以下示例来了解如何创建顶点。
Try the following example to understand how to create vertex.
执行以下查询来创建不带“name”且在基本类 V 上的顶点。
Execute the following query to create a vertex without ‘name’ and on the base class V.
orientdb> CREATE VERTEX
如果成功执行了以上查询,您会获得以下输出。
If the above query is executed successfully, you will get the following output.
Created vertex 'V#9:0 v1' in 0.118000 sec(s)
执行以下查询创建一个名为 v1 的新顶点类,然后在该类中创建顶点。
Execute the following query to create a new vertex class named v1, then create vertex in that class.
orientdb> CREATE CLASS V1 EXTENDS V
orientdb> CREATE VERTEX V1
如果成功执行了以上查询,您会获得以下输出。
If the above query is executed successfully, you will get the following output.
Created vertex 'V1#14:0 v1' in 0.004000 sec(s)
执行以下查询创建一个名为 v1 的类的新顶点,定义其属性,例如 brand = 'Maruti' 和 name = 'Swift'。
Execute the following query to create a new vertex of the class named v1, defining its properties such as brand = 'Maruti' and name = 'Swift'.
orientdb> CREATE VERTEX V1 SET brand = 'maruti', name = 'swift'
如果成功执行了以上查询,您会获得以下输出。
If the above query is executed successfully, you will get the following output.
Created vertex 'V1#14:1{brand:maruti,name:swift} v1' in 0.004000 sec(s)