ÕÒЩ²»´íµÄsqlÃæÊÔÌâ(2)
ÎÊÌâÃèÊö£º
±¾ÌâÓõ½ÏÂÃæÈý¸ö¹Øϵ±í£º
CARD ½èÊ鿨¡£ CNO ¿¨ºÅ£¬NAME ÐÕÃû£¬CLASS °à¼¶
BOOKS ͼÊé¡£ BNO ÊéºÅ£¬BNAME ÊéÃû,AUTHOR ×÷Õߣ¬PRICE µ¥¼Û£¬QUANTITY ¿â´æ²áÊý
BORROW ½èÊé¼Ç¼¡£ CNO ½èÊ鿨ºÅ£¬BNO ÊéºÅ£¬RDATE »¹ÊéÈÕÆÚ
±¸×¢£ºÏÞ¶¨Ã¿ÈËÿÖÖÊéÖ»ÄܽèÒ»±¾£»¿â´æ²áÊýËæ½èÊé¡¢»¹Êé¶ø¸Ä±ä¡£
ÒªÇóʵÏÖÈçÏÂ15¸ö´¦Àí£º
1£® д³ö½¨Á¢BORROW±íµÄSQLÓï¾ä£¬ÒªÇó¶¨ÒåÖ÷ÂëÍêÕûÐÔÔ¼ÊøºÍÒýÓÃÍêÕûÐÔÔ¼Êø¡£
2£® ÕÒ³ö½èÊ鳬¹ý5±¾µÄ¶ÁÕß,Êä³ö½èÊ鿨ºÅ¼°Ëù½èͼÊé²áÊý¡£
3£® ²éѯ½èÔÄÁË"Ë®ä°"Ò»ÊéµÄ¶ÁÕߣ¬Êä³öÐÕÃû¼°°à¼¶¡£
4£® ²éѯ¹ýÆÚδ»¹Í¼Ê飬Êä³ö½èÔÄÕߣ¨¿¨ºÅ£©¡¢ÊéºÅ¼°»¹ÊéÈÕÆÚ¡£
5£® ²éѯÊéÃû°üÀ¨"ÍøÂç"¹Ø¼ü´ÊµÄͼÊ飬Êä³öÊéºÅ¡¢ÊéÃû¡¢×÷Õß¡£
6£® ²éѯÏÖÓÐͼÊéÖм۸ñ×î¸ßµÄͼÊ飬Êä³öÊéÃû¼°×÷Õß¡£
7£® ²éѯµ±Ç°½èÁË"¼ÆËã·½·¨"µ«Ã»Óнè"¼ÆËã·½·¨Ï°Ì⼯"µÄ¶ÁÕߣ¬Êä³öÆä½èÊ鿨ºÅ£¬²¢°´¿¨ºÅ½µÐòÅÅÐòÊä³ö¡£
8£® ½«"C01"°àͬѧËù½èͼÊéµÄ»¹ÆÚ¶¼ÑÓ³¤Ò»ÖÜ¡£
9£® ´ÓBOOKS±íÖÐɾ³ýµ±Ç°ÎÞÈ˽èÔĵÄͼÊé¼Ç¼¡£
10£®Èç¹û¾³£°´ÊéÃû²éѯͼÊéÐÅÏ¢£¬Ç뽨Á¢ºÏÊʵÄË÷Òý¡£
11£®ÔÚBORROW±íÉϽ¨Á¢Ò»¸ö´¥·¢Æ÷£¬Íê³ÉÈçϹ¦ÄÜ£ºÈç¹û¶ÁÕß½èÔĵÄÊéÃûÊÇ"Êý¾Ý¿â¼¼Êõ¼°Ó¦ÓÃ"£¬¾Í½«¸Ã¶ÁÕߵĽèÔļǼ±£´æÔÚBORROW_SAVE±íÖУ¨×¢ORROW_SAVE±í½á¹¹Í¬BORROW±í£©¡£
12£®½¨Á¢Ò»¸öÊÓͼ£¬ÏÔʾ"Á¦01"°àѧÉúµÄ½èÊéÐÅÏ¢£¨Ö»ÒªÇóÏÔʾÐÕÃûºÍÊéÃû£©¡£
13£®²éѯµ±Ç°Í¬Ê±½èÓÐ"¼ÆËã·½·¨"ºÍ"×éºÏÊýѧ"Á½±¾ÊéµÄ¶ÁÕߣ¬Êä³öÆä½èÊ鿨ºÅ£¬²¢°´¿¨ºÅÉýÐòÅÅÐòÊä³ö¡£
14£®¼Ù¶¨ÔÚ½¨BOOKS±íʱûÓж¨ÒåÖ÷Â룬д³öΪBOOKS±í×·¼Ó¶¨ÒåÖ÷ÂëµÄÓï¾ä¡£
15£®¶ÔCARD±í×öÈçÏÂÐ޸ģº
a. ½«NAME×î´óÁпíÔö¼Óµ½10¸ö×Ö·û£¨¼Ù¶¨ÔΪ6¸ö×Ö·û£©¡£
b. Ϊ¸Ã±íÔö¼Ó1ÁÐNAME£¨ÏµÃû£©£¬¿É±ä³¤£¬×î´ó20¸ö×Ö·û¡£
1. д³ö½¨Á¢BORROW±íµÄSQLÓï¾ä£¬ÒªÇó¶¨ÒåÖ÷ÂëÍêÕûÐÔÔ¼ÊøºÍÒýÓÃÍêÕûÐÔÔ¼Êø
--ʵÏÖ´úÂ룺
CREATE TABLE BORROW(
CNO int FOREIGN KEY REFERENCES CARD(CNO),
BNO int FOREIGN KEY REFERENCES BOOKS(BNO),
RDATE datetime,
PRIMARY KEY(CNO,BNO))
2. ÕÒ³ö½èÊ鳬¹ý5±
Ïà¹ØÎĵµ£º
ѧϰsqlµÄ±Ø¾ÎÊÌâ¡£
ѧÉú±ístudent (idѧºÅ SnameÐÕÃû SdeptËùÔÚϵ)
¿Î³Ì±íCourse (crscode¿Î³ÌºÅ name¿Î³ÌÃû)
ѧÉúÑ¡¿Î±ítranscript (studidѧºÅ &nbs ......
¡í1:È¡µÃµ±Ç°ÈÕÆÚÊDZ¾Ôµĵڼ¸ÖÜ
SQL> select to_char(sysdate,'YYYYMMDD W HH24:MI:SS') from
dual;
TO_CHAR(SYSDATE,'YY
-------------------
20030327 4 18:16:09
SQL> select to_char(sysdate,'W') from dual;
T
-
4 ......
SQL Server 2005 Express µ¼Èë/µ¼³öÊý¾Ý
°²×°ºÃSQL Server 2005 Expressºó£¬ÔÙ°²×°
http://download.microsoft.com/download/1/1/0/110d908f-c445-4523-b939-220c7d135f3d/SQLServer2005_SSMSEE.msi
¾Í¿ÉÒÔʹÓÿØÖÆ̨½øÐÐÊý¾Ý¿âµÄ¹ÜÀí¡£
µ«SQL Server Management Studio Express ²¢Ã»Óе¼Èë/µ¼³öÊý¾ÝµÄ¹¦ÄÜ£¬ÎÒÃÇ¿ÉÒÔ ......
SQLÓï¾ä¸´ÖƱíµÄ·½·¨
(2009-08-29 13:41:54)
±êÇ©£º
sql
·ÖÀࣺ¼ÆËã»ú֪ʶ
Èç¹ûÄ¿µÄ±íÒѾ´æÔÚ:
insert into DATAHR.DBO.GBITEM
select * from DEMO.DBO.GBITEM
Èç¹ûÄ¿µÄ±í²»´æÔÚ:
select * into DATAHR.DBO.GBITEM
from DEMO.DBO.GBITEM
¿ç¿âµ¼Èë
select * into [zk_news].[dbo].[News1] from [zk_media].[ ......
distinctÕâ¸ö¹Ø¼ü×ÖÓÃÀ´¹ýÂ˵ô¶àÓàµÄÖظ´¼Ç¼ֻ±£ÁôÒ»Ìõ£¬µ«ÍùÍùÖ»ÓÃËüÀ´·µ»Ø²»Öظ´¼Ç¼µÄÌõÊý£¬¶ø²»ÊÇÓÃËüÀ´·µ»Ø²»ÖؼǼµÄËùÓÐÖµ¡£ÆäÔÒòÊÇdistinctÖ»ÓÐÓöþÖØÑ»·²éѯÀ´½â¾ö£¬¶øÕâÑù¶ÔÓÚÒ»¸öÊý¾ÝÁ¿·Ç³£´óµÄÕ¾À´Ëµ£¬ÎÞÒÉÊÇ»áÖ±½ÓÓ°Ï쵽ЧÂʵġ£
ÏÂÃæÏÈÀ´¿´¿´Àý×Ó£º
table±í
×Ö¶Î1 ×Ö¶ ......