首页 > 数据库 > > gStore常用命令/基本用法之增删改查
gStore针对RDF三元组数据增删改查都怎么使用呢,有哪些常用命令和用法,我在使用过程中进行了总结:
rdf_triple_file_path指带".nt"或者".n3"后缀的文件路径
insert data {
<张三> <性别>"男"^^<http://www.w3.org/2001/XMLSchema#String>.
<张三> <年龄>"28"^^<http://www.w3.org/2001/XMLSchema#Int>.
<张三> <好友> <李四>.
}
rdf_triple_file_path指带".nt"或者".n3"后缀的文件路径
例如从lubm数据库中删除lubm.nt中的三元组数据
[root@localhost gStore]$ bin/gsub lubm./data/lubm/lubm.nt
...
argc: 3 DB_store:lubm remove file: ./data/lubm/lubm.nt
...
remove rdf triples done.
removed triples num: 99550
delete data {
<张三> <性别>"男"^^<http://www.w3.org/2001/XMLSchema#String>.
<张三> <年龄>"28"^^<http://www.w3.org/2001/XMLSchema#Int>.
<张三> <好友> <李四>.
}
另外,SPARQL中还可以通过delete where语句来实现根据子查询结构删除数据,例如我们要删除张三实体的所有信息(包括属性和关系):
delete where
{
<张三> ?x ?y.
}
在gstore中,没有直接的修改数据的命令,我们可以通过先删除原数据,再新增实现数据的修改。
数据库查询是gStore最重要的功能之一,数据查询支持使用包含SPARQL查询的文件查询现有数据库。
如查询名为db_name的数据库,输入以下命令:
bin/gquery db_name query_file
参数含义:query_file:以“.sql”结尾的SPARQL语句存放的文件路径(其他后缀名也可以),其中query_file中的具体查询语句语法非常丰富,请查看往期分享。
[root@localhost gStore]$ bin/gquery lubm./data/lubm/lubm_q0.sql
There has answer: 15
final result is :
?x
<http://www.Department0.University0.edu/FullProfessor0>
<http://www.Department1.University0.edu/FullProfessor0>
<http://www.Department2.University0.edu/FullProfessor0>
<http://www.Department3.University0.edu/FullProfessor0>
<http://www.Department4.University0.edu/FullProfessor0>
<http://www.Department5.University0.edu/FullProfessor0>
<http://www.Department6.University0.edu/FullProfessor0>
<http://www.Department7.University0.edu/FullProfessor0>
<http://www.Department8.University0.edu/FullProfessor0>
<http://www.Department9.University0.edu/FullProfessor0>
<http://www.Department10.University0.edu/FullProfessor0>
<http://www.Department11.University0.edu/FullProfessor0>
<http://www.Department12.University0.edu/FullProfessor0>
<http://www.Department13.University0.edu/FullProfessor0>
<http://www.Department14.University0.edu/FullProfessor0>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69946831/viewspace-3159580/ ,如需转载,请注明出处,否则将追究法律责任。