oracle merge into Ó÷¨Ïê½â
oracle merge into Ó÷¨Ïê½â
2009-07-31 10:14
Oracle9iÒýÈëÁËMERGEÃüÁî,ÄãÄܹ»ÔÚÒ»¸öSQLÓï¾äÖжÔÒ»¸ö±íͬʱִÐÐinsertsºÍupdates²Ù×÷. MERGEÃüÁî´ÓÒ»¸ö»ò¶à¸öÊý¾ÝÔ´ÖÐÑ¡ÔñÐÐÀ´updating»òinsertingµ½Ò»¸ö»ò¶à¸ö±í.
Oracle 10gÖÐMERGEÓÐÈçÏÂһЩ¸Ä½ø£º
1¡¢UPDATE»òINSERT×Ó¾äÊÇ¿ÉÑ¡µÄ
2¡¢UPDATEºÍINSERT×Ó¾ä¿ÉÒÔ¼ÓWHERE×Ó¾ä
3¡¢ONÌõ¼þÖÐʹÓó£Á¿¹ýÂËν´ÊÀ´insertËùÓеÄÐе½Ä¿±ê±íÖÐ,²»ÐèÒªÁ¬½ÓÔ´±íºÍÄ¿±ê±í
4¡¢UPDATE×Ó¾äºóÃæ¿ÉÒÔ¸úDELETE×Ó¾äÀ´È¥³ýһЩ²»ÐèÒªµÄÐÐ
Ê×ÏÈ´´½¨Ê¾Àý±í£º
create table PRODUCTS
(
PRODUCT_ID INTEGER,
PRODUCT_NAME VARCHAR2(60),
CATEGORY VARCHAR2(60)
);
insert into PRODUCTS values (1501, 'VIVITAR 35MM', 'ELECTRNCS');
insert into PRODUCTS values (1502, 'OLYMPUS IS50', 'ELECTRNCS');
insert into PRODUCTS values (1600, 'PLAY GYM', 'TOYS');
insert into PRODUCTS values (1601, 'LAMAZE', 'TOYS');
insert into PRODUCTS values (1666, 'HARRY POTTER', 'DVD');
commit;
create table NEWPRODUCTS
(
PRODUCT_ID INTEGER,
PRODUCT_NAME VARCHAR2(60),
CATEGORY VARCHAR2(60)
);
insert into NEWPRODUCTS values (1502, 'OLYMPUS CAMERA', 'ELECTRNCS');
insert into NEWPRODUCTS values (1601, 'LAMAZE', 'TOYS');
insert into NEWPRODUCTS values (1666, 'HARRY POTTER', 'TOYS');
insert into NEWPRODUCTS values (1700, 'WAIT INTERFACE', 'BOOKS');
commit;
1¡¢¿ÉÊ¡ÂÔµÄUPDATE»òINSERT×Ó¾ä
ÔÚOracle 9i, MERGEÓï¾äÒªÇóÄã±ØÐëͬʱָ¶¨INSERTºÍUPDATE×Ó¾ä.¶øÔÚOracle 10g, Äã¿ÉÒÔÊ¡ÂÔUPDATE»òINSERT×Ó¾äÖеÄÒ»¸ö. ÏÂÃæµÄÀý×Ó¸ù¾Ý±íNEWPRODUCTSµÄPRODUCT_ID×Ö¶ÎÊÇ·ñÆ¥ÅäÀ´updates±íPRODUCTSµÄÐÅÏ¢:
SQL> MERGE INTO products p
2 USING newproducts np
3 ON (p.product_id =
Ïà¹ØÎĵµ£º
¹ØÓÚ°²×°£º
°²×°Oracle10gʱ£¬ËùÊäÈëµÄÈ«¾ÖµÄSIDÃû³ÆΪtest(¼´Êý¾Ý¿âÃû£¬²»ÄÜ×÷ΪÓû§ÃûÀ´µÇ¼)£¬ÃÜÂëΪtest(¸ÃÃÜÂë¶ÔÓ¦µÄÓû§Îªsystem£¬sysµÈ)¡£
×°Íêºó£¬Èô´ÓÍøÒ³ÉϵǼoracle£¬ÔòÊäÈëurl£ºhttp://localhost:1158/em
ÈôÎÞ·¨ÏÔ ......
rom£ºhttp://www.psoug.org/reference/dbms_metadata.html
General Information
Source
{ORACLE_HOME}/rdbms/admin/dbmsmeta.sql
First Available
9.0.1
¼¸¸ö³£Óùý³Ì»òº¯Êý£º
GET_DDL
Fetch DDL for objects
dbms_metadata.get_ddl(
object_type IN VARCHAR2,
name IN VA ......
Author: rainnyzhong
Date:2010-1-15
1£® Ö¢×´ÃèÊö£º
FALB12´ÓEXCEL IMPORT DATAµ½DB£¬Ô¤¼ÆÊÂÎñ»áÔËÐÐ1¸ö¶àСʱ£¬ÔÚ¿ªÊ¼²Ù×÷ºó40·ÖÖÓ×óÓÒ£¬ORACLE¹ÒËÀ£¬ÈκÎÓû§¶¼²»¿ÉÒÔÔٵǽÁË¡£
2£® ·ÖÎö
£¨1£© ÏÂÃæÊǹÒËÀʱOSµÄ×ÊÔ´×´¿ö£º
09:37:54 up 73 ......
¹éµµÈÕÖ¾¼Ç¼×ÅÊý¾Ý¿âµÄ²Ù×÷¼Ç¼£¬ÊÇ×öÊý¾Ý»Ö¸´µÄÒÀ¾Ý£¬Èç¹ûÊý¾Ý¿â¿ªÆôÁ˹鵵ģʽ£¬ÄÇô¾Í»á²úÉú´óÁ¿µÄ¹éµµÈÕÖ¾£¬µ±È»Èç¹ûÓÐRMAN±¸·ÝµÄ»°£¬¿ÉÒÔÔÚ±¸·ÝÖ®ºóɾ³ýÒѾ±¸·Ý¹ýµÄÈÕÖ¾£¬Èç¹ûÊÇûÓвÉÓÃrman±¸·ÝµÄ»°£¬¾ÍÐèÒª×Ô¼ºÀ´É¾³ýÕâд¹éµµÈÕÖ¾¡£ ÏÂÃæµÄ¼¸¸ö½Å±¾¾Í¼õÇáÁËDBAµÄ¹¤×÷Á¿¡£
Linux ƽ̨:
0 2 * * * ......
select * from user_recyclebin where original_name like 'FINANCE_%' order by droptime desc;
FLASHBACK TABLE FINANCE_CASE_FEE_ITEM TO BEFORE DROP
¼´ËùÓÐdropµÄ±í¶¼ÔÚ user_recyclebin Õâ¸öoracle»ØÊÕÕ¾ÀïÃæµÄ£¬ÔÙͨ¹ýflashbackÃüÁԼ´¿É¡£
¿´ÁËÍøÉÏ»¹¿ÉÒÔͨ¹ýµ÷Õûoracleʱ¼ä £¬»Øµ½É¾³ýµÄÄ ......