« InfoQ : Running the Largest Hadoop DFS Cluster | Main | When a Query runs slower on second execution - a possible side effect of cardinality feedback »

Learn from the smaller one's : Native support for ENUM Types

Gerhard a colleague is dealing with Postgres databases and was very suprised how many features are very oracle like. For example the same concept of Sequences exists in Postgres as in Oracle. But then he detected the postgres enum native type support in postgres and asked me if the same feature would exist in Oracle. But no - it was not.

An enum is something like a column check-constraint - definition of a list of values allowed for the enum type. The advantage of an enum is that the constraint checking for allowed values is defined globally once and must not repeated from table to table declaration - an example from the PostgresSQL Documentation : 

Once created, the enum type can be used in table and function definitions much like any other type:

Example 8-3. Basic Enum Usage

CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy');
    name text,
    current_mood mood

INSERT INTO person VALUES ('Moe', 'happy');

SELECT * FROM person WHERE current_mood = 'happy';
 name | current_mood
 Moe  | happy
(1 row)


References (2)

References allow you to track sources for this article, as well as articles that were written in response to this article.

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>