Vertica and its version - Find out using SQL

I was playing around with Vertica and my friend suddenly asked me what version of Vertica I was using. This was because he was trying to debug something and posted a question to guys from Vertica and they asked him that question. At my workplace we use the same Vertica cluster for development. It is a playground with a lot of restrictions. Without DB Admin access you can’t really explore much in Vertica. But yea we are trying to get the most out it despite all that. ...

June 24, 2013 · 1 min · 167 words

Exploring Vertica's INTERPOLATE predicate

Vertica has a special feature to join tables and fill in the last available values where values would otherwise be null. I had a similar use case and wanted to test how I could make the best use of it. I played with simple examples and got it right, but with a slightly more complex one, I was stuck or maybe I just couldn’t understand what was happening. So I posted a question at Stackoverflow ...

June 18, 2013 · 1 min · 75 words

Vertica - Calendar table with dates from a start date to an end date using analytical SQL

I had a problem creating a table with just SQL that is supported by Vertica. Most of the solutions that I came across online were using procedures. But after a lot of playing around and reading vertica documentation I found a solution to my problem. read more about the problem and the solution at Stackoverflow

June 18, 2013 · 1 min · 55 words

Bash v/s Cshell - Functions and their definitions - useful 'type' keyword

Hey if you have worked on Linux then you have interacted with bash. Maybe not. But it is mostly likely that your default shell is bash. I’m not surprised. I’m among the few people on this planet who regularly interacts with cshell also. Thanks to the kind of work I do. One great feature of bash that I miss in cshell is: Functions. Surprised? Cshell doesn’t support functions. It doesn’t have any concept of function. If you wanted to simulate a function, you have to write another cshell script that does what your function would do and define an alias that calls it. ...

June 9, 2013 · 3 min · 460 words

Viewing function definitions in Vertica

I don’t know if you have tried this. But I did try to read function definition from the system tables in Vertica. I used the table called USER_FUNCTIONS which is a table in the V_CATALOG system schema. More details can be found here: https://my.vertica.com/docs/6.1.x/HTML/index.htm#15021.htm But unfortunately when I try and do something like this: vertdeva01:20130604-113434 > select function\_definition from v\_catalog.user\_functions where schema\_name='calc' and function\_name='getCYForDate'; \---------------------------------------------------------------------------------------------------------------------------------- RETURN to\_date(concat(((((date\_part('year', (processDate)::timestamp))::int - CASE WHEN ((date\_part('month', (processDate)::time (1 row) If you notice the function definition is only partly visible. The rest of it gets truncated. I don’t know how to set it right. If you know how, feel free to comment on this post. ...

June 5, 2013 · 2 min · 267 words

Setup DBVisualizer with an HP Vertica DB connection

Download your free copy of DBVisualizer from http://www.dbvis.com/download/ I am going to give you the steps to setup vertica connection to DB Visualizer on a windows 7. Our windows might look different. But I suppose the terms used on the GUI would match that on any operating system. I know this might be a big assumption as I don’t work for DBVisualizer and I haven’t installed it on any other platform. But it is always worth giving this a try if you are starting to use Vertica and would like to see your tables and write queries on a GUI based environment. I am not a big fan of GUIs. But some times it might become handy. Especially if you are a DBA and you manage quite a lot of databases. ...

June 5, 2013 · 4 min · 798 words

CShell and Absurd quotes and eval

I work on CSHELL these days. Probably the most unpopular shell today. Anyone would recommend not to use it. Because of the absurdness of its syntax and quoting. For an example: Top 10 reasons to avoid using CShell My intention was to write a generic wrapper script that I could use to invoke another script that supposedly attempts to update a database and in the unlikely event of failing to do so, the wrapper would wait for a while and retry again. I thought of this approach as we had been facing some database locking issues and some data that was supposed to updated wasn’t getting updated. And this was causing even more problems for us. Since some of our systems rely on this data. By the way, to give you an idea of the locking problem, let me tell you, we have one MySQL database, that is updated by several processes running on 7 different boxes. Now you can understand the number of processes trying to access the database at similar intervals. ...

June 3, 2013 · 4 min · 645 words

MySQL Partitioning Tutorial

This is a brilliant power point presentation that helped summarize partitioning and its uses. I am currently working on mapping an object oriented database into a relational one, focusing on query time performance. So partitioning data according to how it is accessed was a key. And this sure helped a lot in clearing the basics, without wasting much time. hope it helps you as well. MySQL partitions tutorial ...

June 3, 2013 · 1 min · 74 words

VSQL extract data into file

Hey there! So you use Vertica and vsql to interact with your tables. Ever had those times when you wanted to take stuff from your table and paste it into Microsoft Excel for sending it off to someone not so technically acquainted with Vertica? You could write a script to do that for you. But if you just had to do it within a vsql session you also have options to do it. ...

May 30, 2013 · 1 min · 157 words

Vertica DELETE columns from one table using data from another

My colleague had an issue in Vertica. He had a set of values in table 1 to be deleted based on the records in a table table2. I didn’t think this would be easy considering VERTICA didn’t support joins when doing deletes unlike MYSQL. But they do have something else. Let me take you through the steps I followed. I created the following table in which I have records create table eakan (sec\_id int, nameid int, date date); insert into public.eakan values(1,1,'2013-05-20'); insert into public.eakan values(2,1,'2013-05-20'); insert into public.eakan values(3,1,'2013-05-20'); insert into public.eakan values(1,1,'2013-05-21'); insert into public.eakan values(2,1,'2013-05-21'); insert into public.eakan values(3,1,'2013-05-21'); ```I also created another table using the records of which I have to delete records in the earlier one.``` create table eakan\_del (sec\_id int, nameid int, date date); insert into public.eakan\_del values(1,1,'2013-05-21'); commit; ```I was naive initially and did something like this: First try:``` DELETE from eakan WHERE eakan.sec\_id IN (select eakan\_del.sec\_id from eakan\_del where eakan\_del.sec\_id=eakan.sec\_id and eakan\_del.date=eakan.date and eakan\_del.nameid=eakan.nameid) and eakan.date IN (select eakan\_del.date from eakan\_del where eakan\_del.sec\_id=eakan.sec\_id and eakan\_del.date=eakan.date and eakan\_del.nameid=eakan.nameid) and eakan.nameid in (select eakan\_del.nameid from eakan\_del where eakan\_del.sec\_id=eakan.sec\_id and eakan\_del.date=eakan.date and eakan\_del.nameid=eakan.nameid); Then I realized there should be another way and used some documentation of Vertica and also checked out Vertica Forums if something was available. ...

May 30, 2013 · 2 min · 275 words