--
-- ### Check constraint checks
--

create table t1 ( primary a int not null, b int );
alter table t1 add check chk1 on b < 10;

insert into t1 values ( 1, 1);
insert into t1 values ( 2, 2);
insert into t1 values ( 3, 3);
insert into t1 values ( 4, 9);

create table t2 ( a int, b string(10));

-- alter table t2 add check chk2 on b = 'Alpha' or ( b = 'beta' and a >= 3);
alter table t2 add check chk2 on b = 'Alpha' or  a >= 3;

-- also functions can be used in check contraints
-- alter table t2 add check chk3 on length(b) > 3;

insert into t2 values ( 1, 'Alpha');
insert into t2 values ( 3, 'beta');
insert into t2 values ( 4, 'beta');

update t2 set a = 5 where b = 'beta';

-- rename check chk2 to xxxchk;

tableinfo t2;

drop table t1;
drop table t2;


