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

Windows Run box

Some cool windows hacks that I learned recently. Open the run command dialog box and type in the following short cuts to access the corresponding windows utilities. Accessibility Controls - access.cpl Accessibility Wizard - accwiz Add Hardware Wizard - hdwwiz.cpl Add/Remove Programs - appwiz.cpl Administrative Tools - control admintools Automatic Updates - wuaucpl.cpl Bluetooth Transfer Wizard - fsquirt Calculator - calc Certificate Manager - certmgr.msc Character Map - charmap Check Disk Utility - chkdsk Clipboard Viewer - clipbrd Command Prompt - cmd Component Services - dcomcnfg Computer Management - compmgmt.msc Control Panel - control Date and Time Properties - timedate.cpl DDE Shares - ddeshare Device Manager - devmgmt.msc Direct X Troubleshooter - dxdiag Disk Cleanup Utility - cleanmgr Disk Defragment - dfrg.msc Disk Management - diskmgmt.msc Disk Partition Manager - diskpart Display Properties - control desktop Display Properties - desk.cpl Dr. Watson System Troubleshooting­ Utility - drwtsn32 Driver Verifier Utility - verifier Event Viewer - eventvwr.msc Files and Settings Transfer Tool - migwiz File Signature Verification Tool - sigverif Findfast - findfast.cpl Firefox - firefox Folders Properties - control folders Fonts - control fonts Fonts Folder - fonts Free Cell Card Game - freecell Game Controllers - joy.cpl Group Policy Editor (for xp professional) - gpedit.msc Hearts Card Game - mshearts Help and Support - helpctr HyperTerminal - hypertrm Iexpress Wizard - iexpress Indexing Service - ciadv.msc Internet Connection Wizard - icwconn1 Internet Explorer - iexplore Internet Properties - inetcpl.cpl Keyboard Properties - control keyboard Local Security Settings - secpol.msc Local Users and Groups - lusrmgr.msc Logs You Out Of Windows - logoff Malicious Software Removal Tool - mrt Microsoft Chat - winchat Microsoft Movie Maker - moviemk Microsoft Paint - mspaint Microsoft Syncronization Tool - mobsync Minesweeper Game - winmine Mouse Properties - control mouse Mouse Properties - main.cpl Netmeeting - conf Network Connections - control netconnections Network Connections - ncpa.cpl Network Setup Wizard - netsetup.cpl Notepad - notepad Object Packager - packager ODBC Data Source Administrator - odbccp32.cpl On Screen Keyboard - osk Outlook Express - msimn Paint - pbrush Password Properties - password.cpl Performance Monitor - perfmon.msc Performance Monitor - perfmon Phone and Modem Options - telephon.cpl Phone Dialer - dialer Pinball Game - pinball Power Configuration - powercfg.cpl Printers and Faxes - control printers Printers Folder - printers Regional Settings - intl.cpl Registry Editor - regedit Registry Editor - regedit32 Remote Access Phonebook - rasphone Remote Desktop - mstsc Removable Storage - ntmsmgr.msc Removable Storage Operator Requests - ntmsoprq.msc Resultant Set of Policy (for xp professional) - rsop.msc Scanners and Cameras - sticpl.cpl Scheduled Tasks - control schedtasks Security Center - wscui.cpl Services - services.msc Shared Folders - fsmgmt.msc Shuts Down Windows - shutdown Sounds and Audio - mmsys.cpl Spider Solitare Card Game - spider SQL Client Configuration - cliconfg System Configuration Editor - sysedit System Configuration Utility - msconfig System Information - msinfo32 System Properties - sysdm.cpl Task Manager - taskmgr TCP Tester - tcptest Telnet Client - telnet User Account Management - nusrmgr.cpl Utility Manager - utilman Windows Address Book - wab Windows Address Book Import Utility - wabmig Windows Explorer - explorer Windows Firewall - firewall.cpl Windows Magnifier - magnify Windows Management Infrastructure - wmimgmt.msc Windows Media Player - wmplayer Windows Messenger - msmsgs Windows System Security Tool - syskey Windows Update Launches - wupdmgr Windows Version - winver Wordpad - write

May 7, 2013 · 3 min · 559 words

xargs saved my day

So I was doing my regular job, writing new queries to test out my team’s new databases on Vertica. And suddenly my senior manager sends out an email to all in the team asking an estimated disk space requirement for each of our work. I had to find out how much space the raw data files for a complete history that were used to load my databases occupy on disk. ...

February 6, 2013 · 6 min · 1112 words

Emacs - Copy Line

To get the equivalent of kill line command in emacs for copying purposes, I use the following code snippet. Just copy paste it in your .emacs file. (defun copy-line (arg) "Copy lines (as many as prefix argument) in the kill ring" (interactive "p") (kill-ring-save (line-beginning-position) (line-beginning-position (+ 1 arg))) (message "%d line%s copied" arg (if (= 1 arg) "" "s"))) (global-set-key "\\M-k" 'copy-line) If \C is your control key then \M is your alt key. So generally by default your kill line can be done by \C-k Now you can also copy a line by doing: \M-k I don’t remember where I got this bit of code from, I lost those tabs when Firefox crashed. ...

October 2, 2012 · 1 min · 130 words