简体   繁体   English

执行.sql文件以使用OrientDB在Windows系统上导入数据

[英]Execute .sql file for importing data on a Windows system with OrientDB

Hi so I have this example working: 嗨,所以我有这个例子工作:

DECLARE INTENT massiveinsert

CREATE CLASS POST EXTENDS V
CREATE CLASS COMMENT EXTENDS V

INSERT INTO POST (id, title) VALUES ( 10, 'NoSQL movement' );
INSERT INTO POST (id, title) VALUES ( 20, 'New OrientDB' );

INSERT INTO COMMENT (id, postId, text) VALUES ( 0, 10, 'First' );
INSERT INTO COMMENT (id, postId, text) VALUES ( 1, 10, 'Second' );
INSERT INTO COMMENT (id, postId, text) VALUES ( 21, 10, 'Another' );
INSERT INTO COMMENT (id, postId, text) VALUES ( 41, 20, 'First again' );
INSERT INTO COMMENT (id, postId, text) VALUES ( 82, 20, 'Second Again' );

CREATE edge hascomment FROM (select FROM POST) TO (select FROM COMMENT) where comment.postId=post.id
    CREATE LINK comments TYPE linkset FROM comment.postId To post.id INVERSE
UPDATE comment REMOVE postId

But yeah these are 7 test entries. 但是,是的,这是7个测试条目。 I wanted more, so I generated some and stored it in a file. 我想要更多,所以我生成了一些并将其存储在文件中。 So now I wanted to execute that file: 所以现在我想执行该文件:

IMPORT DATABASE POST.sql -merge=true

But that just gives me: 但这给了我:

orientdb {Test2}> import database POST.sql -merge=true

Importing database POST.sql -merge=true... Started import of database
'remote:127.0.0.1/Test2' from POST.sql... Rebuild of stale indexes...
Start rebuild index ouser.name Rebuild  of index ouser.name is
completed. Start rebuild index orole.name Rebuild  of index orole.name
is completed. Stale indexes were rebuilt... Deleting RID Mapping
table...OK

None of the 10.000 entries were created =( 10.000个条目均未创建=(

So my question is how can I execute an external sql file? 所以我的问题是如何执行外部sql文件? And why does the import not work. 以及为什么导入不起作用。 Is import meant that a OrientDB file export is meant? 导入是否意味着OrientDB文件导出? Btw in that file are just "Insert Into .." and if a copy paste a line of them into the console, it works. 顺便说一句,该文件只是“ Insert Into ..”,如果复制将一行内容粘贴到控制台中,它将起作用。

On Linux it would work with "$ console.sh database.sql" (see https://github.com/orientechnologies/orientdb/wiki/Import-RDBMS-to-Document-Model ) but how to do that on Windows? 在Linux上,它可以与“ $ console.sh database.sql”一起使用(请参阅https://github.com/orientechnologies/orientdb/wiki/Import-RDBMS-to-Document-Model ),但是如何在Windows上做到这一点?

Thanks for any help. 谢谢你的帮助。

Edit: 编辑:

Well I now saw that it can only be exported OrientDBs being imported. 好了,现在我看到它只能被导出OrientDB被导入。 Ohh man that's really senseless =/ 哦,那真是毫无意义的人= /

Solution in Windows is: Windows中的解决方案是:

  1. Go to bin folder 转到bin文件夹
  2. Open Console here 在此处打开控制台
  3. Put also a test.sql here with eg: 在这里也放一个test.sql,例如:

    connect remote:127.0.0.1/Test root root 连接远程:127.0.0.1/测试root root

    CREATE CLASS POST EXTENDS V 创建班级后扩展V

    CREATE CLASS COMMENT EXTENDS V 创建班级评论扩展V

    insert into POST (name_id, text) values (83, 'tellus semper interdum mauris ullamcorper purus sit amet nulla quisque arcu libero rutrum ac lobortis vel dapibus at diam nam'); 插入POST(name_id,text)值中(83,'tellam semper interdum mauris ullamcorper purus sitt amet nulla quisque arcu libero rutrum ac lobortis vel dapibus at diam nam');

  4. Now write in console: console.bat test.sql 现在在控制台中编写:console.bat test.sql

That's it. 而已。 Some how it didn't work at my first try... 一些我第一次尝试时不起作用的方法...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM