Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
--创建测试表,一个是varchar2(5), 一个是5 char
SQL> create table test(cola varchar2(5),colb varchar2(5 char));
Table created
SQL> desc test;
Name Type Nullable Default Comments
---- ---------------- -------- ------- --------
COLA VARCHAR2(5) Y
COLB VARCHAR2(5 CHAR) Y
--插入数据,均为5个字符,正常插入
SQL> insert into test values ('abc12','abc12');
1 row inserted
SQL> select * from test;
COLA COLB
----- ----------
abc12 abc12
SQL> commit;
Commit complete
insert into test values ('abc123','abc123')
ORA-12899: 列 ""."TEST"."COLA" 的值太大 (实际值: 6, 最大值: 5)
--col b 多一个中文字符报错
SQL> insert into test values ('abc12','abc12张');
insert into test values ('abc12','abc12张')
ORA-12899: 列 ""."TEST"."COLB" 的值太大 (实际值: 6, 最大值: 5)
SQL> insert into test values ('abc12','abc1张');
2
SQL>
SQL> insert into test values ('abc12','abc1张');
1 row inserted
SQL> commit;
Commit complete
SQL> insert into test values ('abc1张','abc1张');
insert into test values ('abc1张','abc1张')
ORA-12899: 列 ""."TEST"."COLA" 的值太大 (实际值: 6, 最大值: 5)
SQL> select * from test;
2
SQL>
SQL> select * from test;
COLA COLB
----- ----------
abc12 abc12
abc12 abc1张
SQL>
--创建测试表,一个是varchar2(5), 一个是5 char
SQL> create table test(cola varchar2(5),colb varchar2(5 char));
Table created
SQL> desc test;
Name Type Nullable Default Comments
---- ---------------- -------- ------- --------
COLA VARCHAR2(5) Y
COLB VARCHAR2(5 CHAR) Y
--插入数据,均为5个字符,正常插入
SQL> insert into test values ('abc12','abc12');
1 row inserted
SQL> select * from test;
COLA COLB
----- ----------
abc12 abc12
SQL> commit;
Commit complete
--插入6个字符的的报错,varchar2(5)col A 限制了
SQL> insert into test values ('abc123','abc123');insert into test values ('abc123','abc123')
ORA-12899: 列 ""."TEST"."COLA" 的值太大 (实际值: 6, 最大值: 5)
--col b 多一个中文字符报错
SQL> insert into test values ('abc12','abc12张');
insert into test values ('abc12','abc12张')
ORA-12899: 列 ""."TEST"."COLB" 的值太大 (实际值: 6, 最大值: 5)
SQL> insert into test values ('abc12','abc1张');
2
SQL>
SQL> insert into test values ('abc12','abc1张');
1 row inserted
SQL> commit;
Commit complete
SQL> insert into test values ('abc1张','abc1张');
insert into test values ('abc1张','abc1张')
ORA-12899: 列 ""."TEST"."COLA" 的值太大 (实际值: 6, 最大值: 5)
SQL> select * from test;
2
SQL>
SQL> select * from test;
COLA COLB
----- ----------
abc12 abc12
abc12 abc1张
SQL>