Re: Are globally defined constants possible at all ?
От | Nigel J. Andrews |
---|---|
Тема | Re: Are globally defined constants possible at all ? |
Дата | |
Msg-id | Pine.LNX.4.21.0206091639010.4131-100000@ponder.fairway2k.co.uk обсуждение исходный текст |
Ответ на | Re: Are globally defined constants possible at all ? (Andrew Sullivan <andrew@libertyrms.info>) |
Ответы |
Re: Are globally defined constants possible at all ?
Re: Are globally defined constants possible at all ? |
Список | pgsql-general |
On Fri, 7 Jun 2002, Andrew Sullivan wrote: > On Fri, Jun 07, 2002 at 05:29:27PM -0400, Gregory Seidman wrote: > > > > Er, could you expand on that? Are you suggesting something like this: > > > > CREATE TABLE Foo ( > > KindID int, > > ... > > CONSTRAINT fooenum > > CHECK KindID IN ('SOFTWARE', 'HARDWARE') > > ); > > Yes. Except I think you need another set of parentheses > > check("KindID" IN ('SOFTWARE','HARDWARE')) Can this be done? What are the integers derived from the strings and is there any chance of them not being unique? The following message shows a what I think is a more consistent way of writing it but I still can't see how use of CHECK makes the mapping from a textual type to integer. Darren Ferguson wrote on Sun Jun 9 at 16:38:53 2002 > >Check can be used in the following way > >status VARCHAR(32) DEFAULT 'new' NOT NULL > CHECK(status IN ('new','read','deleted')), > >On Fri, 7 Jun 2002, Nigel J. Andrews wrote: > > >> On Fri, 7 Jun 2002, Andrew Sullivan wrote: >> > >> > On Fri, Jun 07, 2002 at 02:36:35PM -0400, Gregory Seidman wrote: >> > >> > > I am in the exact same position. I have a number of things which are >> > > essentially enumerations. Since PostgreSQL does not support an enumeration >> > > type (MySQL does, but then it doesn't have a proper boolean type), I have a >> > >> > Why don't you use a CHECK contraint? That's the standard way to do >> > it. >> >> I wonder if you could explain how to use CHECK for this please? I'm having a >> little trouble thinking in that manner but then I've only seen and used the >> table associating name and value method before and so am a little biased. -- Nigel J. Andrews Director --- Logictree Systems Limited Computer Consultants
В списке pgsql-general по дате отправления: