易截截图软件、单文件、免安装、纯绿色、仅160KB

MySQL MyIsam 存储引擎索引长度限制测试记录

MySQL MyIsam 存储引擎在创建索引的时候,索引键长度是有一个较为严格的长度限制的,所有索引键最大长度总和不能超过1000,而且不是实际数据长度的总和,而是索引键字段定义长度的总和。下面做个简单的测试,记录一下。
root@sky:~# mysql -u sky -p -h127.0.0.1
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 44
Server version: 5.0.51a-log MySQL Community Server (GPL)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
sky@127.0.0.1 : (none) 05:23:08> use test;
Database changed
sky@127.0.0.1 : test 05:23:11>
sky@127.0.0.1 : test 05:23:12>
先创建一个MyIsam表,字符集选择latin1,三个字段均设置为varchar 255,:
sky@127.0.0.1 : test 05:23:12> create table test_ind
-> (a varchar(255),
-> b varchar(255),
-> c varchar(255)
-> ) engine=myisam charset=latin1;
Query OK, 0 rows affected (0.01 sec)
创建效果:
sky@127.0.0.1 : test 05:23:32> show create table test_ind\G
*************************** 1. row ***************************
Table: test_ind
Create Table: CREATE TABLE `test_ind` (
`a` varchar(255) default NULL,
`b` varchar(255) default NULL,
`c` varchar(255) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
三个字段联合索引(长度应该在1000以内)
sky@127.0.0.1 : test 05:23:41> create index test_a_b_c_ind on test_ind(a,b,c);
Query OK, 0 rows affected (0.01 sec)
Records: 0 Duplicates: 0 Warnings: 0
我们看到,创建成功了。
下面我们做一次字符集转换,将字符集转换成utf8
sky@127.0.0.1 : test 05:25:54> alter table test_ind convert to charset utf8;
ERROR 1071 (42000): Specified key was too long; max key length is 1000 bytes
sky@127.0.0.1 : test 05:26:24>
sky@127.0.0.1 : test 05:28:03> show create table test_ind\G
*************************** 1. row ***************************
Table: test_ind
Create Table: CREATE TABLE `test_ind` (
`a` varchar(255) default NULL,
`b` varchar(255) default NULL,
`c` varcha


相关文档:

MySQL: Connect MySQL GUI tools to WAMP 2.0

Connect MySQL GUI tools to WAMP 2.0 Posted by: Vladislav Sadykov () Date: January 24, 2009 09:31AM Hay, I have a problem with MySQL database. I have installed WAMP 2.0 server on my Windows machine and now I would like to connect it with MySQL GUI tools 5. The problem is that at the startup of ......

mysql报错

报错:
 /tmp/ccBBJEB8.o: In function `ping_sql':
pingsql.c:(.text+0x7c): undefined reference to `mysql_init'
pingsql.c:(.text+0xe1): undefined reference to `mysql_real_connect'
pingsql.c:(.text+0xff): undefined reference to `mysql_close'
pingsql.c:(.text+0x119): undefined reference to `mys ......

Linux下分析Mysql日志的好工具–mysqlsla


从http://hackmysql.com/mysqlsla下载mysqlsla,当前最新版为:2.03
tar zxvf mysqlsla-2.03.tar.gz
cp mysqlsla-2.03/bin/mysqlsla /usr/local/bin
如果提示“Can’t locate DBI.pm”,执行以下命令
yum install perl-DBI perl-DBD-MySQL -y
这时就可以使用mysqlsla了,用法如下
mysqlsla -lt slo ......

MySQL保留关键字

MySQL保留关键字
    create table option (oid integer not null auto_increment, oname varchar(255), oinf varchar(255), ovotes integer, oimage varchar(255), ovideo varchar(255), oaudio varchar(255), octime varchar(255), ocuname varchar(255), omtime varchar(255), omuname varchar(255 ......

使用MYSQL数据库插入图片时关于数据库字符集的错误

 在使用JDBC操作数据库 在向数据库中插入图片时,程序老是抛异常
原来的MYSQL字符集是GBK  但是这种字符集虽然支持中文 但是当插入图片等二进制数据时 会出现错误
解决方法:
将数据库字符集更改为gb2312或utf-8
1.在MYSQL DOS界面中输入  show  variables  like "%char%";
+---- ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号