Re: Converting MySQL tinyint to PostgreSQL

From: John DeSoi <desoi(at)pgedit(dot)com>
To: Joe <svn(at)freedomcircle(dot)net>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Converting MySQL tinyint to PostgreSQL
Date: 2005-07-12 13:51:40
Message-ID: DAB6242D-C036-4F4D-8D06-A6F0D8F26C0C@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jul 12, 2005, at 1:16 AM, Joe wrote:

> I have a MySQL database that I'm converting to PostgreSQL which has
> 10 columns with TINYINT type, i.e., a one-byte integer. Only one
> of them qualifies as a true BOOLEAN. Two are entity identifiers
> (for limited range "classes" or "categories") and three others are
> "type"/code values. The last four are month numbers or day of
> month numbers (not implemented as date types because the year is
> separate and is part of the primary key).
>
> I'm wondering what would be the best conversion choice for these
> columns: smallint, numeric(1), char(1), something else? AFAICT,
> the application does not directly do any arithmetic on these
> columns, but the identifier and code types are used as indices into
> PHP arrays. The month/day values are formatted into dates for
> display (and the month also servers as an index into a month-name
> array).
>

I would use smallint. While PHP might work fine with something else,
it seems like the closest match.

> BTW, is TINYINT part of any SQL Standard?

From the pg docs:

SQL only specifies the integer types integer (or int) and smallint.
The type bigint, and the type names int2, int4, and int8 are
extensions, which are shared with various other SQL database systems.

John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-07-12 14:13:30 Re: index bloat
Previous Message Benoît Toutain 2005-07-12 13:45:30 Schema accidentaly dropped in pg_namespace table