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

×ÔÔö×ֶεÄSQLÓï¾ä½â¾ö·½°¸

create table [±íÃû]
(
[×Ô¶¯±àºÅ×Ö¶Î] int IDENTITY (1,1) PRIMARY KEY ,
[×Ö¶Î1] nVarChar(50) default 'ĬÈÏÖµ' null ,
[×Ö¶Î2] ntext null ,
[×Ö¶Î3] datetime,
[×Ö¶Î4] money null ,
[×Ö¶Î5] int default 0,
[×Ö¶Î6] Decimal (12,4) default 0,
[×Ö¶Î7] image null ,
)
ɾ³ý±í£º
Drop table [±íÃû]
²åÈëÊý¾Ý£º
INSERT INTO [±íÃû] (×Ö¶Î1,×Ö¶Î2) VALUES (100,'51WINDOWS.NET')
ɾ³ýÊý¾Ý£º
DELETE from [±íÃû] WHERE [×Ö¶ÎÃû]>100
¸üÐÂÊý¾Ý£º
UPDATE [±íÃû] SET [×Ö¶Î1] = 200,[×Ö¶Î2] = '51WINDOWS.NET' WHERE [×Ö¶ÎÈý] = 'HAIWA'
ÐÂÔö×ֶΣº
ALTER TABLE [±íÃû] ADD [×Ö¶ÎÃû] NVARCHAR (50) NULL
ɾ³ý×ֶΣº
ALTER TABLE [±íÃû] DROP COLUMN [×Ö¶ÎÃû]
ÐÞ¸Ä×ֶΣº
ALTER TABLE [±íÃû] ALTER COLUMN [×Ö¶ÎÃû] NVARCHAR (50) NULL
ÖØÃüÃû±í£º(Access ÖØÃüÃû±í£¬Çë²Î¿¼ÎÄÕ£ºÔÚAccessÊý¾Ý¿âÖÐÖØÃüÃû±í)
sp_rename '±íÃû', 'бíÃû', 'OBJECT'
н¨Ô¼Êø£º
ALTER TABLE [±íÃû] ADD CONSTRAINT Ô¼ÊøÃû CHECK ([Ô¼Êø×Ö¶Î] <= '2000-1-1')
ɾ³ýÔ¼Êø£º
ALTER TABLE [±íÃû] DROP CONSTRAINT Ô¼ÊøÃû
н¨Ä¬ÈÏÖµ
ALTER TABLE [±íÃû] ADD CONSTRAINT ĬÈÏÖµÃû DEFAULT '51WINDOWS.NET' FOR [×Ö¶ÎÃû]
ɾ³ýĬÈÏÖµ
ALTER TABLE [±íÃû] DROP CONSTRAINT ĬÈÏÖµÃû
ɾ³ýSql Server ÖеÄÈÕÖ¾£¬¼õСÊý¾Ý¿âÎļþ´óС
dump transaction Êý¾Ý¿âÃû with no_log
backup log Êý¾Ý¿âÃû with no_log
dbcc shrinkdatabase(Êý¾Ý¿âÃû)
exec sp_dboption 'Êý¾Ý¿âÃû', 'autoshrink', 'true'
×ÔÔöÁв»ÄÜÖ±½ÓÐ޸ģ¬±ØÐ뽫ԭÓÐIDÁÐɾ³ý£¬È»ºóÖØÐÂÌí¼ÓÒ»ÁоßÓÐidentityÊôÐÔµÄID×ֶΣ¬Óï¾äÈçÏÂ
alter table ±íÃû
drop column ID
alter table ±íÃû
add ID int identity(1,1)
ÐÞ¸ÄÈÕÆÚ×Ö¶ÎΪDatatimeÀàÐÍ£¬Ê×ÏÈÒª±£Ö¤±íÖÐÎÞÊý¾Ý£¬»òÏÖÓÐÊý¾Ý¿ÉÒÔÖ±½Óת»»ÎªdatetimeÀàÐÍ£¬·ñÔòÐÞ¸Ä×Ö¶ÎÀàÐ;ͻáʧ°Ü¡£
alter table ±íÃû
alter column ÈÕÆÚ×Ö¶ÎÃû datetime
1, ʹÓÃÒ»¸öÊý¾Ý¿â֮ǰҪÒýÓÃËû£ºuse Êý¾Ý¿âÃû
2£¬ exists()ÅжÏ×Ó²éѯµÄ½á¹ûÊÇ·ñ´æÔÚ£¬·µ»Øtrue or false
3, object_id('¶ÔÏóÃû') ·µ»Ø¸Ã¶ÔÏóÃû¶ÔÓ¦µÄId,¸Ãid´æ´¢ÔÚsysobjects±íÖС£
4£¬ ½¨±íʱ×Ô¶¯½¨Á¢Ö÷¼üÔ¼Êø£ºcreate table a(b char(4),c int,constraint Ö÷¼üÃû primary key(c))
»òÕߣºcreate table a(a char(4) cin


Ïà¹ØÎĵµ£º

sql server2000´æ´¢¹ý³Ì·þÎñÆ÷

´æ´¢¹ý³Ì
ÔÚ´óÐÍÊý¾Ý¿âϵͳÖУ¬Ëæ׏¦ÄܵIJ»¶ÏÍêÉÆ£¬ÏµÍ³Ò²±äµÃÔ½À´Ô½¸´ÔÓ£¬´óÁ¿µÄʱ¼ä½«»áºÄ·ÑÔÚSQL´úÂëºÍÓ¦ÓóÌÐò´úÂëÉÏ£¬¿öÇÒÔںܶàÇé¿öÏ£¬Ðí¶à´úÂë±»Öظ´Ê¹Óöà´Î£¬Ã¿´Î¶¼ÊäÈëÏàͬµÄ´úÂë¼È·±ËöÓֻήµÍϵͳÔËÐÐЧÂÊ¡£Òò´Ë£¬SQL ServerÌṩÁËÒ»ÖÖ·½·¨£¬Ëü¿ÉÒÔ½«Ò»Ð©¹Ì¶¨µÄ²Ù×÷¼¯ÖÐÆðÀ´ÓÉSQL ServerÊý¾Ý¿â·þÎñÆ÷À´Íê³É£ ......

sql ÖÐ case when Óï·¨(ת)


sql
ÖÐ case when Óï·¨
sqlÓïÑÔÖÐÓÐûÓÐÀàËÆCÓïÑÔÖеÄswitch caseµÄÓï¾ä£¿£¿
 
ûÓÐ,ÓÃcase   when   À´´úÌæ¾ÍÐÐÁË.   
       
  ÀýÈç,ÏÂÃæµÄÓï¾äÏÔʾÖÐÎÄÄêÔ  
   
 
select   getdate()   as &n ......

³õѧPL/SQL Óαê

1,ÏÔʾÓαêµÄ²Ù×÷
  
(1) ¶¨ÒåÓαê
      ¸ù¾Ý²éѯµÄÊý¾ÝÇé¿ö£¬ÔÚPL/SQL¿éµÄÉùÃ÷²¿·Ö¶¨ÒåÓα꣬Ó﷨Ϊ£º
         cursor cursor_name is select_statement;
×¢Ò⣺
     Óαê±ØÐëÔÚPL/SQL¿éµÄÉùÃ÷²¿·Ö½øÐж¨Ò壻 ......

SQL ServerÖÐÁÙʱ±íÓë±í±äÁ¿µÄÇø±ð

ÎÒÃÇÔÚÊý¾Ý¿âÖÐʹÓñíµÄʱºò,¾­³£»áÓöµ½Á½ÖÖʹÓñíµÄ·½·¨,·Ö±ð¾ÍÊÇʹÓÃÁÙʱ±í¼°±í±äÁ¿¡£ÔÚʵ¼ÊʹÓõÄʱºò£¬ÎÒÃÇÈçºÎÁé»îµÄÔÚ´æ´¢¹ý³ÌÖÐÔËÓÃËüÃÇ£¬ËäÈ»ËüÃÇʵÏֵŦÄÜ»ù±¾ÉÏÊÇÒ»ÑùµÄ£¬¿ÉÈçºÎÔÚÒ»¸ö´æ´¢¹ý³ÌÖÐÓÐʱºòȥʹÓÃÁÙʱ±í¶ø²»Ê¹Óñí±äÁ¿£¬ÓÐʱºòȥʹÓñí±äÁ¿¶ø²»Ê¹ÓÃÁÙʱ±íÄØ?
¡¡¡¡ÁÙʱ±í
¡¡¡¡ÁÙʱ±íÓëÓÀ¾Ã±íÏàËÆ£ ......

SQL Server µÄÄ£Äâ

SQL Server µÄÄ£Äâ
רÀ¸×÷¼Ò£ºDeanna Dicken 2010Äê2ÔÂ12ÈÕ
·­Ò룺    UltraDBA      2010Äê5ÔÂ25ÈÕ
Ô­ÌûµØÖ·£ºhttp://www.databasejournal.com/features/mssql/article.php/3863516/SQL-Server-Impersonation.htm
½éÉÜ
SQL Server µÄÄ£Ä⣬»òÉÏÏÂÎÄÇл»£¬ÊÇÒ»ÖÖ·½Ê½£¬ÔÊÐíµ± ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