Some time ago, MySQL Forge went offline.
As part of the Forge dismissal operations, I got a backup of my
snippets from the MySQL community team, and I have been lazily
looking around for an alternative place where to put them.
I found such a place: Github
GIST
Gist is a simple way to share snippets and pastes with others.
All gists are git repositories, so they are automatically
versioned, forkable and usable as a git
repository.
Out of my 25 snippets, these are the ones that still look useful
(at least, people have been asking me about those).
When using Oracle, the data dictionary provides us with tons of
tables and views, allowing us to fetch information about pretty
much anything within the database. We do have information like
that in MySQL 5.0 (and up) in the information_schema
database, but it’s scattered through several different tables.
Sometimes a client asks us to change the datatype of a column, but forgets to mention the schema name, and sometimes even the table name. As you can imagine, having this kind of information is vital to locate the object and perform the requested action. This kind of behaviour must be related to Murphy’s Law.
In any case, I’d like to share with you a simple stored procedure that has helped us a lot in the past.
CREATE DATABASE IF NOT EXISTS dba; USE dba; DROP PROCEDURE IF EXISTS `dba`.`get_objects`; DELIMITER $$ CREATE …[Read more]