Michael Scharf <[EMAIL PROTECTED]> writes:
> Jim C. Nasby wrote:
>> On Thu, Jan 05, 2006 at 01:39:02PM -0600, Kurt Welgehausen wrote:
>>
>>> create trigger EnumTrg before insert on MainTbl for each row
>>> when (select count(*) from EnumVals where val = new.EnumCol) = 0 begin
>>> select
> ... you'll also need to write an update trigger ...
True, and you may want to protect EnumVals with triggers after
you populate it, or put EnumVals is a separate read-only
database and attach it. On the other hand, being able to change
the allowed values without changing the schema may be an
On Thu, Jan 05, 2006 at 01:39:02PM -0600, Kurt Welgehausen wrote:
> create trigger EnumTrg before insert on MainTbl for each row
> when (select count(*) from EnumVals where val = new.EnumCol) = 0 begin
>select raise(rollback, 'foreign-key violation: MainTbl.EnumCol');
> end;
Wouldn't that
Kurt Welgehausen said:
>> SQLite doesn't support enums natively. You could emulate it using
>> triggers, although it would be somewhat hidden and definitely a pain in
>> the tucus to use.
>
> It's not really so hard.
>
> create table MainTbl (
> ...
> EnumCol SomeType references EnumVals,
>
> SQLite doesn't support enums natively. You could emulate it using
> triggers, although it would be somewhat hidden and definitely a pain in
> the tucus to use.
It's not really so hard.
create table MainTbl (
...
EnumCol SomeType references EnumVals,
...);
create table EnumVals (val
Rajan, Vivek K said:
> I would like to know the following:
>
> *Does SQLite support enum like MySQL? If yes, how to use it
>
> *If not, is there another way to model enumeration in SQLite?
> And/or any plans going forward to support enums natively in SQLit
I would like to know the following:
*Does SQLite support enum like MySQL? If yes, how to use it
*If not, is there another way to model enumeration in SQLite?
And/or any plans going forward to support enums natively in SQLite?
Rajan
7 matches
Mail list logo