mysql에서 Text가 key가 되어야 할 경우 그에 대한 hash값을 사용하면 fixed_length로 key를 지정할 수 있다.
아래는 mysql의 암호화와 압축 관련함수 페이지이다.
http://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html
MD5() |
Calculate MD5 checksum |
OLD_PASSWORD() |
Return the value of the pre-4.1 implementation of PASSWORD |
PASSWORD() |
Calculate and return a password string |
SHA1() , SHA() |
Calculate an SHA-1 160-bit checksum |
SHA2() |
Calculate an SHA-2 checksum |
< 사용법 >
Calculates an MD5 128-bit checksum for the string. The value is returned as a string of 32 hex digits, or NULL
if the argument was NULL
. The return value can, for example, be used as a hash key. See the notes at the beginning of this section about storing hash values efficiently.
As of MySQL 5.5.3, the return value is a nonbinary string in the connection character set. Before 5.5.3, the return value is a binary string; see the notes at the beginning of this section about using the value as a nonbinary string.
mysql> SELECT MD5('testing');
-> 'ae2b1fca515949e5d54fb22b8ed95575'
This is the “RSA Data Security, Inc. MD5 Message-Digest Algorithm.”
See the note regarding the MD5 algorithm at the beginning this section.
그람 저렇게 긴게 다 필요하냐?
아니라면
필요한 부분만 잘라서 쓰면 된다. 왼쪽 10개 byte만 사용
mysql test -uroot -ptellme -e "select left(md5('asdf'),10)"
+----------------------+
| left(md5('asdf'),10) |
+----------------------+
| 912ec803b2 |
+----------------------+
허허허
'DB > Mysql' 카테고리의 다른 글
Mysql timestamp update null value, mysql에서 timestamp 컬럼에 null을 update할때 (0) | 2011.08.30 |
---|---|
Mysql 서브쿼리 사용법 페이지 (0) | 2011.07.01 |
Mysql index에 대해서 (0) | 2011.06.23 |
mysql insert 속도에 대하여 (Speed of INSERT Statements) (0) | 2011.04.19 |
mysql query browser (0) | 2011.03.10 |