Re: A few SQL questions

From: Peter Koczan <pjkoczan(at)gmail(dot)com>
To: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: A few SQL questions
Date: 2006-12-15 03:16:15
Message-ID: 4582137F.6030600@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Perfect. Exactly what I needed. Thank you very much Richard.

Peter

Richard Broersma Jr wrote:
>> 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.
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rafal Pietrak 2006-12-15 06:59:56 Re: about the RULE system
Previous Message Tom Lane 2006-12-15 02:23:40 Re: updating a view