0% found this document useful (0 votes)
105 views40 pages

Vertica Community Edition Virtual Machine User Guide

Vertica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views40 pages

Vertica Community Edition Virtual Machine User Guide

Vertica
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Vertica Community Edition

Virtual Machine User Guide


Vertica Analytic Database
Software Version: 10.0.x

Document Release Date: 8/31/2020


Vertica Community Edition Virtual Machine User Guide

Legal Notices
Warranty
The only warranties for Micro Focus or one of its affiliates products and services are set forth in the express
warranty statements accompanying such products and services. Nothing herein should be construed as
constituting an additional warranty. Micro Focus shall not be liable for technical or editorial errors or
omissions contained herein.

The information contained herein is subject to change without notice.

Restricted Rights Legend


Confidential computer software. Valid license from Micro Focus required for possession, use or copying.
Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation,
and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard
commercial license.

Copyright Notice
© Copyright 2007 - 2020 Micro Focus or one of its affiliates

Trademark Notices
Adobe™ is a trademark of Adobe Systems Incorporated.

Apache® Hadoop® and Hadoop are either registered trademarks or trademarks of the Apache Software
Foundation in the United States and/or other countries.

Microsoft® and Windows® are U.S. registered trademarks of Microsoft Corporation.

UNIX® is a registered trademark of The Open Group.

This product includes an interface of the 'zlib' general purpose compression library, which is Copyright ©
1995-2002 Jean-loup Gailly and Mark Adler.

Micro Focus Vertica Analytic Database (10.0.x) Page 2 of 40


Contents
Legal Notices 2

Warranty 2

Restricted Rights Legend 2

Copyright Notice 2

Trademark Notices 2

About This Document 5

Get Started with the Vertica Community Edition VM 6

Download the Vertica CE VM and the Vertica Documentation 6

Startup and Log In to the Vertica CE VM 7

What's in the VM? 8

Install the Vertica Documentation on VMware 8

Install the Vertica Documentation on VirtualBox 9

Browse the Vertica Documentation 9

The Vertica Client Tools 10

Get Started With Management Console 11

Log In to Management Console 11

The Exploring New Features Dialog Box 12

View the Management Console Home Page 13

View High-Level Details About the Database and Cluster 14

View VMart Status 15

Why Is Vmart Yellow? 16

Is VMart in Compliance? 17

Configure the Database and MC 18

Query Execution 19

Vertica Analytic Database (10.0.x) Page 3 of 40


Vertica Community Edition Virtual Machine User Guide

Explain Plans and Query Profiles 24

Explore the Overview Tab 26

Learn More About Management Console 27

Get Started with Administration Tools 28

admintools GUI: Check the Database 29

admintools GUI: Execute vsql Commands 30

admintools Command Line: Check the Database 30

admintools Command Line: Access Help 32

Learn More About Administration Tools 33

Get Started with vsql 34

Start vsql 34

Display a List of vsql Commands 35

Execute vsql Commands 36

Load Online Sales Data 38

Exit vsql 39

Learn More About vsql 40

Vertica Analytic Database (10.0.x) Page 4 of 40


Vertica Community Edition Virtual Machine User Guide

About This Document


The goal of this document is to introduce you to Vertica by guiding you through a set of
common tasks. As you follow along, you will learn how to use the Vertica Management
Console, Administration Tools, and vsql.

Documentation references with each example will help you learn how to find the
information you need when you need it.

Important:
To benefit from the documentation references in this document, you must
download and install the Vertica documentation. Follow the instructions in
Get Started with the Vertica Community Edition VM.

If you read this document on the Vertica website, the documentation links
will not work.

Vertica Analytic Database (10.0.x) Page 5 of 40


Vertica Community Edition Virtual Machine User Guide

Get Started with the Vertica


Community Edition VM
The Vertica Community Edition Virtual Machine (Vertica CE VM) is a preconfigured Linux
environment that offers a hands-on introduction to the Vertica Analytic Database. After you
complete the steps described in the following topics, the environment runs locally on your
computer and does not require internet access.

