Re: Error when creating a char column as primary key - Mailing list pgsql-novice

From Tom Lane
Subject Re: Error when creating a char column as primary key
Date
Msg-id 12269.1037894653@sss.pgh.pa.us
Whole thread Raw
In response to Re: Error when creating a char column as primary key  ("Devinder K Rajput" <Devinder.Rajput@ipaper.com>)
List pgsql-novice
"Devinder K Rajput" <Devinder.Rajput@ipaper.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

pgsql-novice by date:

Previous
From: "Devinder K Rajput"
Date:
Subject: Re: Error when creating a char column as primary key
Next
From: Dan Jewett
Date:
Subject: function does not exist error...