Module 2-Hands On
Module 2-Hands On
[email protected]'s password:
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 4.4.0-31-generic x86_64)
* Documentation: https://help.ubuntu.com/
---Now the linux of the remote server is connected, to connect the vertica DB type
the path name as given below
dbadmin=>
dbadmin=> \h
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 (cur
rently off)
\unset NAME unset (delete) internal variable
\! [COMMAND] execute command in shell or start interactive shell
\password [USER]
change user's password
Query Buffer
\e [FILE] edit the query buffer (or file) with external editor
\g send query buffer to server
\g FILE send query buffer to server and results to file
\g | COMMAND send query buffer to server and pipe results to command
\p show the contents of the query buffer
\r reset (clear) the query buffer
\s [FILE] display history or save it to file
\w FILE write query buffer to file
Input/Output
\echo [STRING] write string to standard output
\i FILE execute commands from file
\o FILE send all query results to file
\o | COMMAND pipe all query results to command
\o close query-results file or pipe
\qecho [STRING]
write string to query output stream (see \o)
==========
dbadmin=> \?
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)
\unset NAME unset (delete) internal variable
\! [COMMAND] execute command in shell or start interactive shell
\password [USER]
change user's password
Query Buffer
\e [FILE] edit the query buffer (or file) with external editor
\g send query buffer to server
\g FILE send query buffer to server and results to file
\g | COMMAND send query buffer to server and pipe results to command
\p show the contents of the query buffer
\r reset (clear) the query buffer
\s [FILE] display history or save it to file
\w FILE write query buffer to file
Input/Output
\echo [STRING] write string to standard output
\i FILE execute commands from file
\o FILE send all query results to file
\o | COMMAND pipe all query results to command
\o close query-results file or pipe
\qecho [STRING]
write string to query output stream (see \o)
Informational
\d [PATTERN] describe tables (list tables if no argument is supplied)
PATTERN may include system schema name, e.g. v_catalog.*
\df [PATTERN] list functions
\dj [PATTERN] list projections
\dn [PATTERN] list schemas
\dp [PATTERN] list table access privileges
\ds [PATTERN] list sequences
===============
dbadmin=> \dj
List of projections
Schema | Name | Owner | Node
| Comment
-----------------+-----------------------------------------+---------
+-----------------+---------
"115" | mech_DBD_1_seg_sou_b0 | dbadmin |
|
"115" | mech_DBD_1_seg_sou_b1 | dbadmin |
|
A00000001 | stu_b0 | dbadmin |
|
A00000001 | stu_b1 | dbadmin |
|
A0000000123 | proj_A1 | dbadmin |
v_nhdb_node0003 |
A0000000123 | proj_A1 | dbadmin |
v_nhdb_node0002 |
A0000000123 | proj_A1 | dbadmin |
v_nhdb_node0001 |
A0000000123 | table1_b0 | dbadmin |
|
A0000000123 | table1_b1 | dbadmin |
|
A0000001 | stu_b0 | dbadmin |
|
A0000001 | stu_b1 | dbadmin |
|
A00000011 | tab1_b0 | dbadmin |
|
A00000011 | tab1_b1 | dbadmin |
|
A000001 | stu_b0 | dbadmin |
|
A000001 | stu_b1 | dbadmin |
|
A00001 | stu_b0 | dbadmin |
|
A00001 | stu_b1 | dbadmin |
|
A000011111 | table1_b0 | dbadmin |
|
A000011111 | table1_b1 | dbadmin |
|
A000011111 | table2_b0 | dbadmin |
|
A000011111 | table2_b1 | dbadmin |
|
A000011111 | table3_b0 | dbadmin |
|
A000011111 | table3_b1 | dbadmin |
|
A000011111 | table5_b0 | dbadmin |
|
A000011111 | table5_b1 | dbadmin |
|
A000011111 | test_b0 | dbadmin |
|
A000011111 | test_b1 | dbadmin |
|
A0001 | Mani_b0 | dbadmin |
|
A0001 | Mani_b1 | dbadmin |
|
A0001 | aim_b0 | dbadmin |
|
A0001 | aim_b1 | dbadmin |
|
A0001 | ex_DBD_1_seg_AAA112_b0 | dbadmin |
|
A0001 | ex_DBD_1_seg_AAA112_b1 | dbadmin |
|
A0001 | ex_DBD_5_seg_AAA111_b0 | dbadmin |
|
A0001 | ex_DBD_5_seg_AAA111_b1 | dbadmin |
|
A0001 | gag_b0 | dbadmin |
|
A0001 | gag_b1 | dbadmin |
|
A0001 | pup_b0 | dbadmin |
|
A0001 | pup_b1 | dbadmin |
|
A0001 | source123_b0 | dbadmin |
|
========
=========
=======
-- The above is the default buddy(segmented) projection .. Now we can create the
projection with segmentation and replication
--Now will create a projection with replication and K- Safety is 1.
dbadmin=> \dj
List of projections
Schema | Name | Owner | Node
| Comment
-----------------+-----------------------------------------+---------
+-----------------+---------
========
dbadmin=> select projection_name, projection_schema, node_name from projections
where projection_schema='A0123' and anchor_table_name='hello';
projection_name | projection_schema | node_name
-----------------+-------------------+-----------------
hello_b0 | A0123 |
hello_b1 | A0123 |
hello_m1 | A0123 | v_nhdb_node0001
hello_m1 | A0123 | v_nhdb_node0002
hello_m1 | A0123 | v_nhdb_node0003
(5 rows)
=======
--Now will create a projection with replication and K- Safety is 0
====
--we are doing projection replication with k safe 0,it is contradictory so buddy
projection is created
dbadmin=> select projection_name, projection_schema, node_name from projections
where projection_schema='A0123' and anchor_table_name='hello';
projection_name | projection_schema | node_name
-----------------+-------------------+-----------------
hello_b0 | A0123 |
hello_b1 | A0123 |
hello_m1 | A0123 | v_nhdb_node0001
hello_m1 | A0123 | v_nhdb_node0002
hello_m1 | A0123 | v_nhdb_node0003
hello_m_b0 | A0123 |
hello_m_b1 | A0123 |
(7 rows)
====
======
-- sementation projection creation with ksafe 0, creating manually by specifying
different projection name
===============
--In the above , we have done 4 conditions of projections
--Replication with ksafe 1
--Replication with ksafe 0
--Segmentation with ksafe 1
--Segmentation with ksafe 0
=====
-- The other way of creating the projection in vertica is by running the Database
Designer(DBD)
-- Two modes to run in DBD, incremental mode and comprehensive mode
--when DBD is run for first time comprehensive mode is preferred
--In incremental mode, it will not delete any previous unoptimized projections and
it will create the projection based on the query given
--In comprehensive mode, it will delete any previous unoptimized projections and it
will create the projection for all tables present under the schema
=======