Download the Vertica CE VM and the Vertica Documentation


If you have not already downloaded the Vertica CE VM and the Vertica documentation,
follow these steps:

1. Navigate to Vertica Downloads - Community Edition.


2. Log in or create an account.
3. Under Vertica Community Virtual Machine, click the Download link for your
virtualization platform.

Note:
The Vertica CE VM is available in two virtualization formats: one for
VMware, the other for Oracle VM VirtualBox.

4. Accept the license agreement.


5. Save the file on your computer.
6. Download the Vertica documentation (optional):

Important:
The documentation ZIP file contains the entire Vertica
documentation set. The documentation links in this user guide only
work when the Vertica documentation is installed locally in the VM.

l VMware: Download the documentation ZIP file:


A. Navigate to Vertica Documentation.
B. Click Complete Documentation: Zipped HTML.
C. Click Save to save the ZIP file on your computer.

Vertica-user-doc_10.0.x-for-download.zip

The instructions in Install the Vertica Documentation on VMware explain how to


copy/paste or drag the documentation ZIP file into the VM.

Vertica Analytic Database (10.0.x) Page 6 of 40


Vertica Community Edition Virtual Machine User Guide

l VirtualBox: You will download the documentation later as explained in Install the
Vertica Documentation on VirtualBox.

Startup and Log In to the Vertica CE VM


1. Locate the VM file that you downloaded.
The file for VMware has a ZIP extension. The file for VirtualBox has an OVA extension
or a TAR extension, depending on the browser you used for the download.

VMWare: Unzip the file.


l

l VirtualBox: If the file has a TAR extension, change it to OVA.

2. Open the file in your VM player.


l VMWare: Open the VMX file.

Note:
On initial startup only, VMware displays this message. Click I
copied it to dismiss the message.

lVirtualBox: Import the OVA file.


3. Start up the VM.
Note:
Startup may take some time.

4. Log in to the VM with these credentials:.


User: Vertica DBA

Password: password

Vertica Analytic Database (10.0.x) Page 7 of 40


Vertica Community Edition Virtual Machine User Guide

What's in the VM?


When you launch the VM, you will find these components up and running and ready for use:

l Vertica Analytic Database Community Edition


l Vertica Management Console
l Vertica VMart example database
Note:
VMart is fully loaded except for the online_sales fact table and
its two unique dimensions. Instructions for loading the missing data
are provided as an exercise in the topic Get Started with vsql.

Install the Vertica Documentation on VMware


1. On the VM desktop, double click home, then double click Vertica_Docs to navigate to
/home/Vertica_Docs/.

Important:
You must be logged in as dbadmin.

Vertica Analytic Database (10.0.x) Page 8 of 40


Vertica Community Edition Virtual Machine User Guide

2. Navigate to the location where you downloaded the Vertica documentation ZIP file on
your computer. The name of the ZIP file is:
Vertica-user-doc_10.0.x-for-download.zip

3. To copy the Vertica documentation ZIP file to /home/Vertica_Docs/ in the VM,


drag it or copy and paste it.
4. Open a terminal window in the VM.
5. Execute the following commands:

$ cd /home/dbadmin/Vertica_Docs/
$ unzip Vertica-user-doc_10.0.x-for-download.zip -d /home/dbadmin/Vertica_Docs/

Install the Vertica Documentation on VirtualBox


1. In the VM, open this link: https://www.vertica.com/documentation/vertica/10-0-x-
documentation/.
Important:
You must be logged in as dbadmin.

2. Click Complete Documentation: Zipped HTML.


3. Click Save to save the ZIP file to the Downloads folder in the VM.
Vertica-user-doc_10.0.x-for-download.zip

4. Move the ZIP file to this folder:

/home/dbadmin/Vertica_Docs/

5. Right-click the ZIP file and select Extract here.

Browse the Vertica Documentation


After downloading and unzipping the documentation:

l Take a look at the Vertica documentation home page.


l Refer to Introducing the VMart Example Database to learn about the VMart example
data used in the exercises.

