±±´óÇàÄñoracleѧϰ±Ê¼Ç13
ǶÌ×±í£º
Óë¿É±äÊý×éÀàËÆ£¬²»Í¬Ö®´¦ÊÇǶÌ×±íûÓÐÊý¾ÝÉÏÏÞ¡£
Óï·¨£º
´´½¨»ùÀàÐÍ
create or replace type ǶÌ×±í»ùÀàÐÍÃû as object(×ֶβÎÊý);
create or replace type mingxitype as object(
goodsid varchar(15),
incount int,
providerid varchar(10)
)not final;
´´½¨Ç¶Ì×±íÀàÐÍ
create or replace type ǶÌ×±íÀàÐÍÃû as table of ÀàÐÍÃû;
create or replace type nestmingxitype as table of mingxitype;
´´½¨±í
create table Ö÷±íÃû(
×Ö¶Î1 ÀàÐÍ,
×Ö¶Î2 ÀàÐÍ,
...
×Ö¶În ÀàÐÍ,
ǶÌ×ÀàÐÍ×ֶΠǶÌ×±íÀàÐÍÃû
)nested table ǶÌ×ÀàÐÍ×Ö¶ÎÃû store as ÕæÕý´æ´¢µÄǶÌ×±í;
create table instock
(
orderid varchar(13) not null primary key,
indate date,
mingxi nestmingxitype
)nested table mingxi store as mingxitable;
ÕâÀïÎÒÏë·ÃÎÊʵ¼Ê´æ´¢µÄ±ímingxitable£¬½á¹ûoracle±¨´íÈçÏ£º
cannot reference nested table column's storage table
¿´À´Ïë¿´¿´ÊDz»ÐÐÁË
Ìí¼ÓÊý¾Ý£º
insert into Ö÷±íÃû [(×Ö¶ÎÁбí)] values(
»ù±¾²ÎÊýÁбí,
ǶÌ×±íÀàÐÍÃû(ǶÌ×±í»ùÀàÐÍÃû(²ÎÊýÁбí))
);
insert into instock values(
'200200060001',
to_date('2002-08-06','yyyy-mm-dd'),
nestmingxitype(
mingxitype('j001',200,'1001'),
mingxitype('s001',1000,'1002'),
mingxitype('t005',500,'1003')
)
);
¸üÐÂǶÌ×±íÊý¾Ý£º
¸üÐÂǶÌ×±íʱ²¢²»ÓÃÏñ¸üпɱäÊý×éÒ»Ñù¸üÐÂÈ«²¿Êý¾Ý£¬¿ÉÒÔ¸üÐÂÖÆ¶¨Êý¾Ý¡£
update table(select t.mingxi from instock t where orderid = 1002) mx
set mx.incount = 500
where mx.goodid='10001';
²éѯǶÌ×±íÖÐÊý¾Ý£º
select * from table(select p.mingxi from instock where orderid = '200200060001');
ɾ³ýǶÌ×±íÊý¾Ý£º
delete from table(select t.mingxi from instock t where orderid = '200200060001') t
where t.goodsid='j0001';
×ÜÖ®£¬Ê¹ÓÃtable()º¯Êý½«Ç¶Ì×±í¿´×÷Ò»ÕÅÆÕͨµÄ±í£¬²Ù×÷ʱºò½«º¯ÊýǶÌ×µ½sqlÓï¾äÖм´¿É¡£
¶ÔÏó±í£º
±íÖÐÿһÐж¼´ú±íÒ»¸ö¶ÔÏó
°üº¬¶ÔÏó±êʶ·û OID
REF²Ù×÷·ûÓÃÓÚÒýÓÃÐжÔÏó
DEREF²Ù×÷·ûÓû§·µ»ØÐжÔÏóµÄÖµ
Àý£º
´´½¨¿ÆÊÒÀàÐÍ
create or replace type officetype as object(
id varchar(10),
typename varchar(10)
);
ͨ¹ý¿ÆÊÒÀàÐÍ´´½¨¿ÆÊÒ±í
create table offic of officetype;
²
Ïà¹ØÎĵµ£º
Ëø
²éѯÆäËûÓû§µÄ±í <Óû§Ãû.±íÃû>
Ëø¶¨Ä£Ê½£º
Ðм¶Ëø
Ðб»ÅÅËûÐÔËø¶¨
ÔÚijÐеÄËø±»ÊÍ·Å֮ǰ£¬ÆäËûÓû§²»ÄÜÐ޸ĴËÐÐ
ʹÓÃcommit rollbackÃüÁîÊÍ·ÅËø
»ñÈ¡Ðм¶Ëø
ʹÓÃinsert¡¢updateÓï¾ä£¬×Ô¶¯ÉÏÐм¶Ëø
ʹÓÃselect...for update [of ÁÐÃû] Óï¾ä×Ô¶¯»ñÈ¡Ðм¶Ëø
ÔÚ±íµÄÒ»Ðлò¶àÐзÅÖÃÅÅËûËø£¬ÓÃÓÚ·ÀÖÎÆäË ......
±í·ÖÇøÎ¬»¤£º
Ìí¼Ó·ÖÇø£º
Alter table student add partition ·ÖÇøÃû values less than(100);
ɾ³ý·ÖÇø£º
Alter table student drop partition ·ÖÇøÃû;
½Ø¶Ì·ÖÇø£º
Alter table student truncate partition ·ÖÇøÃû;
ºÏ²¢·ÖÇø£º
Alter table student merge partitions ·ÖÇøÃû,...,·ÖÇøÃû into partition зÖÇøÃû; ......
¡í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 ......
SQLServerºÍOracleÊÇ´ó¼Ò¾³£Óõ½µÄÊý¾Ý¿â£¬ÔÚ´Ë×ܽá³öÕâЩ³£Óú¯ÊýÒÔ¹©
´ó¼Ò²Î¿¼¡£
Êýѧº¯Êý
¡¡¡¡1.¾ø¶ÔÖµ
¡¡¡¡S:select abs(-1) value
¡¡¡¡O:select abs(-1) value from dual
¡¡¡¡2.È¡Õû(´ó)
¡¡¡¡S:select ceiling(-1.001) value
¡¡¡¡O:select ceil(-1.001) value from dual
¡¡¡¡3.È¡Õû£¨Ð¡£©
¡¡¡¡S:s ......
ORACLEÊý¾Ý¿â²åÈëÐÔÄܲâÊÔ
MKing
2010-3-8
²âÊÔ»·¾³»ù±¾ÐÅÏ¢£º
OS£ºWindows XP sp3
DB£ºOracle 9.2.0.1 δÆôÓù鵵
DBÖØ×öÈÕÖ¾Îļþ´óС£º100MB
Ó²ÅÌÐͺţºSAMSUNG HD161GJ£¨SATA-300,160G,7200rpm,8M cache£©
CPU£ºIntel Core2 E8400£¨3.0G£©
Äڴ棺2G
ͨ¹ýHD TuneµÃµ½µÄÓ²ÅÌ»ù±¾²âÊÔÐÅÏ ......