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.我没有想明白这到底是什么原因,请大家指点
(
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.我没有想明白这到底是什么原因,请大家指点
解决方案 »
- C连接MySQL进行查询,多个结果符合的情况下,结果保存在哪里
- 想问关于传参数做表名的一点问题
- mysql按小时统计注册人数怎么弄,只有一个注册时间字段格式为('2010-06-10 20:39:18')
- 如果防止输出的结果中有重复的
- 继续求知-这样的数据库如何设计比较好
- 《sql必知必会》MySql导入数据脚本出错
- 事务与锁表的关系
- 请问 如何获得mysql的原码
- mysql 创建表出错
- MySQL Error: You have an error in your SQL syntax; check the manual that corresp
- 如何查看mysql的全部配置?
- 如何修改MYSQL加密方式
set names 'gbk'
然后再建库插入数据试试。
增加title列的长度.
另外建议创建数据库时指定字符集为utf8,这样在读取是就不需要set names来保证读取汉字不乱码
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>
顶 这里应该不会与字符集有关 ,如果不更改默认字符集 ,默认的是 好像 UTF8(5.xx 以前 默认字符集是 latin1) , 你可以show character set 查一下默认字符集 。另外 utf8 的一个中文占得3个字节 ,你可以写一个脚本测一下
。