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

SQLÍâ¼ü

´´½¨Íâ¼üÔ¼Êø
CREATE TABLE order_sample
(
orderid int PRIMARY KEY,
cust_id int FOREIGN KEY REFERENCES cuts_sample(cust_id) ON DELETE NO CASCADE
)
ON DELETE--ÓÃÓÚ¿ØÖƳ¢ÊÔɾ³ýÍâ¼üÏà¹ØÁªµÄÖ÷±íÖ¸ÏòÐÐʱ²ÉÈ¡µÄ²Ù×÷
-NO ACTION
ɾ³ýÍâ¼üÏà¹ØÁªµÄÖ÷±íÖ¸ÏòÐÐʱ£¬±¨´í
-CASCADE
ɾ³ýÍâ¼üÏà¹ØÁªµÄÖ÷±íÖ¸ÏòÐÐʱ£¬Á¬´øÉ¾³ýÍâ¼üµÄËùÓÐÐÐ
-SET NULL
ɾ³ýÍâ¼üÏà¹ØÁªµÄÖ÷±íÖ¸ÏòÐÐʱ£¬°ÑÍâ¼üÁÐÉèΪ¿Õ
-SET DEFAULT
ɾ³ýÍâ¼üÏà¹ØÁªµÄÖ÷±íÖ¸ÏòÐÐʱ£¬°ÑÍâ¼üÁÐÉèΪĬÈÏÖµ
ɾ³ýÍâ¼üÔ¼Êø
ALTER TABLE order_sample
DROP CONSTRAINT [FK__order_sam__cust___0425A276]
Ìí¼ÓÍâ¼ü
ALTER TABLE order_sample
ADD CONSTRAINT [FK__order_sam__cust___0425A276] FOREIGN KEY(cust_id) REFERENCES cuts_sample(cust_id) ON DELETE  SET NULL 
ON UPADTE ÓÚON DELETE·½·¨Ò»Ñù


Ïà¹ØÎĵµ£º

MS SQL ServerºÍMySQLÇø±ð

      1 MySQLÖ§³Öenum,ºÍsetÀàÐÍ£¬SQL Server²»Ö§³Ö
¡¡¡¡2 MySQL²»Ö§³Önchar,nvarchar,ntextÀàÐÍ
¡¡¡¡3 MySQLµÄµÝÔöÓï¾äÊÇAUTO_INCREMENT£¬¶øMS SQLÊÇidentity(1,1)
¡¡¡¡4 MS SQLĬÈϵ½´¦±í´´½¨Óï¾äµÄĬÈÏÖµ±íʾÊÇ((0)),¶øÔÚMySQLÀïÃæÊDz»ÔÊÐí´øÁ½À¨ºÅµÄ
¡¡¡¡5 MySQLÐèҪΪ±íÖ¸¶¨´æ´¢ÀàÐÍ
¡ ......

SQLÊý¾ÝÖÐÔËÐÐcmdÃüÁî

ÔÚsql²éѯ·ÖÎöÆ÷ÀïÃæÊDz»ÄÜÖ±½ÓÔËÐÐcmdÃüÁîµÄ
µ«ÊÇSQL¸ø³öÁËÒ»¸ö½Ó¿Ú
--´ò¿ª¸ß¼¶ÉèÖÃ
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
--´ò¿ªxp_cmdshellÀ©Õ¹´æ´¢¹ý³Ì
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE
Ê×ÏÈ ´ò¿ªÒ»Ð©ÅäÖÃ
È»ºóÖ´ÐÐÄãÒªÔËÐÐcmdÃüÁî
exec master..xp_cmdshell 'net star ......

×î½üµÄÁ½ÌõsqlЧÂÊÓÅ»¯ÐĵÃ

µÚÒ»Ìõ£º
select * from where field in (1,2,3)   ÕâÖÖд·¨Ó¦¸ÃÉáÆúÁË£¬¶øÓ¦¸ÃÕâÑùд£º
select * from table where field = 1 or field = 2 or field = 3 
ÎªÊ²Ã´ÄØ£¿
·²ÊÂÖ»ÓÐ×ö¹ý²ÅÖªµÀ£¬×Ô¼º½¨¸ö±í£¬²åÈë10WÌõ²âÊÔÊý¾Ý£¬ÓÃsql²âÊÔһϱãÖª£¬ÒòΪ¹¤×÷±ãÀû£¬ÎÒÔÚ²úÆ·»úºÍÍâÍø²âÊÔ»ú¶¼ÒѾ­²âÊÔ¹ý£ ......

SQL Server DBA µÄ¹¤×÷Çåµ¥

ÓÐÐí¶à²»Í¬ÀàÐ͵ÄÊý¾Ý¿â¹ÜÀíÔ±¡£ һЩÀàÐ͵ÄÊý¾Ý¿â¹ÜÀíÔ±ÖÂÁ¦ÓÚÓÚ¿ª·¢ÁìÓò£¬¶øÆäËûµÄÒ»²¿·Ö¸üÖØÊÓÊý¾Ý¿âÐÔÄܵĵ÷ÕûÒÔ¼°ÈÔÈ»ÓÐÒ»²¿·ÖÊý¾Ý¿â¹ÜÀíÔ±ÔòÖÂÁ¦ÓÚ¹ÜÀíSQL ServerµÄÒµÎñ¡£ ÒÀ¾ÝÊý¾Ý¿â¹ÜÀíÔ±µÄ¹¤×÷»·¾³²»Í¬£¬ËûÃǽ«Ö´ÐÐÒ»¶¨ÊýÁ¿µÄ²»Í¬µÄÈÎÎñ¡£ÎªÁËÇø·ÖËùÓв»Í¬µÄÈÎÎñ£¬Êý¾Ý¿â¹ÜÀíÔ±¿ÉÄÜÒªÖ´ÐÐÎÒÇåµ¥ÉÏËùÁеÄÈÎÎñ¡£
¡¡ ......

ÔÚSQLÖÐÏò¶à¸öÊý¾Ý¿âÖвåÈëÏàͬµÄ¼Ç¼

½ñÌìÒ»¸öÅóÓÑÎʵ½Õâ¸öÎÊÌ⣬ÆäʵºÜºÃ½â¾ö£º
declare   @dbname   varchar(50)  
  declare   c_database   cursor   for  
      select   name   from   master.dbo.sysdatabas ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