开始创建表:
create table if not exists ta(
id smallint not null auto_increment,
title varchar not null
);
系统会报错:you have a errno in your sql syntax; check the manual that corrresponds to your mysql server version for the right syntax to use near 'not null'.....
更改创建命令:
create table if not exists ta(
id smallint not null auto_increment,
title varchar(255) not null
);
query Ok; 命令被正确执行
若更改varchar类型为char,同时不指定类型的最大值:
create table if not exists ta(
id smallint not null auto_increment,
title char not null
);
query OK ;命令被正确执行
小结:在给列设置string类型的时候,如果指定列的类型为varchar则需要指定该类型的最大‘容量值‘,若为char类型则不必。