修改密码

请输入密码
请输入密码 请输入8-64长度密码 和 email 地址不相同 至少包括数字、大写字母、小写字母、半角符号中的 3 个
请输入密码
提交

修改昵称

当前昵称:
提交

申请证书

证书详情

Please complete this required field.

  • Ultipa Graph V4

Standalone

Please complete this required field.

Please complete this required field.

服务器的MAC地址

Please complete this required field.

Please complete this required field.

取消
申请
ID
产品
状态
核数
申请天数
审批时间
过期时间
MAC地址
申请理由
审核信息
关闭
基础信息
  • 用户昵称:
  • 手机号:
  • 公司名称:
  • 公司邮箱:
  • 地区:
  • 语言:
修改密码
申请证书

当前未申请证书.

申请证书
Certificate Issued at Valid until Serial No. File
Serial No. Valid until File

Not having one? Apply now! >>>

ProductName CreateTime ID Price File
ProductName CreateTime ID Price File

No Invoice

搜索
    中文

      插入

      概述

      插入操作向当前图集单一或批量地插入新的点、边数据。insert()insert().overwrite()upsert()这三个命令均可以触发插入操作。本节介绍由insert()命令触发的插入操作。

      插入数据时,需首先指定schema,然后指定全部或部分属性的值,也可以不指定任何属性的值:

      • 指定的UID属性值不能与图集中已有的重复;没有指定UID属性值时,系统会自动生成。
      • 未携带的自定义属性会被赋值为null。
      • 若指定的属性值与其数据类型不符,系统会使用该数据类型的默认值给该属性赋值。各数据类型的默认值如下:
        • ""(string,text)
        • 0(int32,int64,uint32,uint64,float,double,decimal)
        • "1970-01-01 08:00:00 +08:00"(timestamp)
        • "0000-00-00 00:00:00"(datetime)
        • [](list)
        • POINT(0.00 0.00)(point)

      常见的失败原因:

      • 指定的UID属性值在图集中已存在。
      • 插入边时,未指定起点和终点。
      • 插入边时,指定的起点或终点在图集中不存在。

      不建议在流式返回的算法语句之后组装插入语句。

      语法

      • 子句别名:支持,数据类型为NODE或EDGE
      • 参数别名:所有参数均不支持定义别名

      // 向当前图集的某个schema中插入点数据
      insert().into(@<schema>)
        .nodes([				//只插入一个点时可省略中括号
          {<property1>:<value1>, <property2>:<value2>, ...},
          {<property1>:<value1>, <property2>:<value2>, ...},
          ...
        ])
        
      // 向当前图集的某个schema中插入边数据,必须携带_from和_to(或_from_uuid和_to_uuid)
      insert().into(@<schema>)
        .edges([				//只插入一个边时可省略中括号
          {<property1>:<value1>, <property2>:<value2>, ...},
          {<property1>:<value1>, <property2>:<value2>, ...},
          ...
        ])
      

      示例

      指定point和blob类型属性的值

      设置piont和blob类型的属性值时,分别需要使用坐标对象构建函数point()二进制转换函数castToRaw()

      本例插入一个@default点,并携带属性coordinate(point类型)和blob_value(blob类型)的值:

      insert().into(@default).nodes({
        coordinate: point({latitude: 132.1, longitude: -1.5}),
        blob_value: castToRaw("32")
      })
      

      示例图集

      在一个空图集中,依次运行以下各行语句创建示例图集:

      create().node_schema("account").edge_schema("follow")
      create().node_property(@account, "name").edge_property(@follow, "time", datetime)
      insert().into(@account).nodes([{_id:"U001", _uuid:1, name:"Jason"}, {_id:"U002", _uuid:2, name:"Tim"}, {_id:"U003", _uuid:3, name:"Grace"}, {_id:"U004", _uuid:4, name:"Ted"}])
      insert().into(@follow).edges([{_uuid:1, _from_uuid:4, _to_uuid:1, time:"2021-09-10"}, {_uuid:2, _from_uuid:3, _to_uuid:2, time:"2020-03-12"}, {_uuid:3, _from_uuid:4, _to_uuid:2, time:"2023-07-30"}])
      

      属性赋值

      本例插入两个@account点。第一个不携带任何属性,该点的_id_uuid由系统生成,其余属性值为null;第二个点未携带的_uuid由系统生成:

      insert().into(@account).nodes([{}, {_id: "U005", name: "Alice"}]) as nodes
      return nodes{*}
      

      |           _id          | _uuid |  name  |
      |------------------------|-------|--------|
      | ULTIPA8000000000000001 |   5   |  null  |
      | U005                   |   6   | Alice  |
      

      UID重复

      本例指定的点UID(_id)U001在图集中已存在,因此插入失败:

      insert().into(@account).nodes({_id: "U001"}) as nodes
      return nodes{*}
      

      Duplicated ids!
      

      边的起/终点不存在

      本例指定的终点(_to)U010在图集中不存在,因此插入失败:

      insert().into(@follow).edges({_from: "U001", _to: "U010"}) as edges
      return edges{*}
      

      The _to: U010 does not exist!
      
      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写