Constraint: string length must be 32 chars

From: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Constraint: string length must be 32 chars
Date: 2010-10-16 16:15:30
Message-ID: AANLkTi=G+2XpqqtyXm-HNmU75eq5WKAWska0jE+eAuTs@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I'm trying to create a table, where md5 strings will serve as primary keys.
So I'd like to add a constraing that the key length should be 32 chars long
(and contain [a-fA-F0-9] only):

create table gps (
id varchar(32) primary key CONSTRAINT char_length(id)==32,
stamp timestamp DEFAULT current_timestamp,
pos point);

But it fails:

ERROR: syntax error at or near "("
LINE 2: id varchar(32) primary key CONSTRAINT char_length(id)==32,
^
Does anybody please know what's wrong here?

Thank you
Alex

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2010-10-16 16:18:04 Re: Automated Database Backups
Previous Message Terry Laurenzo 2010-10-16 15:58:30 Re: Request for comment: pgjson project