Vertica Analytic Database (10.0.x) Page 9 of 40


Vertica Community Edition Virtual Machine User Guide

The Vertica Client Tools


Vertica has a set of client tools for managing your Vertica environment and for querying
and managing your data. The interfaces support a full range of tasks, from scripting to
generating informative performance charts.

Management Console Administration Tools


(MC) (admintools) vsql

Launch from... Browser Terminal Terminal

Manage clusters and YES YES YES


databases

Visualize operations YES NO NO


and performance

Allow scripting NO YES YES

Run SQL Query Execution tab Connect to Database vsql


menu item command

Get started Get Started With Get Started with Get Started
Management Console Administration Tools with vsql

Tip:
See Administration Tools and Management Console in the Vertica
documentation for a detailed comparison of the functionality in
Management Console and Administration Tools.

Vertica Analytic Database (10.0.x) Page 10 of 40


Vertica Community Edition Virtual Machine User Guide

Get Started With Management


Console
Vertica Management Console (MC) is a user-friendly performance monitoring and
management tool that provides a unified view of your Vertica database operations. Using a
browser, you can create, import, manage, and monitor one or more databases and their
associated clusters. You can also create and manage MC users and map them to Vertica
users.

Log In to Management Console


1. Double click the Management Console icon on the VM desktop.
Vertica Management Console opens in a browser at URL address
https://127.0.0.1:5450/webui

2. Click the Login button to log in with the credentials supplied in the dialog box:
Username: uidbadmin

Password: password

Vertica Analytic Database (10.0.x) Page 11 of 40


Vertica Community Edition Virtual Machine User Guide

The Exploring New Features Dialog Box


After you log in, the Management Console home page displays a dialog box entitled
Exploring New Features in Vertica. The dialog box provides links to topics in the Vertica
documentation that describe new or changed features in this release.

The links in the dialog box are URLs to the Vertica documentation on the Vertica website. If
you have a network connection and the VM recognizes it, you can click the links to view the
documentation. However, we recommend that you skip this exploration step until you have
completed the exercises in this document. If you have loaded the Vertica documentation
into the VM, you can find these same topics locally in the VM.

To close the dialog box, simply click OK. On subsequent logins, you can suppress the dialog
box by clicking Do not display this message again.

Vertica Analytic Database (10.0.x) Page 12 of 40


Vertica Community Edition Virtual Machine User Guide

View the Management Console Home Page


The first screen you see when you log in to Management Console is a portal that provides
single-click access to the main functional areas of the tool.

Under Recent Databases, we see the VMart example database, which was created and
imported into MC as part of VM creation.

NEXT STEP: Under Manage, click View Your Infrastructure to open the Infrastructure
page.

Vertica Analytic Database (10.0.x) Page 13 of 40


Vertica Community Edition Virtual Machine User Guide

View High-Level Details About the Database and Cluster


The Database and Cluster View tab provides a high-level view of the databases and clusters
that you can examine and administer within MC. On this page, you can start and stop
databases and remove databases from MC. When you remove a database, it still exists but
is no longer accessible within MC.

ACTION: Click the VMart database to display information about it.

NEXT STEP: Click View to open the Overview page for VMart.

Vertica Analytic Database (10.0.x) Page 14 of 40


Vertica Community Edition Virtual Machine User Guide

View VMart Status


The Overview page is a dashboard that displays key indicators about the database,
including node status, memory, CPU activity, disk space usage, and query activity.

ACTIONS:

l Click the speedometer icon to display the System Health dashboard.


l Click the bar chart icon to display the Query Synopsis dashboard.

NEXT STEP: Click the Manage tab at the bottom of the page.

Vertica Analytic Database (10.0.x) Page 15 of 40


Vertica Community Edition Virtual Machine User Guide

Why Is Vmart Yellow?


The Manage tab displays a graphical representation of each database node with its IP
address, node name, status, hardware detail, and health rating.

