SQL category archives

Oracle testing with the DUAL table

This feature is a hack intended for testing, but it’s built in to every Oracle installation.
DUAL is a table automatically created by Oracle and accessible to all users. It has one column, DUMMY, containing one row. It’s useful for selecting a constant or expression, because the table always exists (so the query will succeed) and […]

Oracle silently truncates dates

According to the documentation, the Oracle DATE type does not store fractions of a second. So if you store a date/time value including fractions of a second and read it back, you’ll get back a slightly different date/time. This will cause exact date matching code in your appplication to fail.

Oracle empty string = null

In Oracle 8, there is no such thing as a zero-length string. Any zero-length string, either from a function call or the literal ”, is treated as null.

Don’t use automatically generated unique IDs

Think carefully before using an automatically-generated unique ID as a primary key in a SQL table. Using such automatically-generated IDs introduces extra implementation detail. This is a pain to manage, especially if they are used as primary keys or worse, foreign keys in tables.

Close
E-mail It