Archive for August, 2009

MySQL Install

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db –user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe –user=mysql &

[译]MySQL的Set数据类型

原文地址:http://dev.mysql.com/tech-resources/articles/mysql-set-datatype.html

最近经常被使用的一个MySQL数据类型不得不算SET数据类型了,SET数据类型是一个String类型,但是由于其涉及复杂的增加,所以常常作为一个组合类型被提及到。在创建表的时候,一个SET类型可以存储指定的字符串的预定义列表中的任何数量的字符串。从SET数据类型与ENUM数据类型的预定义字符集工作方式来说,他们是相似的,但是ENUM数据类型限制你的预定义字符串集合中的一个成员,SET数据类型容许你存储多个预定义字符串,没有任何一个字符串,或者所有的字符串,都可以。

在MySQL的表里面,SET数据类型是作为一个Integer值被存储的。根据可利用元素的数量,SET数据类型将占用了0到8个字节。

MySQL的SET数据类型的要求

元素的个数 字节数
1 – 8 1
9 – 16 2
17 – 24 3
25 – 32 4
33 – 64 8

The SET elements are stored in the MySQL table as a bitmap: each element is represented by a single bit. To demonstrate this, lets look at the following sample table, which will be the basis for the rest of this tutorial. (NOTE: In the examples that follow, there are never whitespaces between elements and their comma seperators. Also note that only during the definition of a set are the elements individually wrapped in single quotes, otherwise the set as a whole gets only one set of quotes. Please do likewise.)

在MySQL的表里面,SET元素当作一个bitmap来存储的:每个元素都通过一个单一比特来代表。为了说明这个,让我们来看看下面的表。

单独增加主键和索引的SQL

ALTER TABLE user_relation_0 ADD INDEX `idx_user_relation` USING BTREE(`user_uuid_a`, `arefriends`);

ALTER TABLE user_relation_0 ADD CONSTRAINT  `pk_user_relation` PRIMARY KEY(`user_relation_uuid`);

使用Google的Ajax库API

使用这个的一个好处是使用了Google的CDN,这对于贫穷的站长来说,实在是太好了。

<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", "1.3.1");
google.load("jqueryui", "1.5.3");
</script>

同时在介绍一下Google的代码园地很不错的一个东西,有很多的Google开发的API可以使用。

Linux查看文件夹大小的命令

du -sm * | sort -n  //统计当前目录大小 并按大小排序

du -sh app //查看app文件夹大小

du app| wc -l //查看app文件夹有多少个文件

Eclipse中高亮

不知道为什么,Eclipse的编辑器的高亮不见了,很不方便啊。最后搜索找到一篇文章,介绍了怎么重新启动高亮。

其恢复方式如下:

选择:windows-> preferences->java->Editor->Mark Occurences

我是碰到过两次了,这次写个日志记录下吧。

参考文章:

http://blog.csdn.net/ccsuliuxing/archive/2007/04/16/1566583.aspx