On Fri, Apr 18, 2014 at 4:42 PM, Simon Slavin <slav...@bigfraud.org> wrote:
> On 18 Apr 2014, at 3:21pm, Dominique Devienne <ddevie...@gmail.com> wrote:
>> No need to resort to triggers. A simple check constraint will do
>
> A constraint can prevent you from putting too-long values in the field.  A 
> trigger can truncate the value to the correct length, which is what declaring 
> a column as VARCHAR() would do.

I'm not sure where you get that declaring a column as varchar()
implicitly truncate, but at least Oracle's VARCHAR2 behaves just like
the check constraint I demonstrated in SQLite earlier. --DD

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table t (name varchar2(2));

Table created.

SQL> insert into t values ('a');

1 row created.

SQL> insert into t values ('aa');

1 row created.

SQL> insert into t values ('aaa');
insert into t values ('aaa')
                      *
ERROR at line 1:
ORA-12899: value too large for column "xxx"."T"."NAME" (actual: 3, maximum: 2)


SQL>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to