create database bbs;use bbs;create table article 
(
id int primary key auto_increment,
pid int,
rootid int,
title varchar(255),
cont text,
pdate datetime,
isleaf int #1-not leaf 0-leaf
);insert into article values (null, 0, 1, '蚂蚁大战大象', '蚂蚁大战大象', now(), 1);
insert into article values (null, 1, 1, '大象被打趴下了', '大象被打趴下了',now(), 1);
insert into article values (null, 2, 1, '蚂蚁也不好过','蚂蚁也不好过', now(), 0);
insert into article values (null, 2, 1, '瞎说', '瞎说', now(), 1);
insert into article values (null, 4, 1, '没有瞎说', '没有瞎说', now(), 0);
insert into article values (null, 1, 1, '怎么可能', '怎么可能', now(), 1);
insert into article values (null, 6, 1, '怎么没有可能', '怎么没有可能', now(), 0);
insert into article values (null, 6, 1, '可能性是很大的', '可能性是很大的', now(), 0);
insert into article values (null, 2, 1, '大象进医院了', '大象进医院了', now(), 1);
insert into article values (null, 9, 1, '护士是蚂蚁', '护士是蚂蚁', now(), 0);
这个数据库创建不起,弹出Data too long for column 'title' at row 1.我没有想明白这到底是什么原因,请大家指点

解决方案 »

  1.   

    你用的什么字符集?
    set names 'gbk'
    然后再建库插入数据试试。
      

  2.   

    报错貌似很明显,你的title列长度不够.
    增加title列的长度.
    另外建议创建数据库时指定字符集为utf8,这样在读取是就不需要set names来保证读取汉字不乱码
      

  3.   

    请楼主在MYSQL命令行工具中试一下,以断定是语句的问题还是你自己的工具的问题。
    mysql> create table article
        -> (
        -> id int primary key auto_increment,
        -> pid int,
        -> rootid int,
        -> title varchar(255),
        -> cont text,
        -> pdate datetime,
        -> isleaf int #1-not leaf 0-leaf
        -> );
    Query OK, 0 rows affected (3.00 sec)mysql> insert into article values (null, 0, 1, '蚂蚁大战大象', '蚂蚁大战大象', n
    ow(), 1);
    Query OK, 1 row affected, 2 warnings (0.15 sec)mysql> insert into article values (null, 1, 1, '大象被打趴下了', '大象被打趴下了
    ',now(), 1);
    Query OK, 1 row affected, 2 warnings (0.00 sec)mysql> insert into article values (null, 2, 1, '蚂蚁也不好过','蚂蚁也不好过', no
    w(), 0);
    Query OK, 1 row affected, 2 warnings (0.04 sec)mysql> insert into article values (null, 2, 1, '瞎说', '瞎说', now(), 1);
    Query OK, 1 row affected, 2 warnings (0.00 sec)mysql> insert into article values (null, 4, 1, '没有瞎说', '没有瞎说', now(), 0)
    ;
    Query OK, 1 row affected, 2 warnings (0.01 sec)mysql> insert into article values (null, 1, 1, '怎么可能', '怎么可能', now(), 1)
    ;
    Query OK, 1 row affected, 2 warnings (0.00 sec)mysql> insert into article values (null, 6, 1, '怎么没有可能', '怎么没有可能', n
    ow(), 0);
    Query OK, 1 row affected, 2 warnings (0.00 sec)mysql> insert into article values (null, 6, 1, '可能性是很大的', '可能性是很大的
    ', now(), 0);
    Query OK, 1 row affected, 2 warnings (0.00 sec)mysql> insert into article values (null, 2, 1, '大象进医院了', '大象进医院了', n
    ow(), 1);
    Query OK, 1 row affected, 2 warnings (0.00 sec)mysql> insert into article values (null, 9, 1, '护士是蚂蚁', '护士是蚂蚁', now()
    , 0);
    Query OK, 1 row affected, 2 warnings (0.01 sec)mysql>
      

  4.   


    顶   这里应该不会与字符集有关  ,如果不更改默认字符集  ,默认的是 好像 UTF8(5.xx 以前 默认字符集是 latin1) , 你可以show  character set  查一下默认字符集 。另外  utf8  的一个中文占得3个字节 ,你可以写一个脚本测一下
      

  5.   

    我在my.ini文件里面加了# default-character-set=gbk,重启了Mysql,还是不行
      

  6.   

    Data too long for column 'title' at row 1 很明显  数据太长 varchar(5000)看看