If you select Memory Utilization from the KPI View drop-down list, VMart displays as
yellow, indicating that its status is CRITICAL. Even before making a selection, VMart may
display as yellow. Why? The Vertica CE VM hosts a single node cluster, but a minimum of
three nodes is required for high availability. MC considers the status of VMart to be critical,
because if the node goes down then the database will be down.

To learn about high availability in Vertica, read the topic on K-Safety in the Vertica
documentation.

ACTIONS:

For each of the items on the KPI View drop-down list:

1. Select the item.


2. Watch the visuals and values change.

NEXT STEP: Click the License tab to view the status of the license for VMart.

Vertica Analytic Database (10.0.x) Page 16 of 40


Vertica Community Edition Virtual Machine User Guide

Is VMart in Compliance?
The License tab displays information about database licensing and compliance. On this tab,
you can monitor license usage over time and be prepared if expiration is pending or if
you're approaching the maximum allowable data size.

ACTION: Click the Audit button.

Questions:

l When does the Vertica Community Edition license expire?


l What is the maximum allowable data size for this license?

NEXT STEP: Click the Settings tab.

Vertica Analytic Database (10.0.x) Page 17 of 40


Vertica Community Edition Virtual Machine User Guide

Configure the Database and MC


On the Settings tab, you can set database options and configure several response thresholds
in MC. For example, you can set the Tuple Mover interval in the database, and you can
configure MC to raise an alert when memory usage on the node reaches a certain
percentage.

ACTIONS: Click each option on the side menu and note the controls and settings for each
one.

NEXT STEP: Click the Query Execution tab.

Vertica Analytic Database (10.0.x) Page 18 of 40


Vertica Community Edition Virtual Machine User Guide

Query Execution
After you click the Query Execution tab, the SQL window opens. In this window, you can run
SQL statements in the Vertica database. Key components of the SQL window include:

l Query History—A recall window, where MC saves SQL statements after they are
executed. You can recall and rerun any of the SQL stored in the recall window.
l Edit window—A window where you can specify SQL statements. You can type SQL,
paste it from the recall window, or import it from a file.
l Execute Query bar—Click this bar to execute the query in the edit window.
l Results window—A window where the results of SQL execution are posted. In this
pane, there are also actions you can perform based on SQL results. For example: you
can export the results to a csv file.

ACTIONS:

To execute a query from Query History:

1. Click the query labeled query2 to display it in the edit window.


2. Click the Format SQL icon and watch the results.
3. Click the Execute Query bar. Observe the results in the results window.
4. Click Auto-Resize all columns to set column widths to the longest value in the
column.

Vertica Analytic Database (10.0.x) Page 19 of 40


Vertica Community Edition Virtual Machine User Guide

5. Click Export Data to export the query results to a csv file, pipe it directly into
LibreOffice Calc, or save it to a file.

To execute a query by typing it in the edit window:

1. Clear the edit window and results window by clicking the Clear button (eraser icon).
2. In the edit window, type:

select version()

3. Click the Execute Query bar.


The version of the Vertica server displays in the results window.

You can type multiple SQL commands in the edit window. Terminate each command
with a semicolon. MC parses the commands and executes them individually. Each
command has its own result set tab in the results window.

To execute a query from a file:

1. Click the eraser icon to clear the edit window and results window.
2. Click the Import SQL Script icon.
3. Select the example_vmart_query_02.sql file and click Open. If the file is not
visible, navigate to /opt/vertica/examples/VMart_Schema.

The file is loaded into the edit window.

4. Click the Execute Query bar to run the SQL and generate the result set in the results
window.

Vertica Analytic Database (10.0.x) Page 20 of 40


Vertica Community Edition Virtual Machine User Guide

NEXT STEPS:

1. Click the Query Profile tab in the results window to display th profile associated with
the query you just ran.
The query profile does not display, because profiles are not generated automatically
for queries that run in less that one second.

2. To generate the profile, prepend the word PROFILE to the query.


3. Click Execute Query, then select the Query Profile tab.
Some of the profile data displays in the Query Profile tab.

Vertica Analytic Database (10.0.x) Page 21 of 40


