Mysql×ÔÉíѧϰ
1.Êý¾Ý¿â³£ÓõÄ×Ö¶ÎÀàÐÍ£º
ÕûÊýÐÍ: TINYINT(0-255×Ö¶Î), SMALLINT(´óµã), INT(¸ü³¤), BIGINT;
СÊýÐÍ: FLOAT, BOUBLE, DECIMAL(M(ÕûÊý),D£¨Ð¡Êý£©);
×Ö·ûÐÍ: CHAR(¹Ì¶¨), VARCHAR(µ¯ÐÔ×Ö·ûÐÍ£¬¼õ»ºÈÝÁ¿);£¨××Ö·ûΪ255£©
ÈÕÆÚÐÍ: DATETIME£¨ÈÕÆÚʱ¼ä£©, DATE£¨ÈÕÆÚ£©, TIMESTAMP£¨ÈÕÆÚת»¯ÎªÊý×Ö.¾«¶È¸ü¸ß£©;
±¸×¢ÐÍ: TINYTEXT(´óÁ¿ÄÚÈÝ), TEXT, LONGTEXT;
2.´´½¨Ò»¸ö¼òµ¥Êý¾Ý¿â:
´´½¨Ò»¸öÊý¾Ý¿â: CREATE TABLE;
ɾ³ýÒ»¸öÊý¾Ý¿âÃüÁDROP TABLE;
ÐÞ¸ÄÒ»¸ö×Ö¶ÎÃû³Æ£ºRENAME TABLE `Ôʼ×Ö¶Î` TO `ÐÂ×Ö¶Î`;
ɾ³ýÒ»¸ö×ֶΣºALTER TABLE `±í` DROP `Ô×Ö¶Î`;
²åÈëÒ»¸ö×ֶΣºALTER TABLE `±í` ADD `ÐÂ×Ö¶Î`...AFTER `Ô×Ö¶Î`
CREAT TABLE `test`(
`id` int(10) NOT NULL auto_increment,
`uid` varchar(10) NOT NULL default '0',
`regdate` date NOT NULL,
`remark` text NULL,
PRIMARY KEY (`id`)
)
3.³£ÓÃÓï¾ä
SELECT ²éѯ×ֶΠfrom ±íÃ÷ WHERE Ìõ¼þ£»
²éѯ×Ö¶Î:¿ÉÒÔʹÓÃͨÅä·û*,×Ö¶ÎÃû£¬×ֶαðÃû£»
±íÃû£ºÊý¾Ý¿â.±íÃ÷,±íÃû
³£ÓÃÌõ¼þ£º=µÈÓÚ, <>²»µÈÓÚ, in°üº¬, not in ²»°üº¬, likeÆ¥ÅäbetweenÔÚ·¶Î§, not BETWEEN ²»ÔÚ·¶Î§, <, >
Ìõ¼þÔËË㣺and, or, £¨£©
4.ÅÅÐò£¬·Ö×飬ָÕë²éѯ£¬¼ÆËã
·Ö×éÓï¾ä£ºgroup by ×Ö¶Î;[Óï¾äorder֮ǰ]
ÅÅÐòÓï¾ä£ºorder by ×Ö¶Î,×Ö¶Îasc(µÍµ½¸ß)/desc(¸ßµ½µÍ);[×îºólimit֮ǰ]
Ö¸Õë²éѯ£ºlimit ³õʼֵ,½áÊøÖµ;[Óï¾ä×îºó]
¼ÆË㣺count()ͳ¼Æº¯Êý, max()×î´óÖµº¯Êý, min()×îСֵº¯Êý, avg()ƽ¾ùÖµº¯Êý, sum()ÀÛ¼ÆÖµº¯Êý;
5.insert²åÈëÓï¾ä
insert into ±íÃû(×Ö¶Î...,....)values(Öµ...,...)
insert into ±íÃû values(Öµ...,...)
6.update¸üÐÂÓï¾ä
update ±íÃûset ×ֶΠ= Öµ where Ìõ¼þ limit;(limit¿ÉÒÔÊ¡ÂÔ)
7.deleteɾ³ýÓï¾ä
delete from ±íÃû where Ìõ¼þ limit
PHPÓëMysql
1,php.ini¼ÓÔØMysql×é¼þ:
extension = php_mysql.dll Ç°ÃæµÄ;È¥µô£¨;ΪעÊÍ·ûºÅ£©
extension_dir = "" ·¾¶ÊÇ·ñÕýÈ·£¨×é¼þĿ¼ÊÇ·ñÕýÈ·£©
2.phpÁ¬½ÓMysqlº¯Êý
mysql_connect:¿ªÆômysqlÁ´½Ó;
mysql_select_db:´ò¿ªÒ»¸öÊý¾Ý¿â
@ºÍor dieÒþ²Ø´íÎóºÍÌõ¼þÏÔʾ
mysql_connect("Ö÷»ú","Óû§Ãû","ÃÜÂë");
mysql_select_db("´ò¿ªÊý¾Ý¿â",Á¬½Ó±êʶ·û);(Èç²»ÌرðÉùÃ÷Á¬½Ó±ê
1.Ç°ÃæһƪÎÄÕÂÏêϸ½éÉÜÁËÈçºÎÔÚWindowsÏÂÕûºÏapache+mysql+php+tomcat,ºÜ¼òµ¥£¬µ«ÊÇÔÚLinuxϾÍûÕâôÈÝÒ×ÁË£¬ÐèÒªÊÖ¹¤µÄȥдÅäÖÃÎļþ£¬ÍøÉϵÄ×ÊÁÏÓкܶ࣬µ«ÊÇÎÒ¸ù¾ÝËûÃǵÄд·¨£¬Ò»²½Ò»²½µÄÅäÖû¹ÊÇûÄÜsuccess!£¨¿ÉÄÜÊÇÎÒ¸öÈ˵ÄÔÒò£¬²»¹ý£¬ÎÞÂÛÔÚGoogle»¹ÊÇbaiduËѵ½µÄÎÄÕ¾ÍÄÇô¼¸Æª£¬Õâ¸öתһÏ£¬ÄǸöתһÏ£¬×îºó¶¼² ......