Showing entries 1 to 10 of 16
6 Older Entries »
Displaying posts with tag: MySQL-Scripts (reset)
MySQL function returns dates of specified day & between date range

This mysql stored function will return you all the dates between given dates having specified day. In short if you say: give me all Sundays in this month. I have following for you: mysql> select Give_Me_Dates_Days(1,'2012-09-01','2012-10-01') as All_Sundays; +--------------------------------------------------------+ | All_Sundays | +--------------------------------------------------------+ | 2012-09-02,2012-09-09,2012-09-16,2012-09-23,2012-09-30 | +--------------------------------------------------------+ The function parameters are as follows: Give_Me_Dates_Days(DAY_IDENTIFIER,START_DATE,END_DATE) Sunday […]

Generate random test data for MySQL using routines

At times you’ll find yourself responsible for generating test data for newly created tables for testing or sampling purpose. There are tools that will generate random data for you but they’re not free. At-times you’ll write scripts to generate data but those will be table specific. I hate generating dummy data, yes I do and […]

MySQL Function to Convert Date To Words

Recently I saw a MySQL Stored Function requirement on Experts-Exchange for converting date into some specific words format. You may find MySQL function for date to words conversion online; even udfs might be ready, but I decided to write my own. I wrote this simple function mainly based on SELECT CASE to convert dates in […]

MySQL Stored procedure to Generate-Extract Insert Statement

A lot of places I saw people asking for ways to generate Insert statements. We do have GUI Tools which can extract insert statements for us readily. of the time I choose the MySQLDump way to generate insert statements. mysqldump -uroot -ppassword –complete-insert –no-create-info DATABASE TABLENAME > TABLENAME.sql But mind is very unstable and hungry, […]

MySQL Load Data Infile Syntax Generator Tool Download

The LOAD DATA INFILE statement reads rows from a text file into a table at a very high speed. The file name must be given as a literal string. I have already written the basic how to follow that considering additional cases. A lot of questions I have seen for loading separated data to MySQL, […]

Ideas for select all columns but one mysql stored procedure

Assume we’ve a table with 100 rows and we need to select all columns but one. The problem is headache of actually typing out all 99 required columns!! Solutions / Ideas to above problem are: Ignorance is bliss. Select all(*) and ignore the column. Manually type column names or manage it with copy paste! Create […]

MyDumpSplitter-Extract split database or tables from mysqldump | MySQL dump splitter

The Mysqldumpsplitter can extract database, table, all databases, all tables or tables matching on regular expression from a mysqldump. It can produce the compressed output of sqls in specified directories. The tool has undergone a complete rewrite, and there are many more functionalities added. Please follow GitHub Repository for future changes or further improvements. Download […]

Stored procedure to add-remove prefix by rename table mysql

Here is one more procedure – (this time) for mass renaming of table. Adding and Removing table-name prefixes 🙂 A friend of mine was renaming 100+ tables by using replace methods in notepad. I showed em a bit better editor: Editplus and then I thought of rescue rest of those who are still interested in […]

MySQL Stored procedure – Split Delimited string into Rows

This procedure will split  a “;” separated column in to new fields preserving ids. This is very specific problem, lets check it with example. Consider a sample table test: And we want output as follows: So again I wrote a procedure. Procedure will read a data from “tmp” table and will split data by my_delimiter […]

MySQL Stored procedure – Execute query if table or Column exists

Well procedures mainly carried out working with information schema and it’s usage in stored procedure. Procedures are fairly simple and easy to understand. 1. Edit_table – following procedure executes queries to particular table if it exists. Basically I created it to satisfy a need of altering a table if column exists. Now it can be used […]

Showing entries 1 to 10 of 16
6 Older Entries »