<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Prop Labs</title>
	<atom:link href="http://proplabs.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://proplabs.org</link>
	<description>Technologist&#039;s Journal</description>
	<lastBuildDate>Thu, 17 May 2012 14:41:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Vertica &#8211; Client Authentication</title>
		<link>http://proplabs.org/2012/05/17/vertica-client-authentication/</link>
		<comments>http://proplabs.org/2012/05/17/vertica-client-authentication/#comments</comments>
		<pubDate>Thu, 17 May 2012 14:34:20 +0000</pubDate>
		<dc:creator>jim.knicely</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Vertica]]></category>

		<guid isPermaLink="false">http://proplabs.org/?p=1337</guid>
		<description><![CDATA[By default Vertica will authenticate users via a user name and password (if supplied) to grant access to the database. However, Vertica has a myriad of other authentication methods available. In addition to the authentication method, we can also configure access by connection type, client IP address range, and user name. I like how MySQL [...]]]></description>
			<content:encoded><![CDATA[<p>By default Vertica will authenticate users via a user name and password (if supplied) to grant access to the database. However, Vertica has a myriad of other authentication methods available.</p>
<p>In addition to the authentication method, we can also <img class="alignright size-medium wp-image-1367" title="umbrella-corporation-login-screen" src="http://proplabs.org/wp-content/uploads/2012/05/umbrella-corporation-login-screen1-300x187.jpg" alt="umbrella corporation login screen1 300x187 Vertica   Client Authentication" width="300" height="187" />configure access by connection type, client IP address range, and user name. I like how MySQL has the ability to only allow a user to connect to the database if he or she is logging on from a particular machine. With Vertica we can do the same thing.</p>
<p>What&#8217;s cool is that the Vertica database can have multiple authentication settings where each is defined as a record (single line) in the <em>vertica.conf</em> configuration file.</p>
<p>A configuration record has the following format:</p>
<p style="padding-left: 30px;"><em>ClientAuthentication = connection_type user_name address method</em></p>
<ul>
<li>The <strong>connection_type</strong> can be <em>local</em>, <em>host</em>, <em>hostssl</em> or <em>hostnossl</em></li>
<li>The <strong>user_name</strong> can be <em>all</em>, or one or more user names (multiple user names are separated with a plus sign (+))</li>
<li>The <strong>address</strong> identifies the client machine IP address range (This can be a range)</li>
<li>The <strong>method</strong> identifies the authentication method to be used for clients that match this record. The available methods are <em>trust</em>, <em>reject</em>, <em>krb5</em>, <em>gss</em>, <em>ldap</em>, <em>md5</em> and <em>password</em>.</li>
</ul>
<p>Try not to edit the <em>vertica.conf</em> file manually because Veritca won&#8217;t be able to error check the entries. It is recommended that we enter records into the <em>vertica.conf</em> file via the <strong>admintools</strong> utility (under the Configuration Menu/Edit Authentication selection) or by setting the <strong>ClientAuthentication</strong> system parameter directly.</p>
<p>As an example, say we want to limit user ABC so that he has to use a TCP/IP connection from his office PC (10.255.15.12) using his LDAP user name and password. That entry might look like this:</p>
<p style="padding-left: 30px;"><em>ClientAuthentication = host ABC 10.255.15.12/24 ldap &#8220;ldap://ldap.mycompany.com/;cn=;,dc=sales,dc=com&#8221;<br />
</em></p>
<p>We can also not allow user ABC to connect from a specific client machine (10.255.20.13). That entry might look like this:</p>
<p style="padding-left: 30px;"><em>ClientAuthentication = host ABC 10.255.20.13/24 reject</em></p>
<p>Note that once entries are added to the <em>vertica.conf</em> file the default user name and password authentication method will no longer function. To enable it in addition to our new settings we have to add a record for it in this format for TCP/IP connections:</p>
<p style="padding-left: 30px;"><em>ClientAuthentication = host all 0.0.0.0/0 password</em></p>
<p>And like this for local connections:</p>
<p style="padding-left: 30px;"><em>ClientAuthentication = local all password</em></p>
<p>When the changes are saved Vertica will check the formatting of each record and ask us to restart the database if everything checks out. Once the database is restarted we can verify that the changes to the authentication settings were successful by querying the <strong>ClientAuthentication</strong> system parameter.</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt; SELECT GET_CONFIG_PARAMETER('ClientAuthentication');
GET_CONFIG_PARAMETER
------------------------------------------------------------------------------------------------------------------------------------------------------------------
host ABC 10.255.15.12/24 ldap &quot;ldap://ldap.mycompany.com/;cn=;,dc=sales,dc=com&quot;,host ABC 10.255.16.127/24 password,host all 0.0.0.0/0 password,local all password</pre>
<p>The order of rules in the file is very important because Vertica will scan the entries from top to bottom using the first rule that matches the client connection. Make sure to put rules based on a specific user or IP address prior  to the more broad rule like all users or a range of IP addresses.</p>
<p>We can also configure the authentication options by setting the <strong>ClientAuthentication</strong> system parameter.</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt; SELECT SET_CONFIG_PARAMETER('ClientAuthentication', 'host ABC 10.255.15.12/24 ldap &quot;ldap://ldap.mycompany.com/;cn=;,dc=sales,dc=com&quot;,host ABC 10.255.16.127/24 password,&lt;em&gt;host all 0.0.0.0/0 password&lt;/em&gt;,local all password');
 SET_CONFIG_PARAMETER
 ----------------------------
 Parameter set successfully
 (1 row)</pre>
<p>After setting the <strong>ClientAuthentication</strong> system parameter with the <strong>SET_CONFIG_PARAMETER</strong> function Vertica will automatically modify the <em>vertica.conf</em> file with our new settings for us. The benefit of doing it this way is that Vertica still checks our formatting and we don&#8217;t have to restart the database!</p>
<p>To reset the authentications method back to the default (user name and password), simply set the <strong>ClientAuthentication</strong> system parameter to nothing:</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt; SELECT SET_CONFIG_PARAMETER('ClientAuthentication', '');
SET_CONFIG_PARAMETER
----------------------------
Parameter set successfully
(1 row)</pre>
<p>For more detail on setting up client authentication, refer to the Administrator&#8217;s Guide!</p>
]]></content:encoded>
			<wfw:commentRss>http://proplabs.org/2012/05/17/vertica-client-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vertica – Mopping Up After Modifying the Data Type or Size of a Table Column</title>
		<link>http://proplabs.org/2012/05/04/vertica-mopping-up-after-modifying-the-data-type-or-size-of-a-table-column/</link>
		<comments>http://proplabs.org/2012/05/04/vertica-mopping-up-after-modifying-the-data-type-or-size-of-a-table-column/#comments</comments>
		<pubDate>Fri, 04 May 2012 19:27:14 +0000</pubDate>
		<dc:creator>jim.knicely</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Vertica]]></category>
		<category><![CDATA[Alter]]></category>
		<category><![CDATA[Column]]></category>
		<category><![CDATA[Table]]></category>

		<guid isPermaLink="false">http://proplabs.org/?p=1249</guid>
		<description><![CDATA[In my previous post Vertica &#8211; How to Modify the Data Type or Size of a Table Column I discussed the steps needed to change the data type or size of a table column. The process we discussed included creating a new table sporting the desired modification(s), copying the data from the original table into [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous post <a title="Link to Previous Post" href="http://proplabs.org/2012/04/27/vertica-how-to-modify-the-data-type-or-size-of-a-table-column/" target="_blank">Vertica &#8211; How to Modify the Data Type or Size of a Table Column</a> I discussed the steps needed to change the data type or size of a table column. The process we discussed included creating a new table sporting the desired modification(s), copying the data from the original table into the new table, dropping the original table and then renaming the new table back to <a title="This is Brilliant!" href="http://vimeo.com/3263721" target="_blank"><img class="alignright  wp-image-1288" title="The-Baby-Mop" src="http://proplabs.org/wp-content/uploads/2012/05/The-Baby-Mop-300x222.png" alt="The Baby Mop 300x222 Vertica – Mopping Up After Modifying the Data Type or Size of a Table Column" width="203" height="150" /></a> the original table name. There are two areas of concern that I would like to address. The first concern is that when we created the new table and then copied data into it from the original table there was a super projection created for the new table. The name of this new projection included the name of the new table. But when we renamed the new table back to the original table name it&#8217;s super projection was not renamed and it retained the name when it was created. The second concern is that any projections on the original table defined by a user or created by Database Designer were lost when we dropped it (note, the original example did not have any non super projections).</p>
<p>It turns out we have some mopping up to do!</p>
<p>Here is a simple example that reveals each of the issues. In the example I am trying to change the data type of a column from an <strong>INT</strong> to a <strong>VARCHAR</strong>.</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; create table test1 (col1 int);
CREATE TABLE
dbadmin=&gt; insert into test1 values (1);
OUTPUT
--------
1
(1 row)</pre>
<p>&nbsp;</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; create projection test1_my_pr as select * from test1 unsegmented all nodes;
WARNING:  Projection  is not available for query processing. Execute the select start_refresh() function to copy data into this projection.
The projection must have a sufficient number of buddy projections and all nodes must be up before starting a refresh.
WARNING:  Projection  is not available for query processing. Execute the select start_refresh() function to copy data into this projection.
The projection must have a sufficient number of buddy projections and all nodes must be up before starting a refresh.
WARNING:  Projection  is not available for query processing. Execute the select start_refresh() function to copy data into this projection.
The projection must have a sufficient number of buddy projections and all nodes must be up before starting a refresh.
CREATE PROJECTION</pre>
<p>&nbsp;</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; select start_refresh();
start_refresh
----------------------------------------
Starting refresh background process.

(1 row)

dbadmin=&gt; select projection_name
dbadmin-&gt;      , is_up_to_date
dbadmin-&gt;   from projections
dbadmin-&gt;  where anchor_table_name = 'test1';
projection_name    | is_up_to_date
----------------------+---------------
test1_node0001       | t
test1_node0002       | t
test1_node0003       | t
test1_my_pr_node0001 | t
test1_my_pr_node0002 | t
test1_my_pr_node0003 | t
(6 rows)

dbadmin=&gt; create table test2 (col1 varchar);
CREATE TABLE
dbadmin=&gt; insert into test2 select * from test1;
OUTPUT
--------
1
(1 row)

dbadmin=&gt; select projection_name
dbadmin-&gt;      , is_up_to_date
dbadmin-&gt;   from projections
dbadmin-&gt;  where anchor_table_name = 'test2';
projection_name | is_up_to_date
-----------------+---------------
test2_node0001  | t
test2_node0002  | t
test2_node0003  | t
(3 rows)

dbadmin=&gt; drop table test1 cascade;
DROP TABLE
dbadmin=&gt; alter table test2 rename to test1;
ALTER TABLE
dbadmin=&gt; select projection_name
dbadmin-&gt;      , is_up_to_date
dbadmin-&gt;   from projections
dbadmin-&gt;  where anchor_table_name = 'test1';
projection_name | is_up_to_date
-----------------+---------------
test2_node0001  | t
test2_node0002  | t
test2_node0003  | t
(3 rows)</pre>
<p>Notice that the projection name on each node does not start with <strong>&#8220;test1&#8243;</strong> and we lost the <strong>test1_my_pr</strong> projection altogether!</p>
<p>To resolve these issues we&#8217;re going to have to modify the &#8220;<strong>5 easy steps</strong>&#8221; that were discussed in the earlier post.</p>
<p>As a reminder, the “<strong>5 easy steps</strong>” were listed as:</p>
<ol>
<li>Create a new table similar to original, but include the data type or size modifications</li>
<li>Copy the data from the original table to the new table</li>
<li>Rename the old table (as a backup)</li>
<li>Rename the new table to same name as the original table</li>
<li>Drop the old table (unless you want to keep it around as a backup)</li>
</ol>
<p>To handle both issues (keeping projection names intact and rebuilding  projections) we need to add a few more steps:</p>
<p>Add<strong> Step 2.5:</strong></p>
<p>Extract the projections for the original table before dropping it using the <strong>EXPORT_OBJECTS</strong> function. This function can generate a script file that contains all of the projection <strong>CREATE</strong> statements for our table. We can execute the script after we&#8217;ve renamed the temporary table back to the original to re-create the projections.</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; select export_objects('/home/dbadmin/test1.sql', 'test1');
export_objects
-------------------------------------
Catalog data exported successfully

(1 row)

dbadmin=&gt; \! cat test1.sql

CREATE TABLE public.test1
(
col1 int
);

CREATE PROJECTION public.test1
(
col1
)
AS
SELECT test1.col1
FROM public.test1
ORDER BY test1.col1
UNSEGMENTED ALL NODES;

CREATE PROJECTION public.test1_my_pr
(
col1
)
AS
SELECT test1.col1
FROM public.test1
ORDER BY test1.col1
UNSEGMENTED ALL NODES;

SELECT MARK_DESIGN_KSAFE(1);
dbadmin=&gt; select * from test2;
col1
------
1
(1 row)</pre>
<p>Add<strong> Step 2.6:</strong></p>
<p>Edit the script file and remove the <strong>CREATE TABLE</strong> statement and add a <strong>SELECT START_REFRESH();</strong> statement at the end to refresh the projections.</p>
<p>Add<strong> Step 4.5:</strong></p>
<p>Run the edited script!</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; \i /home/dbadmin/test1.sql
vsql:/home/dbadmin/test1.sql:18: WARNING:  Projection  is not available for query processing. Execute the select start_refresh() function to copy data into this projection.
The projection must have a sufficient number of buddy projections and all nodes must be up before starting a refresh.
vsql:/home/dbadmin/test1.sql:18: WARNING:  Projection  is not available for query processing. Execute the select start_refresh() function to copy data into this projection.
The projection must have a sufficient number of buddy projections and all nodes must be up before starting a refresh.
vsql:/home/dbadmin/test1.sql:18: WARNING:  Projection  is not available for query processing. Execute the select start_refresh() function to copy data into this projection.
The projection must have a sufficient number of buddy projections and all nodes must be up before starting a refresh.
CREATE PROJECTION
vsql:/home/dbadmin/test1.sql:28: WARNING:  Projection  is not available for query processing. Execute the select start_refresh() function to copy data into this projection.
The projection must have a sufficient number of buddy projections and all nodes must be up before starting a refresh.
vsql:/home/dbadmin/test1.sql:28: WARNING:  Projection  is not available for query processing. Execute the select start_refresh() function to copy data into this projection.
The projection must have a sufficient number of buddy projections and all nodes must be up before starting a refresh.
vsql:/home/dbadmin/test1.sql:28: WARNING:  Projection  is not available for query processing. Execute the select start_refresh() function to copy data into this projection.
The projection must have a sufficient number of buddy projections and all nodes must be up before starting a refresh.
CREATE PROJECTION
MARK_DESIGN_KSAFE
----------------------
Marked design 1-safe
(1 row)

START_REFRESH
----------------------------------------
Starting refresh background process.

(1 row)</pre>
<p>&nbsp;</p>
<pre class="brush: plain; title: ; notranslate">
dbadmin=&gt; select projection_name
dbadmin-&gt;      , is_up_to_date
dbadmin-&gt;   from projections
dbadmin-&gt;  where anchor_table_name = 'test1';
 projection_name    | is_up_to_date
 ----------------------+---------------
 test2_node0001       | t
 test2_node0002       | t
 test2_node0003       | t
 test1_node0001       | t
 test1_node0002       | t
 test1_node0003       | t
 test1_my_pr_node0001 | t
 test1_my_pr_node0002 | t
 test1_my_pr_node0003 | t
 (9 rows)</pre>
<p>Finally, one more step is needed to clean up the old projections that are no longer needed (those named after the temporary <strong>TEMP2</strong> table).</p>
<p><strong>Step 4.7:</strong></p>
<p>Drop the old projections:</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; drop projection test2_node0001;
DROP PROJECTION
dbadmin=&gt; drop projection test2_node0002;
DROP PROJECTION
dbadmin=&gt; drop projection test2_node0003;
DROP PROJECTION
dbadmin=&gt; select projection_name
dbadmin-&gt;      , is_up_to_date
dbadmin-&gt;   from projections
dbadmin-&gt;  where anchor_table_name = 'test1';
projection_name    | is_up_to_date
----------------------+---------------
test1_node0001       | t
test1_node0002       | t
test1_node0003       | t
test1_my_pr_node0001 | t
test1_my_pr_node0002 | t
test1_my_pr_node0003 | t
(6 rows)

dbadmin=&gt; \d test1;
List of Fields by Tables
Schema | Table | Column |    Type     | Size | Default | Not Null | Primary Key | Foreign Key
--------+-------+--------+-------------+------+---------+----------+-------------+-------------
public | test1 | col1   | varchar(80) |   80 |         | f        | f           |
(1 row)

dbadmin=&gt; select * from test1;
col1
------
1
(1 row)</pre>
<p>So our &#8220;<strong>5 easy steps</strong>&#8221; have grown a little into these &#8220;<strong>9 easy steps</strong>&#8220;:</p>
<ol>
<li>Create a new table similar to original, but include the data type or size modifications</li>
<li>Copy the data from the original table to the new table</li>
<li>Extract the projection create statements for the original table into a script.</li>
<li>Rename the old table (as a backup)</li>
<li>Edit the script created in step 3 to remove the CREATE TABLE statement and add a SELECT START_REFRESH() statement to the end.</li>
<li>Rename the new table to same name as the original table</li>
<li>Run the script edited in step 5 to re-create the projections</li>
<li>Drop the old projections</li>
<li>Drop the old table (unless you want to keep it around as a backup)</li>
</ol>
<p>Hopefully this helps out a little more!</p>
]]></content:encoded>
			<wfw:commentRss>http://proplabs.org/2012/05/04/vertica-mopping-up-after-modifying-the-data-type-or-size-of-a-table-column/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimize your LAMP</title>
		<link>http://proplabs.org/2012/05/03/optimize-your-lamp/</link>
		<comments>http://proplabs.org/2012/05/03/optimize-your-lamp/#comments</comments>
		<pubDate>Thu, 03 May 2012 02:25:34 +0000</pubDate>
		<dc:creator>tom.light</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://proplabs.org/?p=1244</guid>
		<description><![CDATA[Sometimes just throwing LAMP on your centos box with yum isn&#8217;t enough, you need to tweak a few settings to get an edge.  These small tweaks will make your LAMP stack fly! First in Apache2, you can get rid of a lot of the default modules, by commenting out these modules you save about 10mb [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes just throwing LAMP on your centos box with yum isn&#8217;t enough, you need to tweak a few settings to get an edge.  These small tweaks will make your LAMP stack fly!</p>
<p>First in Apache2, you can get rid of a lot of the default modules, by commenting out these modules you save about 10mb of ram per request (don&#8217;t comment out anything you need though):</p>
<p><a href="http://proplabs.org/wp-content/uploads/2012/05/apache.jpg"><img class="alignnone size-medium wp-image-1246" title="apache" src="http://proplabs.org/wp-content/uploads/2012/05/apache-300x225.jpg" alt="apache 300x225 Optimize your LAMP" width="300" height="225" /></a></p>
<p>LoadModule auth_basic_module modules/mod_auth_basic.so<br />
LoadModule auth_digest_module modules/mod_auth_digest.so<br />
LoadModule authn_file_module modules/mod_authn_file.so<br />
LoadModule authn_alias_module modules/mod_authn_alias.so<br />
LoadModule authn_anon_module modules/mod_authn_anon.so<br />
LoadModule authn_dbm_module modules/mod_authn_dbm.so<br />
LoadModule authn_default_module modules/mod_authn_default.so<br />
LoadModule authz_user_module modules/mod_authz_user.so<br />
LoadModule authz_owner_module modules/mod_authz_owner.so<br />
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so<br />
LoadModule authz_dbm_module modules/mod_authz_dbm.so<br />
LoadModule authz_default_module modules/mod_authz_default.so<br />
LoadModule ldap_module modules/mod_ldap.so<br />
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so<br />
LoadModule mime_magic_module modules/mod_mime_magic.so<br />
LoadModule dav_module modules/mod_dav.so<br />
LoadModule dav_fs_module modules/mod_dav_fs.so<br />
LoadModule speling_module modules/mod_speling.so<br />
LoadModule proxy_module modules/mod_proxy.so<br />
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so<br />
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so<br />
LoadModule proxy_http_module modules/mod_proxy_http.so<br />
LoadModule proxy_connect_module modules/mod_proxy_connect.so<br />
LoadModule cgi_module modules/mod_cgi.so</p>
<p>I would recommend going to the top of the file and turning KeepAlive On too, this could save your behind if you get a big surge of traffic.</p>
<p>also, in your conf.d folder, rename  proxy_ajp.conf to proxy_ajp.conf.old</p>
<p>In MySQL, I usually run this for my default mysql instancess (2-4gb of ram) and tweak more as needed (my.cnf):</p>
<p>query_cache_type=1<br />
query_cache_limit=1M<br />
query_cache_size=32M<br />
thread_concurrency=4<br />
log_slow_queries=/tmp/mysqld.slow.log<br />
long_query_time=2<br />
key_buffer_size=32M<br />
sort_buffer_size=10M<br />
read_buffer_size=10M<br />
join_buffer_size=10M<br />
read_rnd_buffer_size=25M<br />
max_heap_table_size=256M<br />
tmp_table_size=256M<br />
thread_cache=256<br />
myisam_sort_buffer_size=128M</p>
]]></content:encoded>
			<wfw:commentRss>http://proplabs.org/2012/05/03/optimize-your-lamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vertica &#8211; How to Modify the Data Type or Size of a Table Column</title>
		<link>http://proplabs.org/2012/04/27/vertica-how-to-modify-the-data-type-or-size-of-a-table-column/</link>
		<comments>http://proplabs.org/2012/04/27/vertica-how-to-modify-the-data-type-or-size-of-a-table-column/#comments</comments>
		<pubDate>Fri, 27 Apr 2012 13:47:37 +0000</pubDate>
		<dc:creator>jim.knicely</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Vertica]]></category>
		<category><![CDATA[Column]]></category>
		<category><![CDATA[DataTypes]]></category>
		<category><![CDATA[Resize]]></category>

		<guid isPermaLink="false">http://proplabs.org/?p=1169</guid>
		<description><![CDATA[It&#8217;s relatively easy (if you consider 5 steps relatively easy) to change the data type or size of a table column in Vertica. Unfortunately the ALTER TABLE ALTER COLUMN (as of release 5.1.1) command only gives us the ability to add or remove a DEFAULT value or add or remove a NOT NULL constraint. So [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s relatively easy (if you consider 5 steps relatively easy) to change the data type or size of a table column in Vertica. <img class="alignright  wp-image-1219" title="Super Size my Data!" src="http://proplabs.org/wp-content/uploads/2012/04/SuperSize1.png" alt="SuperSize1 Vertica   How to Modify the Data Type or Size of a Table Column" width="128" height="119" />Unfortunately the <strong>ALTER TABLE ALTER COLUMN</strong> (as of release 5.1.1) command only gives us the ability to add or remove a <strong>DEFAULT</strong> value or add or remove a <strong>NOT NULL</strong> constraint.</p>
<p>So we can make changes like the following using the <strong>ALTER TABLE ALTER COLUMN</strong> command:</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; select version();
version
------------------------------------
Vertica Analytic Database v5.1.1-0
(1 row)
dbadmin=&gt; create table test (col1 varchar(100));
CREATE TABLE
dbadmin=&gt; alter table test alter column col1 set not null;
ALTER TABLE
dbadmin=&gt; alter table test alter column col1 set default '0';
ALTER TABLE
dbadmin=&gt; alter table test alter column col1 drop default;
ALTER TABLE
dbadmin=&gt; alter table test alter column col1 drop not null;
ALTER TABLE</pre>
<p>But not change like these:</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; alter table test alter column col1 int;
ERROR:  syntax error at or near &quot;int&quot; at character 36
LINE 1: alter table test alter column col1 int;
                                           ^
dbadmin=&gt; alter table test alter column col1 varchar(200);
ERROR:  syntax error at or near &quot;varchar&quot; at character 36
LINE 1: alter table test alter column col1 varchar(200);
                                           ^
</pre>
<p>As I mentioned, there are 5 steps that are needed to change a column data type or to re-size it.</p>
<p>They are:</p>
<ol>
<li>Create a new table similar to original, but include the data type or size modifications</li>
<li>Copy the data from the original table to the new table</li>
<li>Rename the old table (as a backup)</li>
<li>Rename the new table to same name as the original table</li>
<li>Drop the old table (unless you want to keep it around as a backup)</li>
</ol>
<p>As an example, in the health care industry the number of medical diagnosis codes (called ICD codes) increased when version 10 was introduced. In doing so the number of characters that represent a code have increased from 3-5 characters (ICD version 9) in length up to 3-7 characters in length for ICD version 10. If a field in a table that stores an ICD code is defined smaller than 7 characters it will need to be modified.</p>
<p>Here&#8217;s how to do that.</p>
<p>First let&#8217;s create a test table named ICD_CODE and I&#8217;ll insert a few ICD-9 codes.</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; create table icd_code (version int, code varchar(5), description varchar(255));
CREATE TABLE
dbadmin=&gt; insert into icd_code values (9, '157', 'Malignant neoplasm of pancreas');
OUTPUT
--------
1
(1 row)

dbadmin=&gt; insert into icd_code values (9, '1570', 'Head of pancreas');
OUTPUT
--------
1
(1 row)
</pre>
<p>Next I&#8217;ll try and insert an ICD-10 code:</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; insert into icd_code values (10, 'S52521A', 'Torus fracture of lower end of right radius, initial encounter for closed fracture');
ERROR:  7-octet value too long for type Varchar(5)</pre>
<p>Yikes! We can&#8217;t squeeze it into the column.<img class="alignright  wp-image-1227" title="Like our data, these puppies can't squeeze in!" src="http://proplabs.org/wp-content/uploads/2012/04/dogs_squeezing3.png" alt="dogs squeezing3 Vertica   How to Modify the Data Type or Size of a Table Column" width="106" height="142" /></p>
<p>We&#8217;re going to have to modify the CODE column so that it can fit the length of the new ICD. To do that, we&#8217;re going to have to implement the 5 relatively easy steps listed above&#8230;</p>
<p>1. Create a new table similar to original, but include the data type or size modifications</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; create table icd_code_temp (version int, code varchar(7), description varchar(255));
CREATE TABLE</pre>
<p>2. Copy the data from the original table to the new table</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; insert into icd_code_temp select * from icd_code;
OUTPUT
--------
2
(1 row)</pre>
<p>3. Rename the old table (as a backup)</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; alter table icd_code rename to icd_code_bk;
ALTER TABLE</pre>
<p>4. Rename the new table to same name as the original table</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; alter table icd_code_temp rename to icd_code;
ALTER TABLE</pre>
<p>Now we can insert the ICD-10 code:</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; insert into icd_code values (10, 'S52521A', 'Torus fracture of lower end of right radius, initial encounter for closed fracture');
 OUTPUT
 --------
 1
 (1 row)</pre>
<p>Verify that all the records are in the new table:</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; select * from icd_code;
version |  code   |                                    description
---------+---------+------------------------------------------------------------------------------------
9 | 157     | Malignant neoplasm of pancreas
9 | 1570    | Head of pancreas
10 | S52521A | Torus fracture of lower end of right radius, initial encounter for closed fracture
(3 rows)</pre>
<p>5. Drop the old table (unless you want to keep it around as a backup)</p>
<pre class="brush: plain; title: ; notranslate">dbadmin=&gt; drop table icd_code_bk;
DROP TABLE</pre>
<p>Hopefully the <strong>ALTER TABLE ALTER COLUMN</strong> command in a future release can do this for us!</p>
]]></content:encoded>
			<wfw:commentRss>http://proplabs.org/2012/04/27/vertica-how-to-modify-the-data-type-or-size-of-a-table-column/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Vertica &#8211; Configuring Event Reporting to the syslog</title>
		<link>http://proplabs.org/2012/04/18/vertica-configuring-event-reporting-to-the-syslog/</link>
		<comments>http://proplabs.org/2012/04/18/vertica-configuring-event-reporting-to-the-syslog/#comments</comments>
		<pubDate>Wed, 18 Apr 2012 19:03:35 +0000</pubDate>
		<dc:creator>jim.knicely</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Vertica]]></category>

		<guid isPermaLink="false">http://proplabs.org/?p=1126</guid>
		<description><![CDATA[Event reporting by Vertica is automatically configured for the vertica.log and the ACTIVE_EVENTS system table. But we can also configure Vertica to write events to the Linux syslog utility. According to Vertica&#8217;s documentation the &#8220;Syslog is a network-logging utility that issues, stores, and processes meaningful log messages. It is designed so DBAs can keep machines [...]]]></description>
			<content:encoded><![CDATA[<p>Event reporting by Vertica is automatically configured for the <em>vertica.log</em> and the <strong>ACTIVE_EVENTS</strong> system table. But we can also configure Vertica to write events to the Linux <em>syslog</em> utility.<img class="size-medium wp-image-1140 alignright" title="EventReporting" src="http://proplabs.org/wp-content/uploads/2012/04/EventReporting-300x195.png" alt="EventReporting 300x195 Vertica   Configuring Event Reporting to the syslog" width="300" height="195" /></p>
<p>According to Vertica&#8217;s documentation the &#8220;Syslog is a network-logging utility that issues, stores, and processes meaningful log messages. It is designed so DBAs can keep machines up and running, and it is a useful way to get heterogeneous data into a single data repository.&#8221;</p>
<p>Since I&#8217;m a DBA that likes to keep Vertica up and running (and one that likes to be employed) I figured it&#8217;d be a good idea to take a look at this feature!</p>
<p>Basically, there are three configuration steps needed to start event logging to the <em>syslog</em>:</p>
<ol>
<li>Turn the feature on (off by default)</li>
<li>Indicate which events to log (none by default)</li>
<li>Indicate where to post the events (<em>/var/log/messages</em> by default)</li>
</ol>
<p><strong>Note:</strong> The third step is only necessary if you want to change the facility logging the events.  Please see Vertica&#8217;s Administrator&#8217;s Guide for details on how to change the default facility for the <em>syslog</em>.</p>
<p>Enabling and disabling the posting of events to the <em>syslog</em> is done by setting the <em>SyslogEnabled</em> system parameter.</p>
<p style="padding-left: 30px;">To enable use: SELECT SET_CONFIG_PARAMETER(&#8216;SyslogEnabled&#8217;, 1);</p>
<p style="padding-left: 30px;">To disable use: SELECT SET_CONFIG_PARAMETER(&#8216;SyslogEnabled&#8217;, 0);</p>
<p>Here is a list of events that can be monitored:</p>
<ul>
<li>Low Disk Space</li>
<li>Read Only File System</li>
<li>Loss Of K Safety</li>
<li>Current Fault Tolerance at Critical Level</li>
<li>Too Many ROS Containers</li>
<li>WOS Over Flow</li>
<li>Node State Change</li>
<li>Recovery Failure</li>
<li>Recovery Error</li>
<li>Recovery Lock Error</li>
<li>Recovery Projection Retrieval Error</li>
<li>Refresh Error</li>
<li>Refresh Lock Error</li>
<li>Tuple Mover Error</li>
<li>Timer Service Task Error</li>
<li>Stale Checkpoint</li>
</ul>
<p>Use the <em>SyslogEvents</em> system parameter to let Vertica know which events you want to log. For example:</p>
<p style="padding-left: 30px;">SELECT SET_CONFIG_PARAMETER(&#8216;SyslogEvents&#8217;, &#8216;Low Disk Space,  Node State Change&#8217;);</p>
<p>By default events are posted in <em>/var/log/messages</em>.</p>
<p>As a test, I&#8217;ll tell Vertica to log any &#8220;Node State Change&#8221; events and then stop and start Vertica on node 3 of my three node cluster.</p>
<p><strong>STEP 1</strong> &#8211; Set up Vertica:</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt; SELECT SET_CONFIG_PARAMETER('SyslogEvents', 'Node State Change');
SET_CONFIG_PARAMETER
----------------------------
Parameter set successfully
(1 row)

dbadmin=&gt; SELECT SET_CONFIG_PARAMETER('SyslogEnabled', 1);
SET_CONFIG_PARAMETER
----------------------------
Parameter set successfully
(1 row)</pre>
<p><strong>STEP 2</strong> -Stop and start Vertica on node 3 using <strong>admintools</strong> utility</p>
<p><strong>STEP 3</strong> &#8211; Jump out the OS on node 3 and view the <em>/var/log/messages</em> file:</p>
<pre class="brush: sql; title: ; notranslate">[root@verticatst03 ~]#  tail /var/log/messages
Apr 18 11:29:42 verticatst03 vertica: Event Posted: Event Code:6 Event Id:8 Event Severity: Informational [6] PostedTimestamp: 2012-04-18 11:29:42.343087 ExpirationTimestamp: 2080-05-06 13:43:49.343087 EventCodeDescription: Node State Change ProblemDescription: Changing node v_vtest_node0003 startup state to SHUTDOWN DatabaseName: vtest Hostname: verticatst03
Apr 18 11:29:42 verticatst03 vertica: Event Cleared: Event Code:6 Event Id:6 Event Severity: Informational [6] PostedTimestamp: 2012-04-18 11:29:42.343557 ExpirationTimestamp: 2012-04-18 11:29:42.343557 EventCodeDescription: Node State Change ProblemDescription: Changing node v_vtest_node0003 leaving startup state UP DatabaseName: vtest Hostname: verticatst03
Apr 18 11:32:18 verticatst03 vertica: Event Posted: Event Code:6 Event Id:1 Event Severity: Informational [6] PostedTimestamp: 2012-04-18 11:32:18.051284 ExpirationTimestamp: 2080-05-06 13:46:25.051284 EventCodeDescription: Node State Change ProblemDescription: Changing node v_vtest_node0003 startup state to RECOVERING DatabaseName: vtest Hostname: verticatst03
Apr 18 11:32:19 verticatst03 vertica: Event Posted: Event Code:6 Event Id:7 Event Severity: Informational [6] PostedTimestamp: 2012-04-18 11:32:19.686469 ExpirationTimestamp: 2080-05-06 13:46:26.686469 EventCodeDescription: Node State Change ProblemDescription: Changing node v_vtest_node0003 startup state to READY DatabaseName: vtest Hostname: verticatst03
Apr 18 11:32:19 verticatst03 vertica: Event Cleared: Event Code:6 Event Id:1 Event Severity: Informational [6] PostedTimestamp: 2012-04-18 11:32:19.686775 ExpirationTimestamp: 2012-04-18 11:32:19.686775 EventCodeDescription: Node State Change ProblemDescription: Changing node v_vtest_node0003 leaving startup state RECOVERING DatabaseName: vtest Hostname: verticatst03
Apr 18 11:32:19 verticatst03 vertica: Event Posted: Event Code:6 Event Id:6 Event Severity: Informational [6] PostedTimestamp: 2012-04-18 11:32:19.687075 ExpirationTimestamp: 2080-05-06 13:46:26.687075 EventCodeDescription: Node State Change ProblemDescription: Changing node v_vtest_node0003 startup state to UP DatabaseName: vtest Hostname: verticatst03
Apr 18 11:32:19 verticatst03 vertica: Event Cleared: Event Code:6 Event Id:7 Event Severity: Informational [6] PostedTimestamp: 2012-04-18 11:32:19.687184 ExpirationTimestamp: 2012-04-18 11:32:19.687184 EventCodeDescription: Node State Change ProblemDescription: Changing node v_vtest_node0003 leaving startup state READY DatabaseName: vtest Hostname: verticatst03</pre>
<p>Note that I had to check <em>/var/log/messages</em> on my cluster node 3 because that&#8217;s the node I took down!</p>
<p>Now I can easily review the <em>syslog</em> for system errors and the Database events I choose in a single location!</p>
]]></content:encoded>
			<wfw:commentRss>http://proplabs.org/2012/04/18/vertica-configuring-event-reporting-to-the-syslog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vertica &#8211; Slicing Up Data Into Time Intervals</title>
		<link>http://proplabs.org/2012/04/13/vertica-slicing-up-data-into-time-intervals/</link>
		<comments>http://proplabs.org/2012/04/13/vertica-slicing-up-data-into-time-intervals/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 20:28:24 +0000</pubDate>
		<dc:creator>jim.knicely</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Vertica]]></category>
		<category><![CDATA[date function]]></category>

		<guid isPermaLink="false">http://proplabs.org/?p=1075</guid>
		<description><![CDATA[Vertica provides us with a cool function named TIME_SLICE which can be used to break (slice) up large data sets into smaller more manageable pieces that are grouped into fixed-time intervals. If you need to see your company&#8217;s sales figures every 60 seconds (you sell a lot of stuff!) or you need to track the [...]]]></description>
			<content:encoded><![CDATA[<p>Vertica provides us with a cool function named <strong>TIME_SLICE</strong> which can be used to break (slice) up large data sets into smaller more manageable pieces that are grouped into fixed-time intervals. If you need to see your company&#8217;s sales figures every 60 seconds (you sell a lot of stuff!) or you need to track the details of an enormous number of stock trades in 5 minute intervals, then Verica makes it simple with the <strong>TIME_SLICE</strong> function.</p>
<p>The syntax for the <strong>TIME_SLICE</strong> function is:</p>
<p style="padding-left: 30px;"><strong>TIME_SLICE</strong>(<em>expression</em>, <em>slice_length</em>, [ <em>time_unit</em> = 'SECOND' ],  [ <em>start_or_end</em> = 'START' ] )</p>
<p>The <em>expression</em> is either a TIMESTAMP or a (string) constant that can be parsed into a TIMESTAMP value, <em>slice_length</em> is the length of the slice specified, <em>time_unit</em> is the time unit of the slice, and <em>start_or_end</em> indicates whether the returned value corresponds to the start or end time of the time slice interval.</p>
<p><strong>Example:</strong></p>
<p>I want to see my company&#8217;s sales information as the number of sales, max sale, min sale and avg sale in 60 second intervals. For this simple example, the company sales are stored in a table named test where there is a column to store the date and time of the sale and a column to store the dollar amount of the sale:</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt; select * from test order by 1;
a_date        | sales
---------------------+-------
2012-04-10 00:00:00 |   700
2012-04-10 23:59:45 |   600
2012-04-11 00:00:00 |   300
2012-04-11 00:00:01 |   430
2012-04-11 00:00:34 |   430
2012-04-11 00:01:00 |   100
2012-04-11 00:01:02 |   150
2012-04-11 00:01:14 |   230
2012-04-11 00:02:32 |   330
2012-04-11 00:02:50 |   350
2012-04-11 00:02:51 |   150
2012-04-11 00:03:01 |   125
2012-04-11 00:03:25 |   900
2012-04-11 00:03:26 |   800
2012-04-11 00:03:26 |   900
2012-04-11 00:03:35 |   425
2012-04-11 00:04:00 |    50
2012-04-11 00:05:25 |   900
2012-04-11 00:05:30 |  5000
2012-04-11 00:05:31 |  6000
2012-04-11 00:05:31 |  6500
2012-04-11 00:05:43 |  5000
2012-04-11 00:13:03 |   300
(23 rows)</pre>
<p>Now, using the <strong>TIME_SLICE</strong> function, I can aggregate the sales in 60 second intervals:</p>
<pre class="brush: sql; title: ; notranslate">
dbadmin=&gt; select time_slice(a_date, 60, 'second', 'start') ts_start
dbadmin-&gt;      , time_slice(a_date, 60, 'second', 'end') ts_end
dbadmin-&gt;      , count(*) tot_sales
dbadmin-&gt;      , min(sales) min_sales
dbadmin-&gt;      , max(sales) max_sales
dbadmin-&gt;      , ROUND(avg(sales), 2) avg_sales
dbadmin-&gt;   from test
dbadmin-&gt;  group
dbadmin-&gt;     by time_slice(a_date, 60, 'second', 'start')
dbadmin-&gt;      , time_slice(a_date, 60, 'second', 'end')
dbadmin-&gt;  order by 1;
ts_start       |       ts_end        | tot_sales | min_sales | max_sales | avg_sales
---------------------+---------------------+-----------+-----------+-----------+-----------
2012-04-10 00:00:00 | 2012-04-10 00:01:00 |         1 |       700 |       700 |       700
2012-04-10 23:59:00 | 2012-04-11 00:00:00 |         1 |       600 |       600 |       600
2012-04-11 00:00:00 | 2012-04-11 00:01:00 |         3 |       300 |       430 |    386.67
2012-04-11 00:01:00 | 2012-04-11 00:02:00 |         3 |       100 |       230 |       160
2012-04-11 00:02:00 | 2012-04-11 00:03:00 |         3 |       150 |       350 |    276.67
2012-04-11 00:03:00 | 2012-04-11 00:04:00 |         5 |       125 |       900 |       630
2012-04-11 00:04:00 | 2012-04-11 00:05:00 |         1 |        50 |        50 |        50
2012-04-11 00:05:00 | 2012-04-11 00:06:00 |         5 |       900 |      6500 |      4680
2012-04-11 00:13:00 | 2012-04-11 00:14:00 |         1 |       300 |       300 |       300
(9 rows)
</pre>
<p>Have fun and have a &#8220;slice&#8221; of pie with that!</p>
<p style="padding-left: 30px;"><img class="size-full wp-image-1103 alignnone" title="pie_slice" src="http://proplabs.org/wp-content/uploads/2012/04/pie_slice.jpeg" alt=" Vertica   Slicing Up Data Into Time Intervals" width="275" height="183" /></p>
<p>PS. Check out a very interesting <strong>TIME_SLICE</strong> forum discussion at <a title="Hot Topic!" href="http://vertica-forums.com/viewtopic.php?f=48&amp;t=137" target="_blank">vertica-forums.com</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://proplabs.org/2012/04/13/vertica-slicing-up-data-into-time-intervals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Install Vertica Community Edition Beta?</title>
		<link>http://proplabs.org/2012/04/13/how-to-install-vertica-community-edition-beta/</link>
		<comments>http://proplabs.org/2012/04/13/how-to-install-vertica-community-edition-beta/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 15:03:53 +0000</pubDate>
		<dc:creator>patrick.kelly</dc:creator>
				<category><![CDATA[Vertica]]></category>
		<category><![CDATA[Administration]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://proplabs.org/?p=1021</guid>
		<description><![CDATA[Here is a quick tutorial for installing the community edition of Vertica on a Centos Linux Virtual Server. I&#8217;m using the same server that I&#8217;ve already installed MySQL and MongoDB on. Both of these databases are drop dead easy to install. MongoDB required a little extra work to standardize the installation and configuration. Even though the Vertica [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick tutorial for installing the <a title=" Vertica Community Edition Beta" href="http://vertica.com/community">community edition of Vertica</a> on a Centos Linux Virtual Server. I&#8217;m using the same server that I&#8217;ve already installed MySQL and <a title="MongoDB Tutorial – Part 1: Installing MongoDB on Linux" href="http://proplabs.org/2012/04/05/mongodb-tutorial-part-1-installing-mongodb-on-linux/">MongoDB</a> on. Both of these databases are drop dead easy to install. MongoDB required a little extra work to standardize the installation and configuration.<a href="http://proplabs.org/wp-content/uploads/2012/04/vertica.jpg"><img class="alignright  wp-image-1064" title="vertica install" src="http://proplabs.org/wp-content/uploads/2012/04/vertica.jpg" alt="vertica How to Install Vertica Community Edition Beta?" width="165" height="124" /></a></p>
<p>Even though the Vertica Community Edition can support up to three nodes, I&#8217;m going to install a single node in this tutorial. This configuration should only be used for development. In a future article, I&#8217;ll go over installing Vertica with more than one node.</p>
<p>Here are the steps:</p>
<h3>Download and Install the Vertica Rpm.</h3>
<ul>
<li>My server is virtual and running Centos 6.0.</li>
</ul>
<pre class="brush: bash; title: ; notranslate">
[root@Anvil ~]# rpm -Uvh vertica-ce-5.1.1-0.x86_64.RHEL5.rpm
</pre>
<p>Preparing&#8230; ########################################### [100%]<br />
1:vertica-ce ########################################### [100%]</p>
<p>Vertica Analytic Database V5.1.1-0 successfully installed on host Anvil</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Important Information<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
If you are upgrading from a previous version, you must backup your database before<br />
continuing with this install. After restarting your database, you will be unable<br />
to revert to a previous version of the software.<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>To download the latest Vertica documentation in zip or tar format please visit the<br />
myvertica web site.</p>
<p>To complete installation and configuration of the cluster,<br />
run: /opt/vertica/sbin/install_vertica</p>
<pre class="brush: bash; title: ; notranslate">
[root@Anvil ~]#
</pre>
<h3>Run install_vertica Script</h3>
<ul>
<li>We are installing the single node instance.  Please remember that you will not be able expand this in the future</li>
</ul>
<pre class="brush: bash; title: ; notranslate">
[root@Anvil ~]# /opt/vertica/sbin/install_vertica
</pre>
<p>Vertica Analytic Database 5.1.1-0 Installation Tool<br />
Upgrading admintools meta data format..<br />
scanning /opt/vertica/config/users<br />
WARNING: No hostname list provided. Installing to localhost<br />
Starting installation tasks&#8230;<br />
Getting system information for cluster (this may take a while)&#8230;.<br />
Info: the package &#8216;pstack&#8217; is useful during troubleshooting. Vertica recommends this package is installed.<br />
Info: the package &#8216;sysstat&#8217; is useful during troubleshooting. Vertica recommends this package is installed.<br />
Checking/fixing OS parameters&#8230;..</p>
<p>Info! Parameter vm.min_free_kbytes is less than 4096<br />
Setting vm.min_free_kbytes to 4096 &#8230;<br />
Info! The maximum number of open file descriptors is less than 65536<br />
Setting open filehandle limit to 65536 &#8230;<br />
Info! The session setting of pam_limits.so is not set in /etc/pam.d/su<br />
Setting session of pam_limits.so in /etc/pam.d/su &#8230;<br />
Info! Parameter fs.file-max is less than 65536<br />
Setting fs.file-max to 65536 &#8230;<br />
Detected cpufreq module loaded on localhost<br />
CPU frequency scaling is enabled. This may adversely affect the performance of your database.<br />
Vertica recommends that cpu frequency scaling be turned off or set to &#8216;performance&#8217;<br />
Creating/Checking Vertica DBA group</p>
<p>Creating/Checking Vertica DBA user</p>
<p>Password for dbadmin:</p>
<p>Creating Vertica Data Directory&#8230;</p>
<p>Updating spread configuration&#8230;<br />
Verifying spread configuration on whole cluster<br />
Generating RSA private key, 1024 bit long modulus<br />
&#8230;&#8230;..++++++<br />
&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.++++++<br />
e is 65537 (0&#215;10001)<br />
Creating node node0001 definition for host localhost<br />
&#8230; Done<br />
Error Monitor 0 errors 2 warnings<br />
Installation completed with warnings.<br />
Installation complete.</p>
<p>To create a database:<br />
1. Logout and login as dbadmin.**<br />
2. Run /opt/vertica/bin/adminTools as dbadmin<br />
3. Select Create Database from the Configuration Menu</p>
<p>** The installation modified the group privileges for dbadmin.<br />
If you used sudo to install vertica as dbadmin, you will<br />
need to logout and login again before the privileges are applied.</p>
<pre class="brush: bash; title: ; notranslate">
[root@Anvil ~]#
</pre>
<p>We&#8217;re ready to start playing Vertica!<br />
This is a vanilla installation. The install_vertica script has a number of parameters, but they are unnecessary for this basic installation. Please refer back to to Vertica&#8217;s documentation to review these parameters.  <strong>Please note, you will NOT be able to add additional nodes to this install!  You will have to reinstall to support additional nodes.  So please, only use this method for prototyping.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://proplabs.org/2012/04/13/how-to-install-vertica-community-edition-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MongoDB Tutorial &#8211; Part 1: Installing MongoDB on Linux</title>
		<link>http://proplabs.org/2012/04/05/mongodb-tutorial-part-1-installing-mongodb-on-linux/</link>
		<comments>http://proplabs.org/2012/04/05/mongodb-tutorial-part-1-installing-mongodb-on-linux/#comments</comments>
		<pubDate>Thu, 05 Apr 2012 05:33:59 +0000</pubDate>
		<dc:creator>patrick.kelly</dc:creator>
				<category><![CDATA[mongoDB]]></category>
		<category><![CDATA[NoSQL]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[databases]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MongoDB]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://proplabs.org/?p=815</guid>
		<description><![CDATA[MongoDB Tutorial Steps As I mentioned in my original article, I&#8217;ve used a number of different databases.  I decided that I wanted to document my work with MongoDB.  This MongoDB tutorial contains a straight forward guide to installing MongoDB on a Centos server. You can download the files which are created in this tutorial from [...]]]></description>
			<content:encoded><![CDATA[<h2>MongoDB Tutorial Steps</h2>
<hr />
<p><a href="http://proplabs.org/wp-content/uploads/2012/04/mongodb.jpg"><img class="alignright size-full wp-image-998" title="mongoDB" src="http://proplabs.org/wp-content/uploads/2012/04/mongodb.jpg" alt="mongodb MongoDB Tutorial   Part 1: Installing MongoDB on Linux" width="100" height="100" /></a><br />
As I mentioned in my original <a title="mongoDB – Let the Renaissance Begin!" href="http://proplabs.org/2012/03/08/mongodb-let-the-renaissance-begin/">article</a>, I&#8217;ve used a number of different databases.  I decided that I wanted to document my work with MongoDB.  This MongoDB tutorial contains a straight forward guide to installing MongoDB on a Centos server.</p>
<p>You can download the files which are created in this tutorial from <a href="http://proplabs.org/wp-content/uploads/2012/04/MongoFiles.zip">here</a>.</p>
<h3></h3>
<h3></h3>
<h3></h3>
<h3>1. Create Data Directory for MongoDB</h3>
<ul>
<li><em>The <a href="http://www.mongodb.org/display/DOCS/Quickstart+Unix">MongDB Quickstart guide for Linux</a> recommends creating a /data/db/ directory. I prefer to follow the <a href="http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard#Directory_structure">Filesystem Hierarchy Standard (FHS)</a> and place the data files in /var/lib.</em></li>
</ul>
<pre class="brush: bash; title: ; notranslate">[root@Anvil ~]# mkdir /var/lib/mongodb/
[root@Anvil ~]# chown -R mongodb:mongodb /var/lib/mongodb/</pre>
<h3>2. Create the MongoDB User</h3>
<ul>
<li><em>Create a user to run MongoDB.</em> <strong>DO NOT RUN IT AS ROOT!!!</strong>
<pre class="brush: bash; title: ; notranslate">[root@Anvil ~]# groupadd mongodb
[root@Anvil ~]# useradd -r -g mongodb mongodb
</pre>
<h3>3. Download MongoDB from <a href="http://www.mongodb.org/downloads">Here</a></h3>
<ul>
<li><em>I just download it into the root directory.</em></li>
</ul>
<pre class="brush: bash; title: ; notranslate">[~]# wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.4.tgz</pre>
<h2></h2>
<h3>4. Extract the files</h3>
<pre class="brush: bash; title: ; notranslate">[root@Anvil ~]# tar xzf mongodb-linux-x86_64-2.0.4.tgz</pre>
<pre class="brush: bash; title: ; notranslate">[root@Anvil ~]# ll mongodb-linux-x86_64-2.0.4
total 56
 drwxr-xr-x 2 root root  4096 Mar 20 00:21 bin
-rw------- 1 root root 34520 Feb 13 16:05 GNU-AGPL-3.0
-rw------- 1 root root  1364 Feb 13 16:05 README
-rw------- 1 root root  9879 Feb 13 16:05 THIRD-PARTY-NOTICES</pre>
<h3>5. Copy the /bin Files to /usr/bin</h3>
<pre class="brush: bash; title: ; notranslate">[root@Anvil ~]# cp mongodb-linux-x86_64-2.0.4/bin/* /usr/bin/</pre>
<h3>6. Copy Remaining Files to /var/lib/mongodb/</h3>
<pre class="brush: bash; title: ; notranslate">[root@Anvil ~]# cp mongodb-linux-x86_64-2.0.4/* /var/lib/mongodb/</pre>
<h3>7. Create MongoDB Start and Stop Scripts</h3>
<ul>
<li>Create basic shell scripts to stop and start the database.</li>
<li>These scripts should be copied to /usr/bin/.</li>
</ul>
<pre class="brush: bash; title: ; notranslate">[root@Anvil ~]# vi /usr/bin/mongostart

#!/bin/sh

/usr/bin/mongod --config /etc/mongodb.cnf \
## --iupgrade \ ##runs a database upgrade option if needed \

[root@Anvil ~]# vi /usr/bin/mongostop

#!/bin/bash

pid=`'ps -o pid,command ax | grep mongod | awk '!/awk/ &amp;&amp; !/grep/ {print $1}'`;
if [ &quot;${pid}&quot; != &quot;&quot; ]; then
    kill -2 ${pid};
fi
</pre>
<h3>8. Create MongoDB Configuration File</h3>
<ul>
<li><em>I always create a basic configuration file for MongoDB in /etc.</em></li>
</ul>
<pre class="brush: bash; title: ; notranslate">
[root@Anvil ~]# vi /etc/mongodb.cnf

# Configuration Options for MongoDB

dbpath = /var/lib/mongodb/
logpath = /var/lib/mongodb/mongodb.log
logappend = true

bind_ip = 127.0.0.1
port = 27017
fork = true
auth = true</pre>
<h3>9. Create MongoDB Init File</h3>
<pre class="brush: bash; title: ; notranslate">[root@Anvil ~]# vi /etc/mongodb.cnf

#!/bin/sh
#
# mongodb – this script starts and stops the mongodb daemon
#
# chkconfig: - 85 15
# description: MongoDB is a non-relational database storage system.
# processname: mongodb
# config: /etc/mongodb.cnf
# pidfile: /var/lib/mongodb/mongo.pid

PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=mongodb

test -x $DAEMON || exit 0

set -e

case &quot;$1&quot; in
  start)
        echo -n &quot;Starting MongoDB... &quot;
        su mongodb -c &quot;/usr/bin/mongostart&quot;
        ;;
  stop)
        echo -n &quot;Stopping MongoDB&quot;
        /usr/bin/mongostop
        ;;
      *)
            N=/etc/init.d/$NAME
            echo &quot;Usage: $N {start|stop}&quot; &gt;&amp;2
            exit 1
            ;;
    esac

    exit 0
</pre>
<ul>
<li><em>Save as /etc/init.d/mongodb.</em></li>
</ul>
<pre class="brush: bash; title: ; notranslate">[root@Anvil ~]# chmod +x /etc/init.d/mongodb
[root@Anvil ~]# chkconfig --add mongodb
[root@Anvil ~]# chkconfig mongodb on

Starting MongoDB... [root@Anvil lib]# forked process: 28108
all output going to: /var/lib/mongodb/mongodb.log</pre>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://proplabs.org/2012/04/05/mongodb-tutorial-part-1-installing-mongodb-on-linux/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Vertica &#8211; Finding the Number of Hours Between Two Dates</title>
		<link>http://proplabs.org/2012/04/03/vertica-finding-the-number-of-hours-between-two-dates/</link>
		<comments>http://proplabs.org/2012/04/03/vertica-finding-the-number-of-hours-between-two-dates/#comments</comments>
		<pubDate>Tue, 03 Apr 2012 12:53:22 +0000</pubDate>
		<dc:creator>jim.knicely</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Vertica]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[vsql]]></category>

		<guid isPermaLink="false">http://proplabs.org/?p=945</guid>
		<description><![CDATA[Recently I was asked by a user if Vertica can display the difference between two dates in hours. I responded profoundly &#8220;of course&#8221; because I believe that with Vertica anything is possible &#8230;plus I was aware that Vertica has the built in functions DATEDIFF and TIMESTAMPDIFF. All we needed to do was pass into the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was asked by a user if Vertica can display the difference between two dates in hours.<img class="alignright  wp-image-982" title="date_time" src="http://proplabs.org/wp-content/uploads/2012/04/date_time.png" alt="date time Vertica   Finding the Number of Hours Between Two Dates" width="112" height="228" /> I responded profoundly &#8220;of course&#8221; because I believe that with Vertica anything is possible <img src='http://proplabs.org/wp-includes/images/smilies/icon_wink.gif' alt="icon wink Vertica   Finding the Number of Hours Between Two Dates" class='wp-smiley' title="Vertica   Finding the Number of Hours Between Two Dates" />  &#8230;plus I was aware that Vertica has the built in functions <strong>DATEDIFF</strong> and <strong>TIMESTAMPDIFF</strong>. All we needed to do was pass into the pertinent function the two dates and the constant &#8220;HOUR&#8221; to indicate that we wanted the difference between the two dates in hours.</p>
<p>I&#8217;ll use the <strong>TIMESTAMPDIFF</strong> function in my examples. This function has the general specification:</p>
<p style="padding-left: 30px;"><em>TIMESTAMPDIFF ( datepart , starttimestamp , endtimestamp );</em></p>
<p>So if I want to know the number of hours that occur between 8am and 4pm on April 2, 2012 I could do this:</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt; SELECT TIMESTAMPDIFF ('HOUR',('apr 2, 2012 08:00:00'), ('apr 2, 2012 16:00:00'));
timestampdiff
---------------
8
(1 row)</pre>
<p>That looks right. How about between 8am and 4:30pm on April 2, 2012?</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt; SELECT TIMESTAMPDIFF ('HOUR',('apr 2, 2012 08:00:00'), ('apr 2, 2012 16:30:00'));
timestampdiff
---------------
8
(1 row)</pre>
<p>Hmm. Sure there is an 8 hour difference in the dates, but what about the extra 30 minutes? 8 hours was not the result the user was expecting. He was hoping to see 8.5 hours.</p>
<p>What I found is that the date diff functions in Vertica work in &#8220;ticks&#8221; of time. That is, they operate on whole increments of the &#8220;datepart&#8221; specified. In my case, I used &#8220;HOUR&#8221; so I got only whole hours back. The same is true when using the other &#8220;datepart&#8221; indicators passed into the functions.</p>
<p>For instance, how many months are there between April 2, 2012 at 8am and May 15, 2012 at 8 am?</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt; SELECT TIMESTAMPDIFF ('MONTH',('apr 2, 2012 08:00:00'), ('may 15, 2012 08:00:00'));
timestampdiff
---------------
1
(1 row)</pre>
<p>Since we specified months Vertica is only comparing the months and disregarding the fractional part of the month. There is 1 month between April and May. (Hint: If you need to find the exact number of months between two dates use the <strong>MONTHS_BETWEEN</strong> function!)</p>
<p>Back to our original requirement, how can we get the number of hours including fractional parts of an hour in the result?</p>
<p>For that we have to get more granular and find the number of seconds that occurred between the two dates and then convert them back to hours (divide by 3600 which is the number of seconds in an hour):</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt; SELECT TIMESTAMPDIFF ('SECOND',('apr 2, 2012 08:00:00'), ('apr 2, 2012 16:30:00')) / 3600.0 as diff;
diff
-------------------
8.500000000000000
(1 row)</pre>
<p>Now the user is content.</p>
<p>Notice that I divided by 3600.0 and not 3600. In Vertica if we divide by an integer we&#8217;ll get an integer result (rounded to an integer value). If we add a &#8220;.0&#8243; to the divisor then we are now dividing an integer by a float, which returns a float!.</p>
<p>Here&#8217;s what happens if I divide by 3600:</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt; SELECT TIMESTAMPDIFF ('SECOND',('apr 2, 2012 08:00:00'), ('apr 2, 2012 16:30:00')) / 3600 as diff;
diff
------
8
(1 row)</pre>
<p>Here are a few more examples:</p>
<pre class="brush: sql; title: ; notranslate">
dbadmin=&gt; SELECT TIMESTAMPDIFF ('SECOND',('apr 2, 2012 08:00:00'), ('apr 2, 2012 08:30:00')) / 3600.0 as diff;
diff
------------------
.500000000000000
(1 row)

dbadmin=&gt; SELECT TIMESTAMPDIFF ('SECOND',('apr 2, 2012 08:00:00'), ('apr 3, 2012 08:30:00')) / 3600.0 as diff;
diff
--------------------
24.500000000000000
(1 row)

dbadmin=&gt; SELECT TIMESTAMPDIFF ('SECOND',('apr 3, 2012 08:40:00'), ('apr 3, 2012 08:50:00')) / 3600.0 as diff;
diff
------------------
.166666666666667
(1 row)</pre>
<p>Check out the <a title="Discuss Vertica" href="http://vertica-forums.com/" target="_blank">Vertica Forums</a> for the latest and greatest Vertica discussion topics!</p>
]]></content:encoded>
			<wfw:commentRss>http://proplabs.org/2012/04/03/vertica-finding-the-number-of-hours-between-two-dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vertica &#8211; Pivot Rows into Columns (Cross Tab Query)</title>
		<link>http://proplabs.org/2012/03/28/vertica-pivot-rows-into-columns-cross-tab-query/</link>
		<comments>http://proplabs.org/2012/03/28/vertica-pivot-rows-into-columns-cross-tab-query/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 20:36:32 +0000</pubDate>
		<dc:creator>jim.knicely</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Vertica]]></category>
		<category><![CDATA[Cross Tab]]></category>
		<category><![CDATA[Pivot]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://proplabs.org/?p=846</guid>
		<description><![CDATA[A cross tab query is a transformation of rows of data into columns. We can &#8220;pivot&#8221; rows into columns in Vertica by way of the DECODE function. Here is a quick example using runs scored by three MLB teams in the 2008, 2009, 2010 and 2011 seasons (Note: The scores used are made up because [...]]]></description>
			<content:encoded><![CDATA[<p>A cross tab query is a transformation of rows of data into columns. We can &#8220;pivot&#8221; rows into columns in Vertica by way of the <strong>DECODE</strong> function.<img class="alignright  wp-image-865" title="Pivot" src="http://proplabs.org/wp-content/uploads/2012/03/Pivot-300x222.png" alt="Pivot 300x222 Vertica   Pivot Rows into Columns (Cross Tab Query)" width="182" height="135" /></p>
<p>Here is a quick example using runs scored by three MLB teams in the 2008, 2009, 2010 and 2011 seasons (Note: The scores used are made up because I was too lazy to Google actuals).</p>
<p>First I&#8217;ll create a table named MLB and insert some data:</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt;; create table mlb (season INT, team varchar(100), runs int);
CREATE TABLE

dbadmin=&gt; insert into mlb values (2008, 'Pirates', 350);
OUTPUT
--------
1
(1 row)

dbadmin=&gt; insert into mlb values (2009, 'Pirates', 325);
OUTPUT
--------
1
(1 row)

dbadmin=&gt; insert into mlb values (2010, 'Pirates', 296);
OUTPUT
--------
1
(1 row)

dbadmin=&gt; insert into mlb values (2011, 'Pirates', 301);
OUTPUT
--------
1
(1 row)

dbadmin=&gt; insert into mlb values (2008, 'Yankees', 450);
OUTPUT
--------
1
(1 row)

dbadmin=&gt; insert into mlb values (2009, 'Yankees', 487);
OUTPUT
--------
1
(1 row)

dbadmin=&gt; insert into mlb values (2010, 'Yankees', 387);
OUTPUT
--------
1
(1 row)

dbadmin=&gt; insert into mlb values (2011, 'Yankees', 404);
OUTPUT
--------
1
(1 row)

dbadmin=&gt; insert into mlb values (2008, 'Dodgers', 250);
OUTPUT
--------
1
(1 row)

dbadmin=&gt; insert into mlb values (2009, 'Dodgers', 347);
OUTPUT
--------
1
(1 row)

dbadmin=&gt; insert into mlb values (2010, 'Dodgers', 237);
OUTPUT
--------
1
(1 row)

dbadmin=&gt; insert into mlb values (2011, 'Dodgers', 544);
OUTPUT
--------
1
(1 row)</pre>
<p>If I select directly from the MLB table, my result set looks like this:</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt;SELECT * FROM mlb;
season |  team   | runs
--------+---------+------
2008 | Pirates |  350
2009 | Pirates |  325
2010 | Pirates |  296
2011 | Pirates |  301
2008 | Yankees |  450
2009 | Yankees |  487
2010 | Yankees |  387
2011 | Yankees |  404
2008 | Dodgers |  250
2009 | Dodgers |  347
2010 | Dodgers |  237
2011 | Dodgers |  544
(12 rows)</pre>
<p>I&#8217;d like to pivot my results on the SEASON column so that I can see the runs scored in columns as opposed to in the rows. To do that I can use the <strong>DECODE</strong> function:</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt; SELECT team
dbadmin-&gt;           , DECODE(season, 2008, runs, NULL) AS &quot;2008_Season&quot;
dbadmin-&gt;           , DECODE(season, 2009, runs, NULL) AS &quot;2009_Season&quot;
dbadmin-&gt;           , DECODE(season, 2010, runs, NULL) AS &quot;2010_Season&quot;
dbadmin-&gt;           , DECODE(season, 2011, runs, NULL) AS &quot;2011_Season&quot;
dbadmin-&gt;        FROM (SELECT season
dbadmin-&gt;                   , team
dbadmin-&gt;                   , runs
dbadmin-&gt;                FROM mlb) seasons;
team   | 2008_Season | 2009_Season | 2010_Season | 2011_Season
---------+-------------+-------------+-------------+-------------
Pirates |         350 |             |             |
Pirates |             |         325 |             |
Pirates |             |             |         296 |
Pirates |             |             |             |         301
Yankees |         450 |             |             |
Yankees |             |         487 |             |
Yankees |             |             |         387 |
Yankees |             |             |             |         404
Dodgers |         250 |             |             |
Dodgers |             |         347 |             |
Dodgers |             |             |         237 |
Dodgers |             |             |             |         544
(12 rows)</pre>
<p>We&#8217;re not finished yet as we need to get rid of the <strong>NULL</strong> column values. For that, we use the <strong>MAX</strong> function:</p>
<pre class="brush: sql; title: ; notranslate">dbadmin=&gt; SELECT team
dbadmin-&gt;      , MAX(DECODE(season, 2008, runs, NULL)) AS &quot;2008_Season&quot;
dbadmin-&gt;      , MAX(DECODE(season, 2009, runs, NULL)) AS &quot;2009_Season&quot;
dbadmin-&gt;      , MAX(DECODE(season, 2010, runs, NULL)) AS &quot;2010_Season&quot;
dbadmin-&gt;      , MAX(DECODE(season, 2011, runs, NULL)) AS &quot;2011_Season&quot;
dbadmin-&gt;   FROM (SELECT season
dbadmin-&gt;              , team
dbadmin-&gt;              , runs
dbadmin-&gt;           FROM mlb) seasons
dbadmin-&gt;  GROUP
dbadmin-&gt;     BY team;
team   | 2008_Season | 2009_Season | 2010_Season | 2011_Season
---------+-------------+-------------+-------------+-------------
Dodgers |         250 |         347 |         237 |         544
Yankees |         450 |         487 |         387 |         404
Pirates |         350 |         325 |         296 |         301
(3 rows)</pre>
<p>That&#8217;s it! This is an old trick we used in Oracle before they introduced the <strong>PIVOT</strong> SQL command in 11g. Maybe Vertica will introduce a similar feature! <strong>HINT!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://proplabs.org/2012/03/28/vertica-pivot-rows-into-columns-cross-tab-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

