| CHAR | 固定長度 0 到 255 字 |
| VARCHAR | 變動長度 0 到 255 字 |
| TINYTEXT | 255 字 |
| TEXT,BLOB | 64Kib 字 |
| MEDIUMTEXT,MEDIUMBLOB | 16Mib 字 |
| LONGTEXT,LONGBLOB | 4Gib 字 |
| TINYINT | -128 to 127 或 0 to 255無符號 |
| SMALLINT | -32768 to 32767 或 0 to 65535無符號 |
| MEDIUMINT | -8388608 to 8388607 或 0 to 16777215無符號 |
| INT | -2147483648 to 2147483647 或 0 to 4294967295無符號 |
| BIGINT | -9223372036854775808 to 9223372036854775807 normal |
| FLOAT | A small number with a floating decimal point. |
| DOUBLE | A large number with a floating decimal point. |
| DECIMAL | A DOUBLE stored as a string , allowing for a fixed decimal point. |
| DATE | YYYY-MM-DD. |
| DATETIME | YYYY-MM-DD HH:MM:SS. |
| TIMESTAMP | YYYYMMDDHHMMSS. |
| TIME | HH:MM:SS. |
| ENUM | Short for ENUMERATION which means that each column may have one of a specified possible values. |
| SET | Similar to ENUM except each column may have more than one of the specified possible values. |
2011年3月5日 星期六
MySQL 資料型態的限制
MYSQL strip_tags
這是從MySQL官方上看到的資料,因為最近剛好有這個需求。
可以省下寫程式的時間,相當方便!!
可以省下寫程式的時間,相當方便!!
delimiter ||
DROP FUNCTION IF EXISTS strip_tags||
CREATE FUNCTION strip_tags( x longtext) RETURNS longtext
LANGUAGE SQL NOT DETERMINISTIC READS SQL DATA
BEGIN
DECLARE sstart INT UNSIGNED;
DECLARE ends INT UNSIGNED;
SET sstart = LOCATE('<', x, 1);
REPEAT
SET ends = LOCATE('>', x, sstart);
SET x = CONCAT(SUBSTRING( x, 1 ,sstart -1) ,SUBSTRING(x, ends +1 )) ;
SET sstart = LOCATE('<', x, 1);
UNTIL sstart < 1 END REPEAT;
return x;
END;
||
delimiter ;
訂閱:
意見 (Atom)