Vertica Community Edition Virtual Machine User Guide

4. To see more of the query profile data, click View more profile information.

The Query Plan page displays.

Vertica Analytic Database (10.0.x) Page 22 of 40


Vertica Community Edition Virtual Machine User Guide

Note:
If you click the Explain or Profile button on the Query Plan page,
Management Console refreshes the text of the query, including the
keyword PROFILE. This behavior causes an error, as shown:

To work around this error, simply delete the PROFILE keyword from
the text of the query and click the Explain or Profile button a second time.

Vertica Analytic Database (10.0.x) Page 23 of 40


Vertica Community Edition Virtual Machine User Guide

Explain Plans and Query Profiles


Explain plans and query profiles are useful for performance analysis. You can generate
explain plans and query profiles on the Query Plans tab of MC. Follow these steps to profile
the query you executed in the previous section, take corrective action, and then verify the
results.

1. After you profile the query and review the path information, note that NO STATISTICS
appears in red. Note also the Cost and Rows detail, which is generated by the Vertica
Optimizer. Cost is the estimated cost of the query. Rows is the number of rows to be
returned for that specific step of the query execution.

+-JOIN HASH [Semi] [Cost: 1K, Rows: 75K (NO STATISTICS)] (PATH ID: 1)
+-- Outer -> JOIN HASH [Anti][NotInAnti] [Cost: 732, Rows: 150K (NO STATISTICS)] (PATH
ID: 2)
+-- Outer -> STORAGE ACCESS for orders [Cost: 546, Rows: 300K (NO STATISTICS)] (PATH ID:
3)
+---> STORAGE ACCESS for vendor_dimension [Cost: 10, Rows: 25 (NO STATISTICS)] (PATH ID:
5)
+---> STORAGE ACCESS for store_dimension [Cost: 10, Rows: 125 (NO STATISTICS)] (PATH ID:
7)

Without statistics, the optimizer may not plan an efficient execution of the query.

2. Apply statistics as follows:

1. Return to the Query Execution tab.


2. In the edit window, type the following SQL statement:

select analyze_statistics('')

(The tick marks in parentheses are single quotation marks.)

3. Click the Execute Query bar.


After a few seconds, the statement returns 0 for success.

3. Clear the screen, then recall the query labeled query2 and execute it.

4. Click Query Profile, then click View More Profile Information.

Vertica Analytic Database (10.0.x) Page 24 of 40


Vertica Community Edition Virtual Machine User Guide

5. Click the Profile button.

Note:
The cost values have increased slightly, but the number of rows
returned has decreased significantly. This means that the optimizer is
doing a more efficient job of returning only rows meeting the filter
criteria, which should equate to faster times and less memory usage.

NO STATISTICS:

+-JOIN HASH [Semi] [Cost: 1K, Rows: 75K (NO STATISTICS)] (PATH ID: 1)
+-- Outer -> JOIN HASH [Anti][NotInAnti] [Cost: 732, Rows: 150K (NO STATISTICS)] (PATH
ID: 2)
+-- Outer -> STORAGE ACCESS for orders [Cost: 546, Rows: 300K (NO STATISTICS)] (PATH ID:
3)
+---> STORAGE ACCESS for vendor_dimension [Cost: 10, Rows: 25 (NO STATISTICS)] (PATH ID:
5)
+---> STORAGE ACCESS for store_dimension [Cost: 10, Rows: 125 (NO STATISTICS)] (PATH ID:
7)

WITH STATISTICS

+-JOIN HASH [Semi] [Cost: 2K, Rows: 18K] (PATH ID: 1)


+-- Outer -> JOIN HASH [Anti][NotInAnti] [Cost: 1K, Rows: 35K] (PATH ID: 2)
+-- Outer -> STORAGE ACCESS for orders [Cost: 1K, Rows: 71K] (PATH ID: 3)
+---> STORAGE ACCESS for vendor_dimension [Cost: 35, Rows: 3] (PATH ID: 5)
+---> STORAGE ACCESS for store_dimension [Cost: 35, Rows: 16] (PATH ID: 7)

