Re: Error when creating a char column as primary key

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Devinder K Rajput" <Devinder(dot)Rajput(at)ipaper(dot)com>
Cc: "Gavin Reade" <gavin(dot)reade(at)innogy(dot)com>, "'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Error when creating a char column as primary key
Date: 2002-11-21 16:04:13
Message-ID: 12269.1037894653@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Devinder K Rajput" <Devinder(dot)Rajput(at)ipaper(dot)com> writes:
>> CREATE TABLE table (serial_no VARCHAR[16] PRIMARY KEY, date date DEFAULT
>> current_date)
>> ERROR: Can't find a default operator class for type 1015

> use VARCHAR(16) and not VARCHAR[16].

Also, consider updating to a more recent version of Postgres. It's been
a very long time since that error message gave a numeric type OID. In
7.2 and later I get

regression=# CREATE TABLE ztable (serial_no VARCHAR[16] PRIMARY KEY);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'ztable_pkey' for table 'ztable'
ERROR: data type character varying[] has no default operator class for access method "btree"
You must specify an operator class for the index or define a
default operator class for the data type

which at least gives you some shot at realizing that you've specified an
array type ...

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Dan Jewett 2002-11-21 19:14:03 function does not exist error...
Previous Message Devinder K Rajput 2002-11-21 15:31:51 Re: Error when creating a char column as primary key