Sunday, April 20, 2014
Text Size

Regular Expressions in SQL

Practice makes perfect. Or in my case, any practice is a start. This article serves as a quick note on how to use regular expressions within SQL statements:

For the following examples, I am pretending to select rows from a table called `STUDENTS`.

Regular Expression Basic Usage Examples

A quick reminder on basic regular expressions.

Match Any Character — Dot
The dot operator '.' matches any single character in the current character set. For example, to find the sequence--'a', followed by any character, followed by 'c'--use the expression:

  1.  a.c 
This expression matches all of the following sequences:

  1.  abc 
  2.  adc 
  3.  a1c 
  4.  a&c 
The expression does not match:

  1.  abb 

Anti-SQL Injection Login Username/Password

I was going to append this to one of my articles on anti-sql injection but as this may undergo some revisions, I'll give it it's own page.

The following PHP code accepts a username and password login and demonstrates how to check against the database without including text that the website visitor submits.


Modifying columns in a table

This is an article to remind me how to modify a column in a database table the old fashioned way (as in stop making me use GUI interfaces so poorly programmed when even I've made better DBMS tools).


  1.  -- Add a column to an existing table (giving it datatype char(2) and allowing NULL) 
  2.  ALTER TABLE myTable ADD myColumn CHAR(2) NULL 
  4.  -- Delete a column 
  5.  ALTER TABLE myTable DROP COLUMN myColumn  
  7.  -- Reorder a column 
  8.  ALTER TABLE myTable MODIFY COLUMN misplacedColumn AFTER otherColumn; 

Access MySQL databases using Oracle SQL Developer

So this is a quick article on how to install the mySQL add-on for Oracle SQL Developer v3.0.04.

I've used various mySQL administration tools to manage mySQL databases over the years, all freeware until someone expresses an interest in using it and then the supplier will implement restrictions and trial based versions. Oracle SQL Developer is currently free at time of print (01-FEB-2013).

I also need to use Oracle databases in my day job so the Oracle SQL developer is already a pre-approved software for our work computers. We have SQL Server Management Studio (SSMS) as well for our SQL Server instances but it wasn't practical to link this to mySQL databases.


Latest Posts

  • 301 Redirect using htaccess file

    • Tue 15-Apr-14
      Further suggestion:
      RewriteRule ^(.*/)?assets/s 2dmain.html\?/( .*/)? $2 [R=301,L]
    • Thu 10-Apr-14
      Playing with some RegEx testers
      RewriteRule ^(.*\?/)?(?:$|( .+?)(?:(\.[^.]$ )|$)) $2 [R=301,L] ...
    • Wed 09-Apr-14
      I tried to redirect links from my old site to my new site, based on what I read in this thread. The old ...
  • JComments 2.3.0 with ReCaptcha in Joomla 2.5.x

    • Fri 28-Mar-14
      You are a rockstar mate! thanks. Followed the steps listed and it worked! If only all tutorials were ...
  • K2 Items disappear

    • Thu 03-Apr-14
      The fix works great, but the problem is occurring a couple of times a day. Any idea how to fix ...
      Larry C.