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

SQL¹ØÓÚÁ½±í¹ØÁªµÄupdate

¹ØÓÚÁ½±í¹ØÁªµÄupdate£¬µ«Óï¾äÔõôд¶¼²»ÕýÈ·£¬ÀÏÊDZ¨´í£¬ÓÚÊÇÐľªÈâÌø£¨¾ÍŲ»Äܼ°Ê±Íê³É²Ù×÷£©È¥²éÁËһϣ¬NND£¬Ô­À´°ÑSQLд³ÉÁËÔÚSQL ServerÏÂÃæµÄÌØÓÐÐÎʽ£¬ÕâÖÖÓï·¨ÔÚOracleÏÂÃæÊÇÐв»Í¨µÄ£¬¼±Ã¦¸Ä»ØÀ´£¬¼°Ê±Íê³ÉÁËÈÎÎñ¡£Ë³±ãÒ²°Ñ²éµ½µÄSQLÌû³öÀ´£¬ÄÄÌìÔÙÍü¼ÇÁË£¬Ò²ºÃÔÚÕâÀïÕÒ»ØÀ´£º
   update customers a
   set    city_name=(select b.city_name from tmp_cust_city b where b.customer_id=a.customer_id)
   where  exists (select 1
                  from   tmp_cust_city b
                  where  b.customer_id=a.customer_id
                 )
   -- update ³¬¹ý2¸öÖµ
   update customers a 
   set    (city_name,customer_type)=(select b.city_name,b.customer_type
                                     from   tmp_cust_city b
                                     where  b.customer_id=a.customer_id)
   where  exists (select 1
                  from   tmp_cust_city b
                  where  b.customer_id=a.customer_id
                 )
-
×ÊÁÏÒýÓÃ:file:///F:/ѧϰÀà×ÊÁÏ/Ë÷µÏ×÷Ò


Ïà¹ØÎĵµ£º

SQLÓï¾ä¼áÐÐתºáÁеÄÒ»ÖÖ·½·¨

¿âλ  »õÎï±àºÅ ¿â´æÊý
1     0101     50
1     0102     60
1     0103     50
2     0101     90
2     0103     100
2     0111     30
3     0101     12 ......

µÚ2 ÕÂ SQL ÎÊÌâ

2.1 ±¾ÕÂÄ¿µÄ
ÔÚ±¾ÕÂÖоÍÔÚ HSQLDB Ö÷Ò³ÂÛ̳»òÓʼþÁбíÖжà´ÎÌá³öµÄÎÊÌâ½øÐнâ´ð£¬Èç¹ûÄã´òËãÔÚÓ¦
ÓóÌÐòÖÐʹÓÃHSQLDB µÄ»°£¬ÄãÓ¦¸ÃÔĶÁһϱ¾Õ¡£
2.2 ¶ÔSQL ±ê×¼µÄÖ§³Ö
1.8.0 °æ±¾µÄHSQLDB Ö§³ÖSQL92¡¢99 ºÍ2003 ±ê×¼¹æ¶¨µÄSQL ·½ÑÔ¡£ÕâÒâζ×ÅHSQLDB
ÖÐÖ§³ÖµÄ±ê×¼ÌØÐÔ£¨ÀýÈç×óÍâÁ¬½Ó£©µÄÓï·¨ÊÇÓɱê×¼Îı¾¹æ¶¨µÄ¡£Ðí¶ ......

PL/SQLµÄÊý¾ÝÀàÐͺͳ£Óú¯Êý

1£©PL/SQLÊý¾ÝÀàÐÍ
Ãû³Æ
ÀàÐÍ
˵Ã÷
NUMBER
Êý×ÖÐÍ
ÄÜ´æ·ÅÕûÊýÖµºÍʵÊýÖµ£¬²¢ÇÒ¿ÉÒÔ¶¨Ò徫¶ÈºÍÈ¡Öµ·¶Î§
BINARY_INTEGER
Êý×ÖÐÍ
¿É´æ´¢´ø·ûºÅÕûÊý£¬ÎªÕûÊý¼ÆËãÓÅ»¯ÐÔÄÜ
DEC
Êý×ÖÐÍ
NUMBERµÄ×ÓÀàÐÍ£¬Ð¡Êý
DOUBLE PRECISION
Êý×ÖÐÍ
NUMBERµÄ×ÓÀàÐÍ£¬¸ß¾«¶ÈʵÊý
INTEGER
Êý×ÖÐÍ
NUMBERµÄ×ÓÀàÐÍ£¬ÕûÊý
INT
Êý ......

¾«ÃîSQLÓï¾äѧϰ

SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