Showing entries 31 to 40 of 68
« 10 Newer Entries | 10 Older Entries »
Displaying posts with tag: stored procedure (reset)
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 some […]

Stored Procedure For Finding Columns In MySQL

Looking for instances particular column in a large schema can be a pain. Fortunately the information schema makes this pretty easy, if your columns have a consistent naming convention.

SELECT table_schema, table_name, column_name
FROM information_schema.columns
WHERE column_name LIKE '%some_name%';

Now, if we want to wrap this up into an easy to use stored procedure, we can do something like this:

drop procedure find_column;
delimiter //
CREATE PROCEDURE find_column(c varchar(255))
        SET @a = CONCAT("%", c, "%");
        SELECT table_schema, table_name, column_name, column_type
                FROM information_schema.columns
                WHERE column_name LIKE @a;
delimiter ;

We need to use the concat statement in order to properly get the quotes in there without using the literal string “c” in the LIKE statement.

You can do a search as follows:

[Read more]
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 […]

Stored procedure to Find database objects

This procedure lists available database objects under passed database name. It lists present Tables, Views, Stored Procedures, Functions and Triggers under particular database. It also lists storage engine of tables. It uses information schema database to gather information and storing in a temporary table. Usage: call xplore(database-name); – Procedure will search through information schema for […]

Calculate Mysql Memory Usage – Quick Stored Procedure

In this post we will look into the MySQL memory utilization estimation or calculation based on the global variables. Using a simple stored procedure call you can get the memory usage estimation for the present MySQL instance. We have global buffers which are allocated irrespective of connections as and when mysql server is started. Along with […]

Search / find through all databases, tables, columns in MySQL

What will you do if one day some one ask you to find single string in all databases, all tables and in all columns? I just read such question and tried to find a “ready made” solution. Reusability is Key Concept !! But I ended up finding no “copy-paste” material. Some of the posts like helped me […]

A year in review; new direction.

It has been more than a year since my self-imposed hiatus from serious MySQL development started and I think it is about time that I get back into the saddle. I have a handful of working prototypes but I should get the code out there, back into the community.I learned a bunch of stuff during the past year at Google but in the end, working on JavaScript, HTML/CSS and Google proprietary languages

MySQL processlist – (show/kill processes)

It”s not the most common task in the world, but you might want to view processes from a particular user and once in a while you might even need to kill processes from a single user, be it during an attack or because you simply got a bug in an application bombarding your db server with connections!

Here is a small stored procedure which does exactly that!

call process_list("show","username","hostname");

– shows all processes owned by username@hostname

call process_list("kill","username","hostname");

– kills all processes owned by username@hostname

The code for this stored procedure can be found below. If you have any comments / suggestions feel free to comment below.

##                                        …

[Read more]
Perl and Java Stored Procedures for MariaDB 5.1

I just applied the external stored procedure patch to a branch of MariaDB and uploaded it to LaunchPad.You can see the branch at that this is not in any reasonable condition to merge into MariaDB. Hopefully we can engage in dialog as to how we can bring this feature properly to MariaDB, MySQL and Drizzle, hopefully making the plugins

Showing entries 31 to 40 of 68
« 10 Newer Entries | 10 Older Entries »