Categories
MySQL

MySQL Scheduled Backup

Another of these things that I'll park here until I have the time to implement it.  A MySQL backup solution to to scheduled backups and optionally email the backup files and logs.  Open Source, of course.

http://www.debianhelp.co.uk/mysqlscript.htm

Categories
MySQL

MySQL Triggers

This external resource looks like about the best tutorial I've seen yet for MySQL Triggers.  I'm going to have to play with this, I've been putting off implementing some necessary triggers for lack of a clear tutorial to guide my first efforts.

http://forge.mysql.com/wiki/Triggers

 

Categories
MySQL

Foreign Keys and Referential Integrity in MySQL

This TechRepublic article is a good fast introduction to the topic of Referential Integrity and the use of  Foreign Keys in MySQL.

Categories
MySQL

Trim leading whitespace from a field in MySQL

As always, backup the database or at least the affected table before running a command that will change every record in a table as this does.

The following line will remove the leading spaces (note the parameter '\t'). For new lines use '\n' and for carriage returns use '\r'.

UPDATE members SET memberid = REPLACE(memberid,'\t','');

For more information, see http://stackoverflow.com/questions/281724/does-the-mysql-trim-function-not-trim-line-breaks-or-carriage-returns.

Categories
MySQL

Using Variables in MySQL

Finding the correct syntax for using variables in MySQL can be surprisingly difficult.
Once you know it, it's easy. Here's a start:

SET @username := 'jonesr';
SELECT id,fname,lname FROM staff WHERE username = @username;