Orientdb 简明教程
OrientDB - Studio
OrientDB 提供了一个 Web UI 来通过 GUI 执行数据库操作。本章介绍 OrientDB 中提供的不同选项。
OrientDB provides a web UI to carry out database operations through GUI. This chapter explains the different options available in OrientDB.
Studio Homepage
Studio 是一个用于管理 OrientDB 的 Web 界面,作为 OrientDB 发行版的一部分提供。
Studio is a web interface for the administration of OrientDB that comes in bundle with the OrientDB distribution.
首先,你需要使用以下命令启动 OrientDB 服务器。
First, you need to start the OrientDB server using the following command.
$ server.sh
在计算机上运行 OrientDB 时,可以通过 URL 访问 Web 界面 −
If you run OrientDB in your machine, the web interface can be accessed via the URL −
http://localhost:2480
如果成功执行了该命令,屏幕上会出现以下输出。
If the command is executed successfully, following will be the output on screen.
Connect to an Existing Database
要登录,请从数据库列表中选择一个数据库,并使用任意数据库用户。默认情况下(用户名/密码), reader/reader 可以读取数据库中的记录, writer/writer 可以读取、创建、更新和删除记录,而 admin/admin 拥有所有权限。
To login, select a database from the databases list and use any database user. By default (username/password) reader/reader can read records from the database, writer/writer can read, create, update and delete records, while admin/admin has all rights.
Drop an Existing Database
从数据库列表中选择一个数据库,然后单击废纸篓图标。Studio 会打开一个确认弹出窗口,你必须在其中输入服务器用户名和服务器密码。
Select a database from the databases list and click the trash icon. Studio will open a confirmation popup where you have to insert the Server User and Server Password.
然后单击“删除数据库”按钮。你可以在 $ORIENTDB_HOME/config/orientdb-server-config.xml 文件中找到服务器凭证。
Then click the "Drop database" button. You can find the server credentials in the $ORIENTDB_HOME/config/orientdb-server-config.xml file.
<users>
<user name = "root" password = "pwd" resources = "*" />
</users>
Create a New Database
要创建一个新数据库,请单击主页上的“新建数据库”按钮。
To create a new database, click the "New DB" button from the homepage.
需要以下信息才能创建新数据库 −
Following information is needed to create a new database −
-
Database name
-
Database type (Document/Graph)
-
Storage type (plocal/memory)
-
Server user
-
Server password
你可以在 $ORIENTDB_HOME/config/orientdbserver-config.xml 文件中找到服务器凭证。
You can find the server credentials in the $ORIENTDB_HOME/config/orientdbserver-config.xml file.
<users>
<user name = "root" password = "pwd" resources = "*" />
</users>
创建后,Studio 会自动登录到新数据库。
Once created, Studio will automatically login to the new database.
Execute a Query
Studio 支持对你正在使用的语言(包括 SQL 和 Gremlin)来自动识别。在编写时,按 Ctrl + Space 使用自动完成功能。
Studio supports auto recognition of the language you’re using between those supported: SQL and Gremlin. While writing, use the auto-complete feature by pressing Ctrl + Space.
查询编辑器中提供以下快捷方式 −
The following shortcuts are available in the query editor −
-
Ctrl + Return − To execute the query or just click the Run button.
-
Ctrl/Cmd + Z − To undo changes.
-
Ctrl/Cmd + Shift + Z − To redo changes.
-
Ctrl/Cmd + F − To search in the editor.
-
Ctrl/Cmd + / − To toggle a comment.
以下截图显示了如何执行查询。
The following screenshot shows how to execute a query.
通过单击结果集中任何 @rid 值,如果记录是文档,您将进入文档编辑模式;否则,您将进入顶点编辑模式。
By clicking any @rid value in the result-set, you will go into document edit mode if the record is a Document, otherwise you will go into vertex edit.
您可以通过单击结果集中或编辑器中的星形图标对查询进行书签。要浏览有书签的查询,请单击 Bookmarks 按钮。Studio 将在左侧打开书签列表,您可以在其中编辑/删除或重新运行查询。
You can bookmark your queries by clicking the star icon in the results-set or in the editor. To browse bookmarked queries, click the Bookmarks button. Studio will open the bookmarks list on the left, where you can edit/delete or rerun queries.
Studio 将执行的查询保存在浏览器的本地存储中。在查询设置中,您可以配置 Studio 在历史记录中保留多少查询。您还可以搜索以前执行的查询、从历史记录中删除所有查询或删除单个查询。
Studio saves the executed queries in the Local Storage of the browser. In the query settings, you can configure how many queries studio will keep in history. You can also search a previously executed query, delete all the queries from the history, or delete a single query.
Edit Vertex
要编辑图表的顶点,请转到图部分。然后运行以下查询。
To edit the vertex of the graph, go to the Graph section. Then run the following query.
Select From Customer
在成功运行查询后,以下是输出屏幕截图。选择图画布中的特定顶点进行编辑。
On successfully running the query, following be the output screenshot. Select the particular vertex in the graph canvas to edit.
选择特定顶点上的编辑符号。您将获得以下屏幕,其中包含编辑顶点的选项。
Select the edit symbol on the particular vertex. You will get the following screen which contains the options to edit the vertex.
Schema Manager
OrientDB 可以以无模式模式、模式模式或两者兼有的模式工作。这里,我们将讨论模式模式。单击 Web UI 顶部的架构部分。您将获得以下屏幕截图。
OrientDB can work in schema-less mode, schema mode or a mix of both. Here we’ll discuss the schema mode. Click on the Schema section on the top of web UI. You will get the following screenshot.
Create a New Class
要创建新类,只需单击 New Class 按钮。将显示以下屏幕截图。您必须提供屏幕截图中所示的以下信息才能创建新类。
To create a new Class, just click the New Class button. Following screenshot will appear. You will have to provide the following information as shown in the screenshot to create the new class.
View All Indexes
当您希望概述数据库中创建的所有索引时,只需单击架构 UI 中的所有索引按钮即可。这将快速访问有关索引的一些信息(名称、类型、属性等),您可以从此处删除或重建它们。
When you want to have an overview of all indexes created in your database, just click he all indexes button in the Schema UI. This will provide a quick access to some information about indexes (name, type, properties, etc.) and you can drop or rebuild them from here.
Edit Class
单击架构部分中的任何类,您将获得以下屏幕截图。
Click on any class on the schema section, you will get the following screenshot.
在编辑类时,您可以添加属性或添加新索引。
While editing a class, you can add a property or add a new index.
Graph Editor
单击图部分。您不仅可以在图样式中可视化数据,还可以与图进行交互并对其进行修改。
Click the graph section. Not only can you visualize your data in a graph style but you can also interact with the graph and modify it.
若要填充图表区域,请在查询编辑器中键入查询或使用浏览界面左的发送到图表功能。
To populate the graph area, type a query in the query editor or use the functionality Send To Graph from the Browse UI.
Add Vertices
若要在图表数据库和图表画布区域中添加新顶点,您必须按下 Add Vertex 按钮。此操作分两步完成。
To add a new Vertex in your Graph Database and in the Graph Canvas area, you have to press the button Add Vertex. This operation is done in two steps.
在第一步,您必须选择新顶点所属的类别,然后单击下一步。
In the first step, you have to choose the class for the new Vertex and then click Next.
在第二步,您必须插入新顶点的字段值。您还可以添加自定义字段,因为 OrientDB 支持无模式模式。若要使新顶点持久化,请单击“保存更改”,然后顶点将被保存到数据库中并添加到画布区域。
In the second step, you have to insert the field values of the new vertex. You can also add custom fields as OrientDB supports schema-less mode. To make the new vertex persistent, click ‘Save changes’ and the vertex will be saved into the database and added to the canvas area.
Delete Vertices
通过单击要删除的顶点打开循环菜单。将鼠标悬停在菜单项更多(…)上打开子菜单,然后单击回收站图标。
Open the circular menu by clicking on the Vertex that you want to delete. Open the submenu by hovering the mouse to the menu entry more (…) and then click the trash icon.
Security
Studio 2.0 包含新的安全管理,您可以在其中以图形方式管理用户和角色。
Studio 2.0 includes the new Security Management, where you can manage Users and Roles in a graphical way.
Users
您可以执行以下操作来管理数据库用户 -
You can perform the following actions to manage the database users −
-
Search Users
-
Add Users
-
Delete Users
-
Edit User: roles can be edited in-line, for name, status and password click the Edit button
Roles
您可以执行以下操作来管理数据库角色 -
You can perform the following actions to manage the database roles −
-
Search Role
-
Add Role
-
Delete Role
-
Edit Role
Add Role
若要添加新用户,请单击 Add Role 按钮,填写新角色的信息(名称、父角色、模式),然后保存以将新角色添加到数据库中。
To add a new User, click the Add Role button, complete the information for the new role (name, parent role, mode) and then save to add the new role to the database.
Add Rule to a Role
若要为所选角色添加新的安全规则,请单击 Add Rule 按钮。这将会询问您要保护的资源字符串。然后,您可以在新创建的资源上配置 CRUD 权限。
To add a new security rule for the selected role, click the Add Rule button. This will ask you the string of the resource that you want to secure. Then you can configure the CRUD permissions on the newly created resource.