OrientDB是一個(gè)支持文檔、圖形、鍵值和對(duì)象模型的NoSQL數(shù)據(jù)庫(kù),它允許您以靈活的方式存儲(chǔ)和管理數(shù)據(jù)。以下是創(chuàng)建OrientDB文檔數(shù)據(jù)庫(kù)的步驟:
準(zhǔn)備:
連接到OrientDB數(shù)據(jù)庫(kù):
創(chuàng)建數(shù)據(jù)庫(kù):
CREATE DATABASE
命令創(chuàng)建一個(gè)新的數(shù)據(jù)庫(kù)。CREATE DATABASE local:path/to/database [USER [PASSWORD]] [STORAGE TYPE [DB_TYPE]]
OrientDB
類的open
方法創(chuàng)建數(shù)據(jù)庫(kù)。OrientDB orientDB = new OrientDB("remote:localhost", "admin", "admin");
ODatabaseSession db = orientDB.open("demo", "admin", "admin");
創(chuàng)建類(Class):
CREATE CLASS
命令創(chuàng)建一個(gè)新的類。CREATE CLASS Person
ODatabaseSession
類的createClass
方法創(chuàng)建類。OClass personClass = db.createClass("Person");
插入數(shù)據(jù):
INSERT INTO
命令插入數(shù)據(jù)。INSERT INTO Person SET name = 'Alice', age = 30
OVertex
類的setProperty
方法插入數(shù)據(jù)。OVertex person = db.newVertex("Person");
person.setProperty("name", "Alice");
person.setProperty("age", 30);
person.save();
通過(guò)以上步驟,您可以成功創(chuàng)建并管理OrientDB文檔數(shù)據(jù)庫(kù)。