Vertica Analytic Database (10.0.x) Page 25 of 40


Vertica Community Edition Virtual Machine User Guide

Explore the Overview Tab


Now that we've seen some of the capabilities of MC, let's take a look at the Overview tab.
In this tab, you can see summarized information about the database. Some of the items on
this tab are actually links; you can click them to display additional details. You can learn
more about other items by hovering your mouse over them.

ACTIONS:

1. At the bottom of the page, click the Overview tab. If the Status Summary page is not
displayed, click the monitor icon on the upper left.
2. In the CPU/Memory/Disk I/O section, hover over the Avg Mem Usage (%) line in the
line graph.
3. Observe the additional details for this point in time.
4. Click a point in the timeline to open an exploded view of this time.
5. Click the Back arrow in your browser to return to the Status Summary page.

Vertica Analytic Database (10.0.x) Page 26 of 40


Vertica Community Edition Virtual Machine User Guide

Learn More About Management Console


To learn more about the Vertica Management Console, see these topics in the Vertica
documentation:

l Management Console
l Using Management Console

Vertica Analytic Database (10.0.x) Page 27 of 40


Vertica Community Edition Virtual Machine User Guide

Get Started with Administration


Tools
The Administration Tools interface allows you to manage your Vertica environment from a
Linux shell.

You can use Administration Tools within an interactive graphical user interface, or you can
use the command line. The command line is useful for scripting.

Tip:
The vsql commands in these examples are stored in the command history
buffer in the VM. Instead of typing a command, you can press the Up arrow
and select it from the list.

Start the Administration Tools GUI


1. Right-click the desktop and select Open Terminal.
2. At the Linux command line, type admintools.

The Main Menu displays.

Vertica Analytic Database (10.0.x) Page 28 of 40


Vertica Community Edition Virtual Machine User Guide

admintools GUI: Check the Database


1. To see if the database is up, select option 1 View Database Cluster State and click
OK.

The database status displays. We see that the VMart database is up and that all host
computers are running.

2. To return to the Main Menu, click OK.


3. To view details about the database, select option 6 Configuration Menu and click OK.
4. On the Configuration Menu, select option 3 View Database and click OK.

5. On the Select database to view screen, press the space bar to select VMart and click
OK.

Vertica Analytic Database (10.0.x) Page 29 of 40


Vertica Community Edition Virtual Machine User Guide

Details about the VMart database display.

6. Click OK.
7. Scroll to option M Main Menu, then click OK.

admintools GUI: Execute vsql Commands


1. To run sql statements against the database using the vsql command line, select option
2 Connect to Database and click OK.
2. Type the password for connecting to the VMart database and click OK.
The password is password.

The vsql prompt displays.

3. To display the version of vsql, type select version();as shown:


dbadmin=> select version();

4. To exit vsql and return to the Administration Tools GUI, type \q.
5. To exit the Administration Tools GUI, select option E Exit and click OK.

admintools Command Line: Check the Database


To check database status and details using the Administration Tools command line:

Vertica Analytic Database (10.0.x) Page 30 of 40


Vertica Community Edition Virtual Machine User Guide

1. Right-click the desktop and select Open Terminal.


2. To check if the database is up, type the following command at the Linux command
prompt:

[dbadmin@localhost ~]$ admintools -t db_status -s UP

This command returns the following, indicating that the VMart database is running:

VMart

3. To view details about the database, type this command:

[dbadmin@localhost ~]$ admintools -t list_db -d VMart

This command returns the following:

Database: VMart
Database Log: /vertica/data/VMart/dbLog, /vertica/data/VMart/v_vmart_node0001_
catalog/vertica.log
Hosts: 127.0.0.1
Restart Policy: always
Port: 5433
Catalog Directory: /vertica/data/VMart/v_vmart_node0001_catalog
[dbadmin@localhost ~]$

Vertica Analytic Database (10.0.x) Page 31 of 40


Vertica Community Edition Virtual Machine User Guide

admintools Command Line: Access Help


