MySQL- SUBSTRING_INDEX – Select Patterns

Consider, a MySQL table having values in a column like below: SELECT location  FROM geo LIMIT 3; “location” “India.Karnataka.Shimoga.Gopala” “India.Karnataka.Bengaluru.BTM” “India.Karnataka.Chikmaglore.Koppa” My requirement is to take only 4th value from each of the rows(such as, Gopala,BTM,Koppa). I don’t want to…

Linux’s AWK

Linux: Adding Numbers in a File Here’s a Linux command to add numbers inside a file: [root@myserver misc]# cat num.test 1 2 3 4 5 This is a sample file with only 5 lines. Think of a file with millions…

Linux sorting, crontab & concat

Linux: Sorting a File Here’s simple ‘sort’ command that will remove the duplicate entry from any file and sort in ascending order:Consider a file with few numbers: [root@myhost tmp]# cat testSort.txt 23 4 56 001 34 3 To sort it:…

MySQL’s INTO OUTFILE for loading file

MySQL: SELECT / LOAD in Batch Here’s are the MySQL commands to extract data from  table and to load data into tables. Unlike other DBMS, MySQL offers SELECT..INTO.. and LOAD DATA.. commands are quite faster and convenient. Data would be…

MongoDB Export cmd

Here’s is a simple MongoDB ‘mongoexport’ command syntax to backup the document/database. This command can be used to backup based on particular conditions (‘where’ clause) Go to MongoDB bin  directory and execute as below:./mongoexport –host localhost –port 10000 -d doc_name…

How do we exclude SQL from replicating in MySQL

If you’re using MySQL Replication, in rare cases you may require to skip a particular SQL statement from replicating – which is to be executed on Master and should not be on the Slave. Though, its not a good practice!…

Remote file transfer using Rsync

While we usually deal with huge data, we come across situations where we need to copy such data from one server/host to a remote host. One of the useful command is ‘rsync‘, which is faster than the traditional scp command!…

MySQL Installation

While you have a basic idea about MySQL, I would recommend the real-time trial and error than just reading out. For that, download a latest stable community version of MySQL from the official website. Though MySQL is platform independent, its…

MongoDB vs MySQL

Here is a comparison between MongoDB and Relational database, MySQL:   Because of distributed key value store, MapReduce calculation capability and document oriented NoSQL features, MongoDB® is The database for Big Data processing.