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

OM裡±£Áô記錄備·ÝSQL

 First:
create table gobo.gobo_om_reservations_2008b as
select * from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')<'2008'
delete from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')<'2008'
commit
After 2009Year:
create table gobo.gobo_om_reservations_????b as --????=to_char(sysdate-400,'yyyy')
select * from gobo.gobo_om_reservations_2008b
insert into gobo.gobo_om_reservations_????b
select * from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')<'????'
delete from gobo_om_reservations
where to_char(CREATION_DATE,'yyyy')<'????'
commit
ϵ統TABLE£ºmtl_reservations
µÄTRRIGERÈçÏ£º
--OTCµÄ訂單ÔÚOM發·Å¹¤單時£¬會×Ô動±£Áô¡£
--¼´°Ñ訂單與¹¤單聯ϵÆð來£¬¿É當訂單銷貨áᣬ
--»ò¹¤單Í깤áᣬ該關聯¼´Ïûʧ
--為Á˱£³Ö聯ϵ啟ÓÃ備·ÝµÄ·½·¨¡£
CREATE OR REPLACE TRIGGER gobo_om_reservations_in
after insert on mtl_reservations
for each row
begin
--舊µÄ·½Ê½備·Ýµ½gobo_om_reservations
insert into gobo_om_reservations
values( :new.SUPPLY_SOURCE_HEADER_ID,
:new.ORGANIZATION_ID,
:new.INVENTORY_ITEM_ID,
:new.DEMAND_SOURCE_TYPE_ID,
:new.DEMAND_SOURCE_HEADER_ID,
:new.DEMAND_SOURCE_LINE_ID,
:new.RESERVATION_QUANTITY,
:new.SUPPLY_SOURCE_TYPE_ID,
:new.CREATION_DATE,
:new.LAST_UPDATE_DATE );
--еķ½Ê½£¬°ÑWIP_JOD_ID寫µ½訂單LINE裡
--為ÁËÈËÁô舊ÉÏÃæµÄ·½Ê½£¬¹Ê²»È¡ÏûÉÏÃæµÄ·½·¨¡£
update oe_order_lines_all
set attribute19=:new.supply_source_header_id
where line_id= :new.demand_source_line_id
-- and header_id=:new.demand_source_header_id
and attribute19 is null;
end;


Ïà¹ØÎĵµ£º

ÀûÓÃSQLÓï¾ä½«Êý¾Ýµ¼³öInsertÓï¾ä

 ÓÐʱºò£¬ÔÚ¹¤×÷ÖлáÓöµ½½«Ò»¸öÊý¾Ý¿âÖбíµÄÊý¾Ýµ¼µ½ÁíÒ»¸öÊý¾Ý¿âµÄ±íÖУ¬µ«Êǹ¤¾ßÓÖûÓÐÌṩÕâÑùµÄ¹¦ÄÜ
ÏÂÃæÄÜͨ¹ýSQLÓï¾äÉú³ÉInsertÓï¾ä£¬ÔÙ²åÈëµ½ÁíÒ»¸öÊý¾Ý¿âÖС£
MSSQL:
SELECT 'INSERT INTO StatInfo(UserName,CardId,Address,WageCount,Pension)'+
' VALUES('''+a.UserName+''','''+a.CardId+''','''+a.Ad ......

SQLÖеÄDDL,DML,DCLÓïÑÔ

     ¸Ð¾õ×Ô¼ºÊDZȽϱ¿µÄ£¬Ñ§Ï°¹ýSQLÓïÑÔ£¬µ«ÊÇÈ´·Ö²»Ì«Çå³þDDL¡¢DML¡¢DCLÓïÑÔ£¬ËùÒÔÄØ£¬½ñÌì¾Íºñ×ÅÁ³Æ¤ÎÊÁËÀÏʦ£¬ÏÖÔÚ¾Í×Ô¼ºÄ¿Ç°µÄÁ˽âÀ´×ܽáһϡ£
1¡¢DDL£¨DATA DEFINITION LANGUAGE£©Êý¾ÝÃèÊöÓïÑÔ
     DDLÓï¾ä²»»á²úÉú»¹Ô­Êý¾Ý£¬ËùÒÔɾ³ýµÄÊý¾ÝÒ²ÊÇÎÞ·¨»Ö¸´µÄ
CREATE - to ......

sql server 2008 ·ÖÇø±íÎÊÌâ

    ¹«Ë¾Óиö±¨±íϵͳÏìÓ¦ËٶȲ»ÊǺÜÀíÏ룬µ÷Óŵ÷Á˺ü¸´Î£¬ÓеãЧ¹û£¬µ«²»ÊǺÜÈÃÈËÂúÒâ¡£×î½üÓÖ¿ªÊ¼µ÷ÓÅ£¬ÊÔÁËÊÔsql server 2008µÄ·ÖÇø±í¹¦ÄÜ£¬¿´¿´ÊDz»ÊÇ·ÖÇøÖ®ºóËٶȿÉÒÔ¿ìÒ»µã¡£
    ÓÃÁËÒ»¸ö°ÙÍò¼¶Êý¾ÝµÄ»ã×ܱíÀ´×ö·ÖÇø£¬·ÖÇøµÄÏë·¨ÊÇ°´ÔÂÀ´·ÖÇø£¬Ò»¸ö·ÖÇø´æ´¢Ò»¸öÔµÄÊý¾Ý£¬Ò»¸ö·ÖÇøµ ......

sqlÊý¾Ý¹ýÂË

 
Ò». ²éÕÒÖظ´¼Ç¼
1. ²éÕÒÈ«²¿Öظ´¼Ç¼
Select * from ±í Where Öظ´×ֶΠIn (Select Öظ´×Ö¶Î
from ±í Group By Öظ´×ֶΠHaving Count(*)>1)
2. ¹ýÂËÖظ´¼Ç¼(Ö»ÏÔʾһÌõ)
Select * from HZT Where ID In (Select Max(ID) from HZT Group By Title)
×¢£º´Ë´¦ÏÔʾID×î´óÒ»Ìõ¼Ç¼
¶þ. ɾ³ýÖظ´¼Ç ......

³£ÓÃSQLÓï¾äÊéд¼¼ÇÉ

 ×ª×Ô£ºhttp://jianghaifeng.blogchina.com/3841741.html
 SQL½á¹¹»¯²éѯ×Ö·û´®µÄ¸Äд£¬ÊÇʵÏÖÊý¾Ý¿â²éѯÐÔÄÜÌáÉýµÄ×îÏÖʵ¡¢×îÓÐЧµÄÊֶΣ¬ÓÐʱÉõÖÁÊÇΨһµÄÊֶΣ¬±ÈÈçÔÚ²»ÔÊÐí´ó·ù¶ÈÐÞ¸ÄÏÖÓÐÊý¾Ý¿â½á¹¹µÄÇé¿öÏ¡£
ͨ¹ýÓÅ»¯SQLÓï¾äÌá¸ß²éѯÐÔÄܵĹؼüÊÇ£º
 ¸ù¾Ýʵ¼ÊÐèÇóÇé¿ö£¬½¨Á¢ºÏÊʵÄË÷Òý£»
&# ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