Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

¾­µäSQLÓï¾ä´óÈ«

Ò»¡¢»ù´¡
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 ÔËËã·ûͨ¹ý×éºÏÆäËûÁ½¸ö½á¹û±í£¨ÀýÈç TABLE1 ºÍ TABLE2£©²¢ÏûÈ¥±íÖÐÈκÎÖظ´ÐжøÅÉÉú³öÒ»¸ö½á¹û±í¡£µ± ALL Ëæ UNION Ò»ÆðʹÓÃʱ£¨¼´ UNION ALL£©£¬²»Ïû³ýÖظ´ÐС£Á½ÖÖÇé¿öÏ£¬ÅÉÉú±íµÄÿһÐв»ÊÇÀ´×Ô TABLE


Ïà¹ØÎĵµ£º

»ñµÃÊý¾Ý¿âÃû³Æ///////²éѯÊý¾Ý¿âÀïËùÓбíµÄsqlÓï¾ä£¡

select   name   as   ¿âÃû   from   master..sysdatabases   where   dbid>=7 »ñµÃÊý¾Ý¿âÃû³Æ
select * from sysobjects where xtype='u' or xtype='v' ²éѯÊý¾Ý¿âÀïËùÓбíµÄsqlÓï¾ä£¡
select name from sysobjects where type='u' ²éѯһ¸ö¿ ......

ʹÓÃvisio 2003½¨Á¢sql server·´Ïò¹¤³Ì

Èý²½×ß¡£
<1>½¨Á¢Êý¾ÝÔ´
´ò¿ª¿ØÖÆÃæ°å—>¹ÜÀí¹¤¾ß—>Êý¾ÝÔ´ (ODBC)£¬»òÖ±½ÓÔËÐÐodbccp32.cplÃüÁî¡£´ò¿ªODBCÊý¾ÝÔ´¹ÜÀíÆ÷¡£Ìí¼ÓÒ»¸öϵͳÊý¾ÝÔ´¡£Ñ¡ÔñSql Server×÷ΪÊý¾ÝÔ´µÄÇý¶¯³ÌÐò£¬¼üÈëÊý¾ÝÔ´Ãû³Ædemo£¬Ñ¡ÔñºÏÊʵÄsql server·þÎñÆ÷£¬È»ºóһ·ĬÈÏÏÂÈ¥¡££¨ÔÚºóÃæµÄ²½ÖèÖпÉÒÔÑ¡ÔñÐèÒª½øÐз´Ïò¹¤³Ì ......

PHPÁ¬½ÓSQL Server

ʹÓùýSQL ServerµÄÈËÓ¦¸Ã¶¼Çå³þ£¬SQL Server³£ÓõÄÓÐÁ½ÖÖÈÏÖ¤·½Ê½£¬Ò»ÖÖÊDZ¾µØϵͳÕË»§ÈÏÖ¤£¨Windows Authentication £©£¬Ò»ÖÖÊÇʹÓÃÓû§ÃûºÍÃÜÂ루SQL Server Authentication £©£¬µÚ¶þÖÖÈÏÖ¤·½Ê½±ØÐëÆôÓÃSQL ServerµÄ»ìºÏģʽ¡£
¡¡¡¡1.Windows AuthenticationÁ¬½Ó²¿·Ö´úÂë¶Î£º
<?php
$serverName = "(local)";
$co ......

·ÀÖ¹SQL×¢Èë¹¥»÷µÄ×¢ÒâÊÂÏî

·ÀÖ¹SQL×¢Èë¹¥»÷µÄ×¢ÒâÊÂÏî
Ò». SQL Injection¼°Æä·À·¶µÄ»ù±¾ÖªÊ¶
¿ÉÄÜ´ó¼Ò¶¼ÖªµÀ£¬SQL×¢ÈëÖ÷ÒªÊÇÀûÓÃ×Ö·ûÐͲÎÊýÊäÈëµÄ¼ì²é©¶´¡£
±ÈÈç˵£¬³ÌÐòÖÐÓÐÕâÑùµÄ²éѯ£º
 string sql = "SELECT * from SiteUsers WHERE UserName='" + userName + "'";
ÆäÖеÄuserName²ÎÊýÊÇ´ÓÓû§½çÃæÉÏÊäÈëµÄ¡£
Èç¹ûÊÇÕý³£µÄÊäÈ룬±ÈÈç ......

SQLÖлñµÃEXECºóÃæµÄsqlÓï¾ä»ò·µ»ØÖµµÄ·½·¨

SQLÖлñµÃEXECºóÃæµÄsqlÓï¾ä»ò·µ»ØÖµµÄ·½·¨
Ç°ÑÔ£ºÔÚÊý¾Ý¿â³ÌÐò¿ª·¢µÄ¹ý³ÌÖÐ,ÎÒ勱ÃǾ­³£»áÅöµ½Ñ§Ï°ÀûÓÃEXECÀ´Ö´ÐÐÒ»¶ÎÐèÒª·µ»ØijЩֵµÄsqlÓï¾ä£¨Í¨³£Êǹ¹Ô춯̬sqlÓï¾äʱʹÓã©£¬»òÕßÔÚÒ»¸öHTML´æ´¢¹ý³ÌÖÐÀûÓÃEXECµ÷ÓÃÁíÒ»¸öHTMLÓзµ»ØÖµµÄ´æ´¢¹ý³Ì£¨±ØÐë»ñµÃ·µ»ØÖµ£©£¬ÄÇôÈçºÎ»ñµÃÕâЩ·µ»ØÖµÄØ?
1.EXECÖ´ÐÐsqlÓï¾ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