Re: Error when creating a char column as primary key

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Error when creating a char column as primary key
Дата
Msg-id 12269.1037894653@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Error when creating a char column as primary key  ("Devinder K Rajput" <Devinder.Rajput@ipaper.com>)
Список 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 по дате отправления:

Предыдущее
От: "Devinder K Rajput"
Дата:
Сообщение: Re: Error when creating a char column as primary key
Следующее
От: Dan Jewett
Дата:
Сообщение: function does not exist error...