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·½·¨Ò»Ñù
Ïà¹ØÎĵµ£º
µÚÒ»Ìõ£º
select * from where field in (1,2,3) ÕâÖÖд·¨Ó¦¸ÃÉáÆúÁË£¬¶øÓ¦¸ÃÕâÑùд£º
select * from table where field = 1 or field = 2 or field = 3
ΪʲôÄØ£¿
·²ÊÂÖ»ÓÐ×ö¹ý²ÅÖªµÀ£¬×Ô¼º½¨¸ö±í£¬²åÈë10WÌõ²âÊÔÊý¾Ý£¬ÓÃsql²âÊÔһϱãÖª£¬ÒòΪ¹¤×÷±ãÀû£¬ÎÒÔÚ²úÆ·»úºÍÍâÍø²âÊÔ»ú¶¼ÒѾ²âÊÔ¹ý£ ......
ÔÚÎÒÃÇÈÕ³£Ê¹ÓÃSQL ServerÊý¾Ý¿âʱ£¬¾³£Óöµ½ÐèÒªÔÚʵÀýInstance01ÖпçʵÀý·ÃÎÊInstance02ÖеÄÊý¾Ý¡£ÀýÈçÔÚ×öÊý¾ÝǨÒÆʱ£¬ÈçÏÂÓï¾ä:
insert into Instance01.DB01.dbo.Table01
select * from Instance02.DB01.dbo.Table01
ÆÕͨÇé¿öÏ£¬ÕâÑù×öÊDz»ÔÊÐíµÄ£¬ÒòΪSQ ......
»ùÓÚmsdn ÏêϸѧϰT-SQL (http://msdn.microsoft.com/zh-cn/library/bb510741.aspx)
Aggregate function--Sum() Two Sample from msdn
USE AdventureWorks;
GO
SELECT Color, SUM(ListPrice), SUM(StandardCost)
from Production.Product
WHERE Color IS NOT NULL
AND ListPrice != 0.00 ......
Five basic search conditions are summarized here:
1) Comparison test
2) Range test
3) Set membership test
4) Pattern matching test (Like)
The pattern matching test checks to see whether the data value in a column matches a specified pattern
% mathes any se ......