¾µäMYSQLÓï¾ä
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(Create£¬Alter£¬Drop£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(Select£¬Delete£¬Update£¬Insert)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
Create DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨ ±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- ¿ªÊ¼ ±¸·Ý
BACKUP DATABASE pubs TO testBack
4¡¢ËµÃ÷£º´´½¨Ð±í
create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)
¸ù¾ÝÒÑÓÐµÄ±í´´½¨ÐÂ±í£º
A£ºcreate table tab_new like tab_old (ʹÓÃ¾É±í´´½¨Ð±í)
B£ºcreate table tab_new as select col1,col2… from tab_old definition only
5¡¢ËµÃ÷£ºÉ¾³ýбí
drop table tabname
6¡¢ËµÃ÷£ºÔö¼ÓÒ»¸öÁÐ
Alter table tabname add column col type
×¢£ºÁÐÔö¼Óºó½«²»ÄÜɾ³ý¡£DB2ÖÐÁмÓÉϺóÊý¾ÝÀàÐÍÒ²²»Äܸı䣬ΨһÄܸıäµÄÊÇÔö¼ÓvarcharÀàÐ͵ij¤¶È¡£
7¡¢ËµÃ÷£ºÌí¼ÓÖ÷¼ü£º Alter table tabname add primary key(col)
˵Ã÷£ºÉ¾³ýÖ÷¼ü£º Alter table tabname drop primary key(col)
8¡¢ËµÃ÷£º´´½¨Ë÷Òý£ºcreate [unique] index idxname on tabname(col….)
ɾ³ýË÷Òý£ºdrop index idxname
×¢£ºË÷ÒýÊDz»¿É¸ü¸ÄµÄ£¬Ïë¸ü¸Ä±ØÐëɾ³ýÖØн¨¡£
9¡¢ËµÃ÷£º´´½¨ÊÓͼ£ºcreate view viewname as select statement
ɾ³ýÊÓͼ£ºdrop view viewname
10¡¢ËµÃ÷£º¼¸¸ö¼òµ¥µÄ»ù±¾µÄsqlÓï¾ä
Ñ¡Ôñ£ºselect * from table1 where ·¶Î§
²åÈ룺insert into table1(field1,field2) values(value1,value2)
ɾ³ý£ºdelete from table1 where ·¶Î§
¸üУºupdate table1 set field1=value1 where ·¶Î§
²éÕÒ£ºselect * from table1 where field1 like ’%value1%’ ---likeµÄÓï·¨ºÜ¾«Ã²é×ÊÁÏ!
ÅÅÐò£ºselect * from table1 order by field1,field2 [desc]
×ÜÊý£ºselect count * as totalcount from table1
ÇóºÍ£ºselect sum(field1) as sumvalue from table1
ƽ¾ù£ºselect avg(field1) as avgvalue from table1
×î´ó£ºselect max(field1) as maxvalue from table1
×îС£ºselect min(field1) as minvalue from table1
11¡¢ËµÃ÷£º¼¸¸ö¸ß¼¶²éѯÔËËã´Ê
A£º UNION ÔËËã·û
UNION ÔËËã·
Ïà¹ØÎĵµ£º
»·¾³£ºCentOS linux 5.2
ϵͳֻ°²×°VI±à¼Æ÷Ó뿪·¢¹¤¾ß
ÔÚ±à¼MYSQLʱ£º
#./configure --prefix=/usr/local/mysql --with-charset=gb2312 --with-extra-charsets=all
Ö´Ðкó³öÏÖÈçÏ´íÎó£º
checking for tgetent in -ltermcap… no
checking for termcap functions library… config ......
×òÌìÓöµ½Ò»¸öÎÊÌâ:
ÔÚÒ»ÕÅÓÐÈýÊ®ÍòÌõ¼Í¼µÄÊý¾Ý±íA£¬ÆäÖ÷¼ü×ÔÔö×Ö¶Îid£¬name×ֶΣ¨varchar)£¬»¹ÓÐtype_id£¨int)£¬ÔÚname×Ö¶ÎÉÏÒѾÌí¼ÓÁËË÷Òý¡£type_idÓÉÓÚÊÇÕûÐÍ×ֶΣ¬ÈÏΪ¼ÓË÷ÒýûÓÐÌ«¶àµÄÒâÒ壬ËùÒÔûÓмÓË÷Òý¡£
±¾´ÎÓÐÒ»¸öÐèÇóÊÇÔÚÒ»¸öÑ»·Öа´type_id²éѯ´Ë±íA£¬½á¹ûÒ»Ö´ÐдËÑ»·£¬mySQLÁ¢¿ÌÕ¼ÓÃCPUµ½200%ÒÔÉÏ£¬µ¼ ......
Ò»¡¢mysql°²×°ÅäÖÃ
root@xmlinuxer-server:/media/WinF/LAMP#groupadd mysql
root@xmlinuxer-server:/media/WinF/LAMP#useradd -g mysql mysql
root@xmlinuxer-server:/media/WinF/LAMP#tar -zxvf mysql-5.0.33.tar.gz
root@xmlinuxer-server:/media/WinF/LAMP#cd mysql-5.0.33
root@xmlinuxer-server:/media/WinF/LAM ......
±¾Ê¾Àýͨ¹ý while...end while Ñ»·¿ØÖÆÓαêÀ´ÊµÏÖ²åÈë±í¼Ç¼¡£
DROP PROCEDURE IF exists pro_initCategoryForTradingEntity;
create procedure pro_initCategoryForTradingEntity(tradingEntityId int)
begin
declare f_parent,entityId int;
declare b int default 0; ......
unixODBC°²×°
Õ⼸ÌìÕæÊÇÓôÃÆËÀÁË£¬»ù±¾Ã¿Ì춼ÔÚ±àÒë°²×°QTºÍunixODBC£¬ÎÞÄÎ×Ü»á³öÏÖЩĪÃûÆäÃîµÄ´íÎó¡£Ê×ÏÈ£¬ÎÒ³ÐÈÏÎÒLinuxÍæµØ²»Ê죬µ«ÕâЩ¿ªÔ´Èí¼þ²úÉÌÖ®¼äµÄ¼æÈÝÐÔҲ̫²îÁË°É¡£ËùÒÔ»¹ÊÇÖƶ¨¸ö±ê×¼±È½ÏºÃ£¬´ó¼Ò¶¼×ñÊØÒ»¸öÔ¼¶¨¡£´ÓÕâ¸öÒâÒåÀ´Ëµ£¬Î¢ÈíµÄ¢¶Ï£¬»¹ÊÇÓÐÒ»¶¨µÄºÃ´¦µÄ¡£
......