Category Archives: Oracle

GUID Values as Primary Keys

A Globally Unique Identifier (GUID) is an excellent choice for a primary key. It has three of the main attributes I look for in a primary key:

  • It’s compact: just 16 bytes.
  • It’s guaranteed to be unique.
  • It’s not a business value like an SSN or an account number. This is important because once a primary key value is assigned it shouldn’t change, and business values – even SSN’s – can change.
  •  
    This post shows how to use a GUID in Oracle, SQL Server, and MySQL. A GUID is a 16-byte binary value that should always be unique. Oracle, SQL Server, and MySQL all have functions that will generate a GUID. Their functions vary, as do the data types used to represent the GUID. Continue reading

    Teradata Primer for SQL Developers: Character Functions

    Introduction

    I recently started working with Teradata for a client, and my initial line of learning has been to compare and constrast Teradata functionality with Oracle, the database I know best. This post covers Teradata character (string) functions and their Oracle equivalents.  I’ve included their SQL Server and MySQL equivalents as well. Continue reading

    Teradata Primer for SQL Developers: Numeric Functions

    Introduction

    I recently started working with Teradata for a client, and my initial line of learning has been to compare and constrast Teradata functionality with Oracle, the database I know best. This post covers Teradata numeric functions and their Oracle equivalents.  I’ve included their SQL Server and MySQL equivalents as well. Continue reading

    Calculating Time Spans Between Rows in Oracle

    Oracle’s analytic functions are great for summarizing data, but that’s only part of their power. The LEAD and LAG analytic functions let you work with values from preceding or following rows, something that’s difficult – and often impossible – to do with non-analytic queries.

    This post shows how to use the LAG function to calculate time spans between events in a log file. Continue reading