Arangodb 简明教程
ArangoDB - Database Methods
在本章中,我们将讨论 ArangoDB 中不同的数据库方法。
In this chapter, we will discuss the different Database Methods in ArangoDB.
首先,让我们获取数据库的属性——
To start with, let us get the properties of the Database −
-
Name
-
ID
-
Path
首先,我们调用 Arangosh。一旦调用 Arangosh,我们将列出我们到目前为止创建的数据库——
First, we invoke the Arangosh. Once, Arangosh is invoked, we will list the databases we created so far −
我们将使用以下代码行调用 Arangosh——
We will use the following line of code to invoke Arangosh −
127.0.0.1:8529@_system> db._databases()
Output
[
"_system",
"song_collection"
]
我们看到两个数据库,一个 [ _system ] 是默认创建的,另一个 [ song_collection ] 是我们创建的。
We see two databases, one _system created by default, and the second song_collection that we have created.
现在,让我们使用以下代码行切换到 song_collection 数据库——
Let us now shift to song_collection database with the following line of code −
127.0.0.1:8529@_system> db._useDatabase("song_collection")
Output
true
127.0.0.1:8529@song_collection>
我们将探索 song_collection 数据库的属性。
We will explore the properties of our song_collection database.
To find the name
我们将使用以下代码行查找名称。
We will use the following line of code to find the name.
127.0.0.1:8529@song_collection> db._name()
To find the id −
我们将使用以下代码行查找 ID。
We will use the following line of code to find the id.
127.0.0.1:8529@song_collection> db._id()
To find the path −
我们将使用以下代码行查找路径。
We will use the following line of code to find the path.
127.0.0.1:8529@song_collection> db._path()
Output
/var/lib/arangodb3/databases/database-4838
现在,让我们使用以下代码行检查是否在系统数据库中——
Let us now check if we are in the system database or not by using the following line of code −
127.0.0.1:8529@song_collection&t; db._isSystem()
Output
false
这意味着我们不在系统数据库中(因为我们已经创建并切换到了 song_collection)。以下屏幕截图将帮助你理解这一点。
It means we are not in the system database (as we have created and shifted to the song_collection). The following screenshot will help you understand this.
