SQL Server Ë÷Òý»ù´¡ÖªÊ¶(4)
ÓÐЩÈË¿ÉÄܶÔÖ÷¼üºÍ¾Û¼¯Ë÷ÒýÓÐËù»ìÏý£¬ÆäʵÕâÁ½¸öÊDz»Í¬µÄ¸ÅÄÏÂÃæÊÇÒ»¸ö¼òµ¥µÄÃèÊö¡£²»Ïë¿´ÈÆ¿ÚÎÄ×ÖÕߣ¬Ö±½Ó¿´Á½ÕßµÄ¶Ô±È±í¡£ÓÈÆäÊÇ×îºóÒ»ÏîµÄ±È½Ï¡£
Ö÷¼ü£¨PRIMARY KEY £©
À´×ÔMSDNµÄÃèÊö£º
±íͨ³£¾ßÓаüº¬Î¨Ò»±êʶ±íÖÐÿһÐеÄÖµµÄÒ»ÁлòÒ»×éÁС£ÕâÑùµÄÒ»Áлò¶àÁгÆΪ±íµÄÖ÷¼ü (PK)£¬ÓÃÓÚÇ¿ÖƱíµÄʵÌåÍêÕûÐÔ¡£ÔÚ´´½¨»òÐ޸ıíʱ£¬Äú¿ÉÒÔͨ¹ý¶¨Òå PRIMARY KEY Ô¼ÊøÀ´´´½¨Ö÷¼ü¡£
Ò»¸ö±íÖ»ÄÜÓÐÒ»¸ö PRIMARY KEY Ô¼Êø£¬²¢ÇÒ PRIMARY KEY Ô¼ÊøÖеÄÁв»ÄܽÓÊÜ¿ÕÖµ¡£ÓÉÓÚ PRIMARY KEY Ô¼Êø¿É±£Ö¤Êý¾ÝµÄΨһÐÔ£¬Òò´Ë¾³£¶Ô±êʶÁж¨ÒåÕâÖÖÔ¼Êø¡£
Èç¹ûΪ±íÖ¸¶¨ÁË PRIMARY KEY Ô¼Êø£¬Ôò SQL Server 2005 Êý¾Ý¿âÒýÇæ ½«Í¨¹ýΪÖ÷¼üÁд´½¨Î¨Ò»Ë÷ÒýÀ´Ç¿ÖÆÊý¾ÝµÄΨһÐÔ¡£µ±ÔÚ²éѯÖÐʹÓÃÖ÷¼üʱ£¬´ËË÷Òý»¹¿ÉÓÃÀ´¶ÔÊý¾Ý½øÐпìËÙ·ÃÎÊ¡£Òò´Ë£¬ËùÑ¡µÄÖ÷¼ü±ØÐë×ñÊØ´´½¨Î¨Ò»Ë÷ÒýµÄ¹æÔò¡£
´´½¨Ö÷¼üʱ£¬Êý¾Ý¿âÒýÇæ »á×Ô¶¯´´½¨Î¨Ò»µÄË÷ÒýÀ´Ç¿ÖÆʵʩ PRIMARY KEY Ô¼ÊøµÄΨһÐÔÒªÇó¡£Èç¹û±íÖв»´æÔÚ¾Û¼¯Ë÷Òý»òδÏÔʽָ¶¨·Ç¾Û¼¯Ë÷Òý£¬Ôò½«´´½¨Î¨Ò»µÄ¾Û¼¯Ë÷ÒýÒÔÇ¿ÖÆʵʩ PRIMARY KEY Ô¼Êø¡£
¾Û¼¯Ë÷Òý
¾Û¼¯Ë÷Òý»ùÓÚÊý¾ÝÐеļüÖµÔÚ±íÄÚÅÅÐòºÍ´æ´¢ÕâЩÊý¾ÝÐС£Ã¿¸ö±íÖ»ÄÜÓÐÒ»¸ö¾Û¼¯Ë÷Òý£¬ÒòΪÊý¾ÝÐб¾ÉíÖ»ÄÜ°´Ò»¸ö˳Ðò´æ´¢¡£
ÿ¸ö±í¼¸ºõ¶¼¶ÔÁж¨Òå¾Û¼¯Ë÷ÒýÀ´ÊµÏÖÏÂÁй¦ÄÜ£º
¿ÉÓÃÓÚ¾³£Ê¹ÓõIJéѯ¡£
Ìṩ¸ß¶ÈΨһÐÔ¡£
Á½ÕߵıȽÏ
ÏÂÃæÊÇÒ»¸ö¼òµ¥µÄ±È½Ï±í
Ö÷¼ü
¾Û¼¯Ë÷Òý
ÓÃ;
Ç¿ÖƱíµÄʵÌåÍêÕûÐÔ
¶ÔÊý¾ÝÐеÄÅÅÐò£¬·½±ã²éѯÓÃ
Ò»¸ö±í¶àÉÙ¸ö
Ò»¸ö±í×î¶àÒ»¸öÖ÷¼ü
Ò»¸ö±í×î¶àÒ»¸ö¾Û¼¯Ë÷Òý
ÊÇ·ñÔÊÐí¶à¸ö×Ö¶ÎÀ´¶¨Òå
Ò»¸öÖ÷¼ü¿ÉÒÔ¶à¸ö×Ö¶ÎÀ´¶¨Òå
Ò»¸öË÷Òý¿ÉÒÔ¶à¸ö×Ö¶ÎÀ´¶¨Òå
ÊÇ·ñÔÊÐí null Êý¾ÝÐгöÏÖ
Èç¹ûÒª´´½¨µÄÊý¾ÝÁÐÖÐÊý¾Ý´æÔÚnull£¬ÎÞ·¨½¨Á¢Ö÷¼ü¡£
´´½¨±íʱָ¶¨µÄ PRIMARY KEY Ô¼ÊøÁÐÒþʽת»»Îª NOT NULL¡£
ûÓÐÏÞÖƽ¨Á¢¾Û¼¯Ë÷ÒýµÄÁÐÒ»¶¨±ØÐë not null .
Ò²¾ÍÊÇ¿ÉÒÔÁеÄÊý¾ÝÊÇ null
²Î¿´×îºóÒ»Ïî±È½Ï
ÊÇ·ñÒªÇóÊý¾Ý±ØÐëΨһ
ÒªÇóÊý¾Ý±ØÐëΨһ
Êý¾Ý¼´¿ÉÒÔΨһ£¬Ò²¿ÉÒÔ²»Î¨Ò»¡£¿´Ä㶨ÒåÕâ¸öË÷ÒýµÄ UNIQUE ÉèÖá£
£¨ÕâÒ»µãÐèÒª¿´ºóÃæµÄÒ»¸ö±È½Ï£¬ËäÈ»ÄãµÄÊý¾ÝÁпÉÄܲ»Î¨Ò»£¬µ«ÊÇϵͳ»áÌæÄã²úÉúÒ»¸öÄã¿´²»µ½µÄΨһÁУ©
´´½¨µÄÂß¼
Êý¾Ý¿âÔÚ´´½¨Ö÷¼üͬʱ£¬»á×Ô¶¯½¨Á¢Ò»¸öΨһË÷Òý¡£
Èç¹ûÕâ¸ö±í֮ǰûÓоۼ¯Ë÷Òý£¬Í¬Ê±½¨Á¢Ö÷¼üʱºòûÓÐÇ¿ÖÆÖ¸¶¨Ê¹Ó÷Ǿۼ¯Ë÷Òý£¬Ôò½¨Á¢Ö÷¼üʱºò£¬Í¬Ê±½¨
Ïà¹ØÎĵµ£º
index.jsp
<%@ page language="java" import="java.sql.*" import="java.lang.*" import="java.util.*" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%!
& ......
import java.sql.*;
/*
* JAVAÁ¬½ÓACCESS£¬SQL Server,MySQL,OracleÊý¾Ý¿â
*
* */
public class JDBC {
public static void main(String[] args)throws Exception {
Connection conn=null;
//====Á¬½ÓACCESSÊý¾Ý¿â ......
1. ²é¿´oracleÊý¾Ý¿â×Ö·û¼¯£º
select userenv('language') from dual;
2. ÇåÆÁ ÔÚOracle Sql/PlusÖÐ
clear scr;
clear screen;
3. ²éѯµ±Ç°Óû§Ï¶¼ÓÐÄÇЩ±í
select * from tab;
4.&n ......
(ËÄ)ÆäËûÊéÉÏûÓеÄË÷ÒýʹÓþÑé×ܽá
¡¡¡¡1¡¢ÓþۺÏË÷Òý±ÈÓò»ÊǾۺÏË÷ÒýµÄÖ÷¼üËٶȿì
¡¡¡¡ÏÂÃæÊÇʵÀýÓï¾ä£º(¶¼ÊÇÌáÈ¡25ÍòÌõÊý¾Ý)
¡¡¡¡select gid,fariqi,neibuyonghu,reader,title from Tgongwen
¡¡¡¡where fariqi='2004-9-16'
¡¡¡¡Ê¹ÓÃʱ¼ä£º3326ºÁÃë
¡¡¡¡select gid,fariqi,neibuyonghu,reader,title from Tgongwe ......
±í½á¹¹ÈçÏÂ:
id int 4
EntryID int 4
BlogID int 4
ÏÖÔÚÒªÇóÔÚ²åÈëʱ£¬²»ÔÊÐí²åÈëEntryIDÓëBlogID¶¼ÏàͬµÄ¼Ç¼£¬¼´±íÖв»ÔÊÐíÈÎÒâÁ½Ìõ¼Ç¼µÄEntryIDÓëBlogID¶¼Ïàͬ£¬EntryIDÓëBlogID¹¹³É¼Ç¼µÄΨһ±êʶ¡£
ÒÔÇ ......