Field size become unlimited in union...

Поиск
Список
Период
Сортировка
От Durumdara
Тема Field size become unlimited in union...
Дата
Msg-id CAEcMXhnD61vMMDTd_tvj2ipNLV9C-inyRSZx_LkUeQnbZnMvrg@mail.gmail.com
обсуждение исходный текст
Ответы Re: Field size become unlimited in union...  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
Hello!

As I experienced, PGSQL changes the result field sizes to unlimited varchar, when I passed different field size in same column of the union.

SP.Key - varchar(100)
SP.Value - varchar(200)

Example:

  select 'a', value from sp
  union all
  select key, value from sp


The first field is not limited to 100, it's unlimited varchar() (= Text, Memo, CLOB).

So PG don't use the maximal field size (100).


If I did cast on the field to resize to 100, the result is limited correctly.


  select cast('a' as varchar(100)), value from sp
  union all
  select key, value from sp


Can I force somehow to PG use the maximal size?
 
Or must I know and equalize all field sizes in union?

Or must I use temporary tables and inserts to not get this problem?

Thanks

Regards
    dd

В списке pgsql-general по дате отправления:

Предыдущее
От: "dandl"
Дата:
Сообщение: Does the initial postgres user have a password?
Следующее
От: Alban Hertroys
Дата:
Сообщение: Re: (VERY) Slow Query - PostgreSQL 9.2