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 o
Ïà¹ØÎĵµ£º
ÔÎÄת×Ô:http://tech.it168.com/a2009/0218/265/000000265868.shtml
Ë÷ÒýÊÇÒÔ±íÁÐΪ»ù´¡µÄÊý¾Ý¿â¶ÔÏó¡£Ë÷ÒýÖб£´æ×űíÖÐÅÅÐòµÄË÷ÒýÁУ¬²¢ÇҼͼÁËË÷ÒýÁÐÔÚÊý¾Ý¿â±íÖеÄÎïÀí´æ´¢Î»Öã¬ÊµÏÖÁ˱íÖÐÊý¾ÝµÄÂß¼ÅÅÐò¡£Í¨¹ýË÷Òý£¬¿ÉÒÔ¼Ó¿ìÊý¾ÝµÄ²éѯËٶȺͼõÉÙϵͳµÄÏìӦʱ¼ä;¿ÉÒÔʹ±íºÍ±íÖ®¼äµÄÁ¬½ÓËٶȼӿ졣
µ«ÊÇ£¬ ......
·ÖÒ³sql²éѯÔÚ±à³ÌµÄÓ¦Óúܶ࣬Ö÷ÒªÓд洢¹ý³Ì·ÖÒ³ºÍsql·ÖÒ³Á½ÖÖ£¬ÎұȽÏϲ»¶ÓÃsql·ÖÒ³£¬Ö÷ÒªÊǺܷ½±ã¡£ÎªÁËÌá¸ß²éѯЧÂÊ£¬Ó¦ÔÚÅÅÐò×Ö¶ÎÉϼÓË÷Òý¡£sql·ÖÒ³²éѯµÄÔÀíºÜ¼òµ¥£¬±ÈÈçÄãÒª²é100ÌõÊý¾ÝÖеÄ30-40Ìõ£¬ÄãÏȲéѯ³öÇ°40Ìõ£¬ÔÙ°ÑÕâ30Ìõµ¹Ðò£¬ÔÙ²é³öÕâµ¹ÐòºóµÄÇ°Ê®Ìõ£¬×îºó°ÑÕâÊ®Ìõµ¹Ðò¾ÍÊÇÄãÏëÒªµÄ½á¹û¡£
  ......
ÈκÎÊÂÎñÎÞÂÛÆä¸ôÀ뼶±ðÈçºÎ£¬¶¼¾ßÓÐÔ×ÓÐÔ¡£Ô×ÓÐԺ͸ôÀ뼶±ðÊÇÁ½ÂëÊ¡£
¼Ù¶¨Ö»ÓÐÒ»ÖÖ×ÊÔ´Êý¾Ý±íÉϵēÐГ¿ÉÒÔ±»Ëø¶¨¡£ËøÖ»Óй²ÏíËøºÍÅÅËûËøÁ½ÖÖ¡£
ËøµÄ¼æÈÝÐÔ£º
SX
S 10
X 00
ÊÂÎñµÄ¸ôÀ뼶±ð£º
Read Uncommitted
Êý¾Ý¶Áȡʱ²»ÐèÒªËø¶¨
Read Committed
Êý¾Ý¶ÁȡʱÐèÒª¹²ÏíËø¶¨
Repeatable Re ......
¶ÔÓÚ½ñÌìµÄ RDBMS Ìåϵ½á¹¹¶øÑÔ£¬ËÀËøÄÑÒÔ±ÜÃâ — ÔÚ¸ßÈÝÁ¿µÄ OLTP »·¾³ÖиüÊǼ«ÎªÆձ顣ÕýÊÇÓÉÓÚ .NET µÄ¹«¹²ÓïÑÔÔËÐпâ (CLR) µÄ³öÏÖ£¬ SQL Server 2005 ²ÅµÃÒÔΪ¿ª·¢ÈËÔ±ÌṩһÖÖеĴíÎó´¦Àí·½·¨¡£ÔÚ±¾ÔÂרÀ¸ÖУ¬ Ron Talmage ΪÄú½éÉÜÈçºÎʹÓà TRY/CATCH Óï¾äÀ´½â¾öÒ»¸öËÀËøÎÊÌâ¡£
Ò»¸öʾÀýËÀËø
ÈÃÎÒÃÇ´ÓÕâÑùÒ ......
SQL Server 2005 ¾µÏñ¹¹½¨ÊÖ²á
Ò»¡¢ ¾µÏñ¼ò½é
1¡¢ ¼ò½é
Êý¾Ý¿â¾µÏñÊǽ«Êý¾Ý¿âÊÂÎñ´¦Àí´ÓÒ»¸öSQL ServerÊý¾Ý¿âÒƶ¯µ½²»Í¬SQL Server»·¾³ÖеÄÁíÒ»¸öSQL ServerÊý¾Ý¿âÖС£¾µÏñ²»ÄÜÖ±½Ó·ÃÎÊ;ËüÖ»ÓÃÔÚ´íÎó»Ö¸´µÄÇé¿öϲſÉÒÔ±»·ÃÎÊ¡£
Òª½øÐÐÊý¾Ý¿â¾µÏñËùÐèµÄ×îСÐèÇó°üÀ¨ÁËÁ½¸ö²»Í¬µÄSQL ServerÔËÐл·¾³¡£Ö÷·þÎñÆ÷± ......