Re: A few SQL questions

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: A few SQL questions
Дата
Msg-id 43128.78375.qm@web31812.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на A few SQL questions  ("Peter Koczan" <pjkoczan@gmail.com>)
Ответы Re: A few SQL questions  (Peter Koczan <pjkoczan@gmail.com>)
Список pgsql-general
> 1. In sybase, each column can have the same rule applied to it. You don't
> have to create multiple rules for columns in different tables. For instance,
> let's suppose that we require 5 digit numeric ids, using only a char(5)
> type, but there's a constraint on that column that says it must adhere to
> idrule, and idrule is defined as:
>
> create rule idrule as @id like "[0-9][0-9][0-9][0-9][0-9]" (ugly, I know,
> but i didn't write it)

A domain will do this:
http://www.postgresql.org/docs/8.2/interactive/sql-createdomain.html
http://www.postgresql.org/docs/8.2/interactive/functions-matching.html#FUNCTIONS-POSIX-REGEXP
in the constraint portion of the syntax you can specify a regular expression
id ~ '^[0-9]{5}$'

> 2. Is there any nice way to generate number sequences via select? In other
> words, something along the lines of:
> select 1 through 10 as number;

generate_series() should do what you want.
http://www.postgresql.org/docs/8.2/interactive/functions-srf.html

Regards,

Richard Broersma Jr.

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

Предыдущее
От: "Peter Koczan"
Дата:
Сообщение: A few SQL questions
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Temp file space (Re: creating an index with tablespace on a dedicated filesystem)