Re: limit table to one row

Поиск
Список
Период
Сортировка
От Grzegorz Jaśkiewicz
Тема Re: limit table to one row
Дата
Msg-id 2f4958ff0906090837w7d945027y109573f9615ad369@mail.gmail.com
обсуждение исходный текст
Ответ на Re: limit table to one row  (Brandon Metcalf <brandon@geronimoalloys.com>)
Ответы Re: limit table to one row  (Brandon Metcalf <brandon@geronimoalloys.com>)
Список pgsql-general
2009/6/9 Brandon Metcalf <brandon@geronimoalloys.com>:

>
>  CREATE TABLE foo (
>    start  DATE,
>    length VARCHAR(10),
>  );
>
> I need to be able to get one value for each column at any given time.
> Specifically, I need to get a value for start and add the value for
> length to get a time period.  Since your approach would allow more
> than one row, how does it help me?

If you want to store period of time, why store it as varchar ?

just store two rows
create table foo(
  n varchar,
  val date
);

and store two rows:
"start", now(),
"end", now()+'something '::interval

Wouldn't that do, or is there something I misunderstand ?

The approach with vertical structure, is used when people want to
store some particular state, say - kind of like structure in C, but in
SQL, and they create table for it with all the columns, etc, and have
to limit it to one row.

On the other hand, you could also use unique index on (1) approach
(say if you need more variety of types).

--
GJ

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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: column name gets substitudes inside an execute statement of a trigger function. how to avoid it?!
Следующее
От: Brandon Metcalf
Дата:
Сообщение: Re: limit table to one row