SQL 2005 CHECKÔ¼ÊøºÍ¹æÔòÇø±ð
Ò»¡¢Ô¼Êø
Ô¼Êø¶¨Òå¹ØÓÚÁÐÖÐÔÊÐíÖµµÄ¹æÔò£¬ÊÇÇ¿ÖÆÍêÕûÐԵıê×¼»úÖÆ¡£
ʹÓÃÔ¼ÊøÓÅÏÈÓÚʹÓô¥·¢Æ÷¡¢¹æÔòºÍĬÈÏÖµ¡£²éѯÓÅ»¯Æ÷ҲʹÓÃÔ¼Êø¶¨ÒåÉú³É¸ßÐÔÄܵIJéѯִÐмƻ®¡£SQL Server 2005Ö§³ÖÎåÀàÔ¼Êø£º
1. NOT NULLÖ¸¶¨²»½ÓÊÜNULLÖµµÄÁС£
2. CHECK Ô¼Êø¶Ô¿ÉÒÔ·ÅÈëÁÐÖеÄÖµ½øÐÐÏÞÖÆ£¬ÒÔÇ¿ÖÆÖ´ÐÐÓòµÄÍêÕûÐÔ¡£CHECKÔ¼Êø¾Ü¾øËùÓÐÔÚ¼ì²âÌõ¼þÖÐȡֵΪfalseµÄÖµ¡£¿ÉÒÔΪÿÁÐÖ¸¶¨¶à¸öCHECKÔ¼Êø¡£ÏÂÀýÏÔʾÃûΪchk_idÔ¼ÊøµÄ´´½¨£¬¸ÃÔ¼ÊøÈ·±£Ö»¶Ô´Ë¹Ø¼ü×ÖÊäÈëÖ¸¶¨·¶Î§ÄÚµÄÊý×Ö£¬ÒÔ½øÒ»²½Ç¿ÖÆÖ´ÐÐÖ÷¼üµÄÓò¡£
CREATE TABLE cust_sample
(
cust_id int PRIMARY KEY,
cust_name char(50),
cust_address char(50),
cust_credit_limit money,
CONSTRAINT chk_id CHECK(cust_id BETWEEN 0 and 10000)
)
3. UNIQUEÔ¼Êø£º¶ÔÓÚ UNIQUE Ô¼ÊøÖеÄÁУ¬±íÖв»ÔÊÐíÓÐÁ½Ðаüº¬ÏàͬµÄ·Ç¿ÕÖµ¡£Ö÷¼üҲǿÖÆÖ´ÐÐΨһÐÔ£¬µ«Ö÷¼ü²»ÔÊÐí¿ÕÖµ¡£UNIQUE Ô¼ÊøÓÅÏÈÓÚΨһË÷Òý¡£
4. PRIMARY KEY Ô¼Êø±êʶÁлòÁм¯£¬ÕâЩÁлòÁм¯µÄֵΨһ±êʶ±íÖеÄÐС£ÔÚÒ»¸ö±íÖУ¬²»ÄÜÓÐÁ½Ðаüº¬ÏàͬµÄÖ÷¼üÖµ¡£²»ÄÜÔÚÖ÷¼üÄÚµÄÈκÎÁÐÖÐÊäÈëNULLÖµ¡£ÔÚÊý¾Ý¿âÖÐNULLÊÇÌØÊâÖµ£¬´ú±í²»Í¬Óڿհ׺Í0ÖµµÄδֵ֪¡£½¨ÒéʹÓÃÒ»¸öСµÄÕûÊýÁÐ×÷ΪÖ÷¼ü¡£Ã¿¸ö±í¶¼Ó¦ÓÐÒ»¸öÖ÷¼ü¡£
Ò»¸ö±íÖпÉÒÔÓÐÒ»¸öÒÔÉϵÄÁÐ×éºÏ£¬ÕâЩ×éºÏÄÜΨһ±êʶ±íÖеÄÐУ¬Ã¿¸ö×éºÏ¾ÍÊÇÒ»¸öºòÑ¡¼ü¡£Êý¾Ý¿â¹ÜÀíÔ±´ÓºòÑ¡¼üÖÐÑ¡ÔñÒ»¸ö×÷ΪÖ÷¼ü¡£ÀýÈ磬ÔÚpart_sample±íÖУ¬part_nmbrºÍpart_name¶¼¿ÉÒÔÊǺòÑ¡¼ü£¬µ«ÊÇÖ»½«part_nmbrÑ¡×÷Ö÷¼ü¡£
CREATE TABLE part_sample
(
 
Ïà¹ØÎĵµ£º
<%
set conn= server.createobject("ADODB.connection")
conn.open "driver={sybase driver 10};"
"srvr=SYBASE;"
"UID=sa;"
"pwd=sybase;"
sql="select no from tab_st ......
¹¤¾ß£º
Sybase PowerDesigner 12.5
Microsoft SQL Server 2005
µÚÒ»²½£º¸ÅÒªÉè¼Æ
´ò¿ªPowerDesignerÈí¼þ£¬Éè¼Æ“¸ÅÄîÊý¾ÝÄ£ÐÍ”(Conceptual Data Model)£º
ͼ1
Éè¼Æ±í½á¹¹£º
ͼ2
ÔÚÉè¼ÆÊôÐÔ(×Ö¶Î)µÄʱºò£¬Èý¸ö×Öĸ(M¡¢P¡¢D)·Ö±ð±íʾ£º
M£ºÊÇ·ñΪ¿Õ;(√±íʾ²»ÔÊÐíΪ¿Õ)
P£ºÊÇ·ñ뻅 ......
×î½üÓöµ½Ò»¸öÏîÄ¿£¬¿Í»§ÔÚ×ܲ¿Â¼ÈëÐÅÏ¢ºó£¬Êý¾ÝÐèҪͬ²½µ½ÏÂÊôµÄÈô¸É¸ö×ÓϵͳÖС£ÏÖÔÚ×ܲ¿µ¥¶ÀʹÓÃÒ»¸öÊý¾Ý¿â£¬ÏÂÊôµ¥Î»¸÷×ÔʹÓÃ×Ô¼ºµÄÊý¾Ý¿â¡£
¶ÔÓÚÕâ¸öÎÊÌ⣬Ïëµ½Á˼¸¸ö½â¾ö·½°¸£º
1¡¢×Ô¼ºÐ´´úÂë½â¾ö¡£¶¨ÒåºÃ·ÃÎÊÿ¸öÊý¾ ......
Ò»¡¢»ù´¡
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 testBac ......