orient db创建顶点

时间:2016-08-10 08:45:36

标签: sql orientdb bulkinsert

我想在Orientdb中创建一些顶点。在SQL中,语法类似于:

create vertex table1 <select [...] from table2>
create edge from <@rid of the new created vertex> to <@rid from table2>

table1和table2之间的关系是一对一的。 我想在OrientDB中做类似的事情(使用foreignKey1 I&#39; ll创建边缘)

post

1 个答案:

答案 0 :(得分:2)

我创建了两个类Table2的顶点

enter image description here

我已使用此代码

var g=orient.getGraph();
var b=g.command("sql","select from table2");
for(i=0;i<b.length;i++){
    var record2=b[i];
    var column1=record2.getProperty("column1");
    var column2=record2.getProperty("column2"); 
    var id=record2.getProperty("id"); 
    var record1=g.command("sql","insert into table1 (col1, col2, foreignKey1) values ('"+ column1 + "','" + column2 + "',"+ id + ") return @this");
    g.commit();
    g.command("sql","create edge e from " + record1.getId() + " to " + record2.getId());
}

我已经获得

enter code here

希望有所帮助