1.  To access admintools Help, type this command:

[dbadmin@localhost ~]$ admintools --help

This command returns the following:

Usage: admintools [options]


Options:
-h, --help Display this help. Can be combined with -t <tool> for
help on a specific tool
-a, --help_all List all command line sub-commands and switches
--debug Set adminTool logging in debug mode
-t, --tool name_of_tool
Invoke an available tool. Example: admintools -t connect_db -d VMart
Available tools:
command_host
connect_db
create_db
.
.
.

2. To get help on a specific tool, type a command like the one shown here for the list_
node tool:

[dbadmin@localhost ~]$ admintools -t list_node -help

This command returns the following:

Usage: admintools [options]


Usage: list_node [options]
Options:
-h, --help show this help message and exit
-n NODENAME, --node=NODENAME
Name of the node to be listed

Vertica Analytic Database (10.0.x) Page 32 of 40


Vertica Community Edition Virtual Machine User Guide

Learn More About Administration Tools


To learn more about the Vertica Administration Tools, see these topics in the Vertica
documentation:

l Administration Tools
l Using the Administration Tools

Vertica Analytic Database (10.0.x) Page 33 of 40


Vertica Community Edition Virtual Machine User Guide

Get Started with vsql


vsql is a character-based, interactive utility that lets you type SQL statements and see the
results. vsql also provides meta-commands and several shell-like features for writing scripts
and automating various tasks.

Tip:
The vsql commands in these examples are stored in the command history
buffer in the VM. Instead of typing a command, you can press the Up arrow
and select it from the list.

Start vsql
1. Right-click the desktop and select Open Terminal.
2. Change to the directory that contains the VMart example scripts used in this exercise:

[dbadmin@localhost ~]$ cd /opt/vertica/examples/VMart_Schema

3. Start vsql and type password for the password:

[dbadmin@localhost VMart_Schema]$ vsql


Password:

The following text displays:

Welcome to vsql, the Vertica Analytic Database interactive terminal.


Type:
\h or \? for help with vsql commands
\g or terminate with semicolon to execute query
\q to quit

Vertica Analytic Database (10.0.x) Page 34 of 40


Vertica Community Edition Virtual Machine User Guide

Display a List of vsql Commands


1. To display a list of vsql commands, type \? as shown:
dbadmin=> \?

The following output displays:

See the Vertica Programmer's Guide for information on available commands.


General
\c[onnect] [DBNAME|- [USER]]
connect to new database (currently "dbadmin")
\cd [DIR] change the current working directory
\q quit vsql
\set [NAME [VALUE]]
set internal variable, or list all if no parameters
\timing [on|off]
toggle timing of commands, or explicitly turn it on or off (currently
off)
.
.
.

2. To view more output, press the space bar.


3. To quit displaying output, type q.

Vertica Analytic Database (10.0.x) Page 35 of 40


Vertica Community Edition Virtual Machine User Guide

Execute vsql Commands


1. Type \d to see a list of user tables:

dbadmin=> \d

The list of tables displays:

List of tables
Schema | Name | Kind | Owner | Comment
-------------+----------------- -----+-------+---------+--------
online_sales | call_center_dimension | table | dbadmin |
online_sales | online_page_dimension | table | dbadmin |
online_sales | online_sales_fact | table | dbadmin |
public | customer_dimension | table | dbadmin |
public | date_dimension | table | dbadmin |
public | employee_dimension | table | dbadmin |
public | inventory_fact | table | dbadmin |
public | product_dimension | table | dbadmin |
public | promotion_dimension | table | dbadmin |
public | shipping_dimension | table | dbadmin |
public | vendor_dimension | table | dbadmin |
public | warehouse_dimension | table | dbadmin |
store | store_dimension | table | dbadmin |
store | store_orders_fact | table | dbadmin |
store | store_sales_fact | table | dbadmin |
(15 rows)

Note:
\d is an example of a meta-command in vsql. Meta-commands begin
with an unquoted backslash character and are processed by vsql
itself. These commands help make vsql more useful for
administration or scripting.

