SQL

DELETE, TRUNCATE and DROP – all three commands get rid of table data. How exactly are they different? When should you use which?

A bird’s eye view of their differences, a table comparing the three.

[click to continue…]

{ 14 comments }

“How can I select the Nth highest salary of the EMP table?”

This is a question that every Oracle newbie stumbles over. Ask it on a forum and you’re pointed to the archives. That gets you nowhere as when you search the archives, all you find is a host of other messages also asking you to search the archives.

Here comes the answer to the problem of finding the Nth highest salary. You can extend this logic to find the Nth highest row of any table.

[click to continue…]

{ 44 comments }

In applications that take user email id as input, there is a need to check for email id validity. Here is a very easy validation for syntax of an email address, using regular expressions in Oracle SQL.

The basic email address format is username@example.com. The SQL will verify that the email address provided fits into that format. This can be used before data entry, or coded on a table as a check constraint.

[click to continue…]

{ 8 comments }

What is a regular expression?

A regular expression (also called regex or regexp for short) is a sequence of characters that describes a pattern in text.

Regular Expressions in Oracle

Some examples of regular expressions:

p..t => A dot stands for a single character. This regular expression will match words that start with a ‘p’, end with a ‘t’ and have any two characters in between them (since there are two dots within).

[click to continue…]

{ 4 comments }