Re: Create table error

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Create table error
Дата
Msg-id 20040914145017.U27974@megazone.bigpanda.com
обсуждение исходный текст
Ответ на Re: Create table error  (Kumar S <ps_postgres@yahoo.com>)
Список pgsql-novice
On Tue, 14 Sep 2004, Kumar S wrote:

> Thank you Stephan Szabo,
>  I removed additional information from parenthesis and
> it worked.
> What I wanted to store is a number (e.g:15099404)
> which is a publication ID from PubMed (medical litt.
> database).  This number I wanted to use further to
> build queries to extract the publication linked to
> that number.
>
> My collegue suggested that I could store that number
> as a string too because I will not be doing any
> calculations on that number.

Well, it all depends on how it's used.  For example,
would you want to sort on the field, and would you
want 9000 to come before or after 150000? Does the
value ever have leading zeros that it would be bad
to lose?

If you're really just using it as a value that's only ever compared to be
= (or <>), a string is fine (*). If it's got to have leading zeros, a
string is nearly necessary.  If you want numeric sorting on the field
you'd either need to cast in your queries or use a number. If you're
comparing like ids after 15099403 where you want a numeric comparison
rather than a textual one, you'll need to cast or use a numer.

(*) - You probably would want a constraint to keep the valid values
constrained appropriately.


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

Предыдущее
От: Kumar S
Дата:
Сообщение: Re: Create table error
Следующее
От: Josh Berkus
Дата:
Сообщение: Re: Serial datatype clarification