See Meta-Commands in the Vertica documentation for details.

Vertica Analytic Database (10.0.x) Page 36 of 40


Vertica Community Edition Virtual Machine User Guide

2. Type \ds to see a list of system tables:

dbadmin=> \dS

The list of system tables displays:

List of tables
Schema | Name | Kind | Description
|Comment
----------+----------------- +-------+---------------------------------------------------
+-----------
v_catalog |access_policy |system |Access Policy information
|
v_catalog |all_tables |system |A complete listing of all tables and views
|
v_catalog |client_auth |system |Client Authentication Detailed information
|
v_catalog |client_auth_params|system |Client Authentication Paramters
|
v_catalog |cluster_layout |system |Current cluster layout with relative order of
nodes|
v_catalog |columns |system |Table column information
|
v_catalog |comments |system |User comments on catalog objects
|
v_catalog |constraint_columns|system |Table column constraint information
|
v_catalog |databases |system |Database information
|
v_catalog |directed_queries |system |Directed queries
|
.
.
.

To view more output, press the space bar. To quit displaying output, type q.

3. Query the system table projection_storage as shown:

dbadmin=> select projection_name,sum(row_count) from projection_storage where projection_


schema = 'online_sales' group by projection_schema, projection_name order by sum(row_
count);

The query returns the following:

projection_name | sum
---------------------+-----
(0 rows)

Vertica Analytic Database (10.0.x) Page 37 of 40


Vertica Community Edition Virtual Machine User Guide

Load Online Sales Data


Follow these steps to load data into the online-sales fact table and its two unique

dimensions:

1. View the content of the external SQL script called vmart_load_online_sales_data.sql.


Press the Up arrow repeatedly until you find the following command. Select it to
execute the command from History.

dbadmin=> \! cat /opt/vertica/examples/VMart_Schema/vmart_load_online_sales_data.sql

The content of the SQL script file displays:

\set t_pwd '/opt/vertica/examples/VMart_Schema'

\set input_file '''':t_pwd'/Online_Page_Dimension.tbl'''


COPY online_sales.Online_Page_Dimension FROM :input_file DELIMITER '|' NULL '' DIRECT;
\set input_file '''':t_pwd'/Call_Center_Dimension.tbl'''
COPY online_sales.Call_Center_Dimension FROM :input_file DELIMITER '|' NULL '' DIRECT;
\set input_file '''':t_pwd'/Online_Sales_Fact.tbl'''
COPY online_sales.Online_Sales_Fact FROM :input_file DELIMITER '|' NULL '' DIRECT;

2. Run the external SQL script to load the data:

dbadmin=> \i /opt/vertica/examples/VMart_Schema/vmart_load_online_sales_data.sql

The script loads the data and displays the following:

Rows Loaded
-------------
1000
(1 row)

Rows Loaded
-------------
200
(1 row)

Rows Loaded
-------------
5000000
(1 row)

Vertica Analytic Database (10.0.x) Page 38 of 40


Vertica Community Edition Virtual Machine User Guide

3. Rerun the query of the system table projection_storage to see the effect of the data
load:
Press the Up arrow repeatedly until you find the following command. Select it to
execute the command from History.

dbadmin=> select projection_name,sum(row_count) from projection_storage where projection_


schema = 'online_sales' group by projection_schema,projection_name order by sum(row_
count);

The query returns the following:

projection_name | sum
-----------------------------+---------
call_center_dimension_super | 200
online_page_dimension_super | 1000
online_sales_fact_super | 5000000
(3 rows)

Exit vsql
To exit vsql, type \q:

dbadmin-> \q

After you exit vsql, the Linux command prompt displays:

[dbadmin@localhost VMart_Schema]$

Vertica Analytic Database (10.0.x) Page 39 of 40


Vertica Community Edition Virtual Machine User Guide

Learn More About vsql


To learn more about vsql, see the following topics in the Vertica documentation:

l Using vsql
l SQL in Vertica

Vertica Analytic Database (10.0.x) Page 40 of 40

You might also like