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

SQL´¥·¢Æ÷ʵÀý½²½â

SQL´¥·¢Æ÷ʵÀý½²½â
2008-10-31 21:06
SQL´¥·¢Æ÷ʵÀý1
¶¨Ò壺 ºÎΪ´¥·¢Æ÷£¿ÔÚSQL ServerÀïÃæÒ²¾ÍÊǶÔijһ¸ö±íµÄÒ»¶¨µÄ²Ù×÷£¬´¥·¢Ä³ÖÖÌõ¼þ£¬´Ó¶øÖ´ÐеÄÒ»¶Î³ÌÐò¡£´¥·¢Æ÷ÊÇÒ»¸öÌØÊâµÄ´æ´¢¹ý³Ì¡£
      ³£¼ûµÄ´¥·¢Æ÷ÓÐÈýÖÖ£º·Ö±ðÓ¦ÓÃÓÚInsert , Update , Delete ʼþ¡£
      ÎÒΪʲôҪʹÓô¥·¢Æ÷£¿±ÈÈ磬ÕâôÁ½¸ö±í£º
      Create Table Student(              --ѧÉú±í
        StudentID int primary key,       --ѧºÅ
        ....
       )
      Create Table BorrowRecord(               --ѧÉú½èÊé¼Ç¼±í
        BorrowRecord   int identity(1,1),       --Á÷Ë®ºÅ  
        StudentID      int ,                    --ѧºÅ
        BorrowDate     datetime,                --½è³öʱ¼ä
        ReturnDAte     Datetime,                --¹é»¹Ê±¼ä
        ...
      )
     Óõ½µÄ¹¦ÄÜÓÐ:
        1.Èç¹ûÎÒ¸ü¸ÄÁËѧÉúµÄѧºÅ,ÎÒÏ£ÍûËûµÄ½èÊé¼Ç¼ÈÔÈ»ÓëÕâ¸öѧÉúÏà¹Ø(Ò²¾ÍÊÇͬʱ¸ü¸Ä½èÊé¼Ç¼±íµÄѧºÅ);
        2.Èç¹û¸ÃѧÉúÒѾ­±ÏÒµ£¬ÎÒÏ£Íûɾ³ýËûµÄѧºÅµÄͬʱ£¬Ò²É¾³ýËüµÄ½èÊé¼Ç¼¡£
   &n


Ïà¹ØÎĵµ£º

javaÓësql server 2005µÄÏà¹Ø²Ù×÷

//±¾³ÌÐòÁ¬½ÓµÄÊÇsql server 2005£¬ÓëÁ¬½Ósql server 2000Óе㲻ͬ£ºdriverNameºÍURL¶¼²»Í¬
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class create{
   public void getConnection() th ......

Mysql µ¼Èë .sqlÎļþÖÐÎÄÂÒÂ룿

 --default-character-set=utf8 ÓëÐÞ¸ÄsqlÎļþ¼ÓÈ룺SET NAMES 'utf8'; 
µ¼Èë½Å±¾Ê±£¬SET NAMES 'xxx' £¬xxxÓ¦¸ÃºÍsql½Å±¾ÎļþµÄʵ¼Ê±àÂëÒ»Ö£¬Èç¹ûÄãÉèÖõÄʱutf-8 £¬ÄÇôÇëÈ·ÈÏÄãµÄsql½Å±¾Îļþʱutf-8±£´æµÄ:
iconv -f UTF-8 xxx.sql
Èç¹ûÏÔʾÕý³££¬ÄÇôÕâÒ»²½¾ÍOKÁË
ÁíÍâ×¢ÒâÄãµÄ½Å±¾ÀÓÐûÓиø¿â±íÉèÖ ......

caseÓï¾äÔÚSQLÖеÄʹÓ÷½·¨

Case¾ßÓÐÁ½ÖÖ¸ñʽ¡£¼òµ¥Caseº¯ÊýºÍCaseËÑË÷º¯Êý¡£
--¼òµ¥Caseº¯Êý
CASE sex
WHEN '1' THEN 'ÄÐ'
WHEN '2' THEN 'Å®'
ELSE 'ÆäËû' END
--CaseËÑË÷º¯Êý
CASE WHEN sex = '1' THEN 'ÄÐ'
WHEN sex = '2' THEN 'Å®'
ELSE 'ÆäËû' END
ÕâÁ½ÖÖ·½Ê½£¬¿ÉÒÔʵÏÖÏàͬµÄ¹¦ÄÜ¡£¼òµ¥Caseº¯ÊýµÄд·¨Ïà ......

ORACLE·ÖÒ³²éѯSQLÓï·¨


--1:ÎÞORDER BYÅÅÐòµÄд·¨¡£(ЧÂÊ×î¸ß) ­
--(¾­¹ý²âÊÔ£¬´Ë·½·¨³É±¾×îµÍ£¬Ö»Ç¶Ì×Ò»²ã£¬ËÙ¶È×î¿ì£¡¼´Ê¹²éѯµÄÊý¾ÝÁ¿ÔÙ´ó£¬Ò²¼¸ºõ²»ÊÜÓ°Ï죬ËÙ¶ÈÒÀÈ»£¡) ­
SELECT * ­
  from (Select ROWNUM AS ROWNO, T.* ­
           from k_task T &s ......

µ÷ÓÃSQL´æ´¢¹ý³Ì

±êÇ©£ºÊý¾Ý·ÃÎÊ     ADO.NET
    µ÷ÓÃSQL´æ´¢¹ý³Ì       ´æ´¢¹ý³ÌÔÚÒ»¸öµ¥ÔªÖзâ×°Á˸´ÔÓµÄSQL²éѯºÍÊý¾Ý¹ý³Ì£¬¿ÉÒÔÓɶà¸ö³ÌÐò»òÓû§Ö®¼äµ÷Óá£
    Àý£º
  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