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

SQLÓï¾ä´´½¨Êý¾Ý¿â

1.create database dataname
ÕâÊÇ´´½¨Êý¾Ý¿â×î¼òµ¥µÄ·½·¨£®Êý¾Ý¿âµÄ¸÷¸öÊôÐÔ¶¼ÊÇĬÈÏ£®ÈçÊý¾Ý¿âÎļþÓëÈÕÖ¾Îļþ´æ´¢Ä¿Â¼£®Êý¾Ý¿â´óСµÈ£®
ÏÂÃæ½éÉÜϳ£Óþö¶¨Êý¾Ý¿âÊôÐÔµÄ×Ӿ䣮
on:¼òµ¥Àí½âΪ¶¨Òå´æ´¢Êý¾Ý¿âÎļþµÄλÖ㬿´ÏÂÃæ´úÂ룮
filename:Êý¾Ý¿âµÄÂß¼­±ðÃû
size:Êý¾Ý¿â³õʼ´óС
maxsize:Êý¾Ý¿â³õ´óÈÝÁ¿
filegrowth:Êý¾Ý¿âÿ´ÎÔö¼ÓµÄÈÝÁ¿£®
log on:¼òµ¥Àí½âΪ¶¨Òå´æ´¢Êý¾Ý¿âÈÕÖ¾ÎļþµÄλÖã®
¿´´´½¨´úÂ룺
create database Accounting
on(name='AccountingName',
filename='F:\×ܽá\Sql\´´½¨ºÍÐÞ¸ÄÊý¾Ý±í\Accounting.mbdf',
size=10mb,
maxsize=50mb,
filegrowth=5mb)
log on(name='AccountingLog',
filename='F:\×ܽá\Sql\´´½¨ºÍÐÞ¸ÄÊý¾Ý±í\Accounting.log',
size=10mb,
maxsize=50mb,
filegrowth=5mb)
ÉÏÃæ˵µ½ÁË¡¡filegrowth:Êý¾Ý¿âÿ´ÎÔö¼ÓµÄÈÝÁ¿¡¡½áºÏ´úÂëÀ´Ëµ£®¾ÍÊdzõʼÊý¾Ý¿â´óСΪ10mb.µ±Êý¾Ý¿âÈÝÁ¿Òª³¬³öʱ£®Ëû»á×Ô¶¯Ôö¼Ó5mb£®Õâ»á¾ÍÊÇ15mb´óС£®×î´óµ½50mb
create database song on
(name=ktvdata,filename='D:\database\ktvdata.mdf',
size=8MB,maxsize=9MB,filegrowth=100KB)
log on
(name=ktvdata_log,filename='D:\database\ktvdata.ldf',
size=9MB,maxsize=10MB,filegrowth=100KB)
go
2. ʹÓÃALTER DATABASEÓï¾äÐÞ¸ÄÊý¾Ý¿â
Àý4-3¡¡½«Á½¸öÊý¾ÝÎļþºÍÒ»¸öÊÂÎñÈÕÖ¾ÎļþÌí¼Óµ½testÊý¾Ý¿âÖС£
³ÌÐòÇåµ¥ÈçÏ£º
ALTER DATABASE Test
ADD FILE
(NAME = Test1, FILENAME='c:\Program Files\Microsoft SQL Server\MSSQL\Data\test1.ndf', SIZE =
5MB, MAXSIZE = 100MB, FILEGROWTH = 5MB),
(NAME = Test2, FILENAME='c:\Program Files\Microsoft SQL Server\MSSQL\Data\test2.ndf', SIZE =
3MB, MAXSIZE = 10MB, FILEGROWTH = 1MB)
GO
ALTER DATABASE Test
 ADD LOG FILE ( NAME = testlog1, FILENAME='c:\Program Files\Microsoft SQL
Server\MSSQL\Data\testlog1.ldf',  SIZE = 5MB,  MAXSIZE = 100MB,  FILEGROWTH = 5MB)
GO
3¡¢ÖØÃüÃûtestΪdemo
  sp_renamedb 'test','demo'
4. ɾ³ýÊý¾Ý¿â£º drop database song
go


Ïà¹ØÎĵµ£º

sql overµÄ×÷Óü°Ó÷¨


RANK ( ) OVER ( [query_partition_clause] order_by_clause )
DENSE_RANK ( ) OVER ( [query_partition_clause] order_by_clause )
¿ÉʵÏÖ°´Ö¸¶¨µÄ×ֶηÖ×éÅÅÐò£¬¶ÔÓÚÏàͬ·Ö×é×ֶεĽá¹û¼¯½øÐÐÅÅÐò,
ÆäÖÐPARTITION BY Ϊ·Ö×é×ֶΣ¬ORDER BY Ö¸¶¨ÅÅÐò×Ö¶Î
over²»Äܵ¥¶ÀʹÓã¬ÒªºÍ·ÖÎöº¯Êý£ºrank(),dense_rank(),row_n ......

sql ³ÌÐòÓï¾ä


Transact-SQL
ÓïÑÔʹÓõÄÁ÷³Ì¿ØÖÆÃüÁîÓë³£¼ûµÄ³ÌÐòÉè¼ÆÓïÑÔÀàËÆÖ÷ÒªÓÐÒÔϼ¸ÖÖ¿ØÖÆÃüÁî¡£
4.6.1 IF…ELSE
ÆäÓï·¨ÈçÏ£º
IF <Ìõ¼þ±í´ïʽ>
<ÃüÁîÐлò³ÌÐò¿é>
[ELSE [Ìõ¼þ±í´ïʽ]
<ÃüÁîÐлò³ÌÐò¿é>]
ÆäÖÐ<Ìõ¼þ±í´ïʽ>¿ÉÒÔÊǸ÷ÖÖ±í´ïʽµÄ×éºÏ£¬µ«±í´ïʽµÄÖµ±ØÐëÊÇÂß¼­Öµ“Õæ&rdq ......

SQL Server´æ´¢¹ý³Ì½éÉÜ


ÕªÒª£º±¾ÎĽéÉÜÁËSQL Server´æ´¢¹ý³ÌÏà¶ÔÓÚÆäËûµÄÊý¾Ý¿â·ÃÎÊ·½·¨µÄÓŵ㼰SQL Server´æ´¢¹ý³ÌµÄ·ÖÀàµÈ¡£
SQL Server´æ´¢¹ý³ÌÊÇÒ»¸ö±»ÃüÃûµÄ´æ´¢ÔÚ·þÎñÆ÷ÉϵÄTransacation-SqlÓï¾ä¼¯ºÏ,ÊÇ·â×°Öظ´ÐÔ¹¤×÷µÄÒ»ÖÖ·½·¨,ËüÖ§³ÖÓû§ÉùÃ÷µÄ±äÁ¿¡¢Ìõ¼þÖ´ÐкÍÆäËûÇ¿´óµÄ±à³Ì¹¦ÄÜ¡£
SQL Server´æ´¢¹ý³ÌÏà¶ÔÓÚÆäËûµÄÊý¾Ý¿â·ÃÎÊ·½·¨Ó ......

SQL Server 2008ÐÐÊý¾ÝºÍÒ³Êý¾ÝѹËõ½âÃÜ

SQL ServerµÄÐÔÄÜÖ÷Ҫȡ¾öÓÚ´ÅÅÌI/OЧÂÊ£¬Ìá¸ßI/OЧÂÊijÖÖ³ÌÐòÉϾÍÒâζ×ÅÌá¸ßÐÔÄÜ¡£SQL Server 2008ÌṩÁËÊý¾ÝѹËõ¹¦ÄÜÀ´Ìá¸ß´ÅÅÌI/O¡£
Êý¾ÝѹËõÒâζ׿õСÊý¾ÝµÄÓдÅÅÌÕ¼ÓÃÁ¿£¬ËùÒÔÊý¾ÝѹËõ¿ÉÒÔÓÃÔÚ±í£¬¾Û¼¯Ë÷Òý£¬·Ç¾Û¼¯Ë÷Òý£¬ÊÓͼË÷Òý»òÊÇ·ÖÇø±í£¬·ÖÇøË÷ÒýÉÏ¡£
Êý¾ÝѹËõ¿ÉÒÔÔÚÁ½¸ö¼¶±ðÉÏʵÏÖ£ºÐ춱ðºÍÒ³¼¶±ð¡£Ò³¼¶±ðѹ ......

SQL SERVER 2000/2005 ÁÐתÐÐ ÐÐתÁÐ


ÆÕͨÐÐÁÐת»»
ÎÊÌ⣺¼ÙÉèÓÐÕÅѧÉú³É¼¨±í(tb)ÈçÏÂ:
ÐÕÃû ¿Î³Ì ·ÖÊý
ÕÅÈý ÓïÎÄ 74
ÕÅÈý Êýѧ 83
ÕÅÈý ÎïÀí 93
ÀîËÄ ÓïÎÄ 74
ÀîËÄ Êýѧ 84
ÀîËÄ ÎïÀí 94
Ïë±ä³É(µÃµ½ÈçϽá¹û)£º
ÐÕÃû ÓïÎÄ Êýѧ ÎïÀí
---- ---- ---- ----
ÀîËÄ 74 84 94
ÕÅÈý 74 83 93
-------------------
*/
create table tb(ÐÕÃû varc ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