A view is a virtual table defined by a query on one or more tables. A view has the structure of a regular table but does not physically store data. Views can be based on a single table or multiple tables. You can use a single-table view to query and modify data in its underlying base table. A multi-table view is typically read-only and used only for queries. This topic describes how to create, rename, and delete views.
Prerequisites
You must be connected to an instance. For more information, see Connect to an instance.
Create a view
Log on to the Hologres management console.
In the top navigation bar, select a region.
Click Go to HoloWeb to open the HoloWeb developer page.
-
On the HoloWeb development page, go to the Metadata Management page. In the Instances Connected list, expand the target database and schema. Then, right-click Views and select Create View.
-
On the Create View page, configure the parameters, including the Schema, a required View Name, and an optional Description. On the Query Statement tab, enter the SQL query for the view. You can use the Data Preview and DDL Statements tabs to verify your query. When you are finished, click Submit.
Parameter
Description
Schema
The name of the schema.
You can select the default public schema or a custom schema.
View Name
The name of the view.
Description
A description of the view.
Query Statement
Enter the query statement in the editor. The query can be based on a single table or multiple tables.
-
If a view is based on a single table, changes to the view's data are reflected in the table, and vice versa.
-
If a view is based on multiple tables, it is read-only.
NoteBe careful when modifying data in a single-table view. These changes can affect the base table and impact your services.
-
-
Click Submit in the upper-right corner of the page. A success message is displayed in the run log below, and the created view appears in the corresponding directory on the left.
After creating the view, you can open it to review its query statement, DDL statements, and data.
Manage a view
-
On the Metadata Management page, locate the view that you want to manage in the Instances Connected list.
-
You can either browse the list or use the search bar at the top of the navigation pane.
Expand the target instance and database nodes. You can find the view, such as holo_view, under the Views node of the public schema.
You can perform the following operations:
-
Open View
Right-click the view and select Open View to open its details page.
The view details page includes the Query Statement, Data Preview, and DDL Statements tabs. The context menu also includes the Delete View option.
Query View
Click Query View in the upper-right corner. This action opens the Ad-hoc Query page. In the SQL editor, enter an SQL statement and click Run to query the view. For more information about ad-hoc queries, see SQL editor.
For example, enter
SELECT * FROM public.holo_view;in the editor and click run to query the view data.Edit View
Click Edit View, modify the query in the Query Statement area, and then click Submit.
Refresh
After modifying the view, click Refresh to display the updated information.
-
Delete View
To delete the current view, right-click the target view and select Delete View. In the confirmation message, click OK.
-
Create and delete views using SQL
You can also create, query, and delete views by using SQL statements. For details on the required syntax, see VIEW.