More Related Content Similar to Itpub电子杂志(第二期) Similar to Itpub电子杂志(第二期) (20) Itpub电子杂志(第二期)1. ITPUB µç×Ó
ÔÓÖ¾
(µÚ¶þÆÚ
)
http://www.itpub.net
2000.2
2. ITPUB µç×ÓÔÓÖ¾ Ŀ¼
Ŀ¼
±¾ÆÚµ¼¶Á
Êý¾Ý¿â¹ÜÀí
ORACLE Êý¾Ý¿â¹éµµÄ£Ê½ÉèÖõķÖÎö˵Ã÷
Standby Êý¾Ý¿âµÄÇл»·½·¨
²»ÓÃÖؽ¨
ÇÉÓÃRman À´¹ÜÀíÂãÉ豸ÉϵÄÊý¾Ý¿â
Êý¾Ý¿â¿ª·¢
¿ª·¢ro*C/C++¶àÏß³ÌÓ¦Óõķ½·¨
P
½«²éѯ½á¹ûÁ¬½Ó³ÉÁбíµÄ¼¸¸ö·½·¨
¼¸¸ö³£Óýű¾
Developer2000 ϵÁн²×ù¶þ
ORACLE ÈÏÖ¤
Åàѵ£º Lesson 1-10
001
ÆóÒµÐÅÏ¢»¯
ÏîÄ¿¼Æ»®µÄ±àд
ÖÐÐ͹ÜÀíÈí¼þÊг¡µÄ¿Í»§Ìص㼰¹¦ÄÜÐèÇó
Cloning Oracle Applications,Release 11i
ÂÛ̳¾«»ª
ÖÆ×÷ÈËÔ±
HOME: http://www.itpub.net MAIL: epub@itpub.net
3. ITPUB µç×ÓÔÓÖ¾ ±¾ÆÚµ¼¶Á
±¾ÆÚµ¼¶Á
¹§ºØÐÂìû£¡ µç×ÓÔÓÖ¾ÂõÈëµÚ¶þÆÚÀ²¡«
ITPUB
webmaster@itpub.net ÁªÏµ£¬¶àл֧
±¾¿¯ËùÓÐÎÄÕ°æȨ¹é×÷ÕßËùÓУ¬ÈçÓÐתÔØ£¬ÇëÓë
³Ö£¬Ò»Æð±£»¤ÎÒÃǵÄÀͶ¯³É¹û¡£
±¾ÆÚÎÄÕÂÄÚÈݵ¼¶Á
Êý¾Ý¿â¹ÜÀí
ORACLE Êý¾Ý¿â¹éµµÄ£Ê½ÉèÖõķÖÎö˵Ã÷ ¡ïtigerking
ËäÈ»RACLE Êý¾Ý¿âµÄÈÕ־ģʽºÍ×Ô¶¯¹éµµÉèÖò¢²»¸´ÔÓ£¬µ«ÆäÖеÄ
O
ÄîºÍ²Ù×÷¹ý³Ì»¹ÊÇÈÝÒ×»ìÏýµÄ±¾ÎĽéÉÜÁË ORACLE Êý¾Ý¿â¹éµµÄ£Ê½µÄ¸ÅÄ×÷ÓÃ
ÒÔ¼°ÉèÖõIJÙ×÷¹ý³Ì¡£
²»ÓÃÖؽ¨ Standby Êý¾Ý¿âµÄÇл»·½·¨ ¡ïovertime
ÔÚ Oracle µÄÁª»úÎĵµÖУ¬ Êý¾Ý¿âÈç¹û±»¼¤»î£¨
Standby activate£©ºó£¬¾Í³ÉΪ
ÁË primary Êý¾Ý¿â£¬Ô-À´µÄ Êý¾Ý¿â±ØÐëÖؽ¨²ÅÄܳÉΪÐÂ
primary standby Êý¾Ý¿â¡£
Èç¹û primary Êý¾Ý¿âµÄ log ÔÚÇл»Ê±ÊÇ¿ÉÓõÄÇé¿öÏ£¬¿ÉÒÔʵÏÖ
redo primary µ½
standby Êý¾Ý¿âµÄÎÞ·ìÇл £ graceful switch£¡
»¨ ©£ÕâÑù¿ÉÒÔ²»ÓÃÖؽ¨Êý¾Ý¿â£¬
standby
¼õÇáÁËά»¤¹¤×÷Á¿¡£
ÇÉÓà Rman À´¹ÜÀíÂãÉ豸ÉϵÄÊý¾Ý¿â ¡ïchao_ping
±¾ÎĽéÉÜÒ»¸ö°ì·¨£¬¿ÉÒÔÓà Rman À´ÇáËɸ㶨ÂãÉ豸 /Îļþϵͳ֮¼äÊý¾ÝÎļþ
µÄǨÒÆ¡£ÔÚ´«Í³·½·¨ÀïÃ棬ÎÒÃDZØÐë¶ÔÓÚÿ¸ö Unix ²»Í¬µÄ ´óС£¬ ¾í¹Ü
Block OS
ÀíµÄ overhead µÄÖµ×÷¼ÆË㣬²ÅÄܷdz£Ð¡ÐĵÄÓà dd À´×öÕâЩ¿½±´ºÍÒƶ¯£¬µ«ÊÇÏÖ
ÔÚÔÚ Rman µÄ°ïÖúÏ£¬ÎÒÃÇ¿ÉÒÔÍêÈ«ºöÂÔÕâЩ²»Í¬µÄµØ·½£¬ÔÚËùÓÐ Unix ƽ̨
/NT
ƽ̨ÉÏÖ±½ÓÔÚ ÄÚ²¿ÊµÏÖÕâÖÖÊý¾ÝÎļþµÄתÒÆ¡£
Oracle
Êý¾Ý¿â¿ª·¢
¿ª·¢roC/C++¶àÏß³ÌÓ¦Óõķ½·¨
P ¡ïwangqis ÕûÀí£º jlandzpa
½éÉÜÁË¿ª·¢ Pro*C/C++¶àÏß³ÌÓ¦Óõķ½·¨¼°ÏêϸµÄ²½Öè¡£
½«²éѯ½á¹ûÁ¬½Ó³ÉÁбíµÄ¼¸¸ö·½·¨ ¡ï
oldwain
±¾ÎĽéÉÜÁ˶àÖÖÖÖ·½·¨À´ÊµÏÖ½«²éѯ½á¹ûÁ¬½Ó³ÉÁÐ±í¡£
¼¸¸ö³£Óýű¾¡ïsean ÕûÀí£ºjlandzpa
±¾ÎĽéÉÜÁËһЩÓÐÓõÄscript¡£
Developer2000 ϵÁн²×ù¶þ¡ïË÷ÂíÀï
±¾ÆÚ½«¸ø´ó¼Ò½²Êö°²×°ÎÊÌâºÍ Oracle Developer µÄ×é³É¡£
ORACLE ÈÏÖ¤
Åàѵ£º Lesson 1-10 ¡ï
001 easyfree
ÆóÒµÐÅÏ¢»¯
ÏîÄ¿¼Æ»®µÄ±àд κÖÎ
¡ïITPUB (W39)
¸æËßÄãÓ¦¸ÃÔõô±àд
ERP ÏîÄ¿¼Æ»®ÒÔ¼°ÊµÊ©¹ý³ÌÖÐӦעÒâµÄÊÂÏî¡£
ÖÐÐ͹ÜÀíÈí¼þÊг¡µÄ¿Í»§Ìص㼰¹¦ÄÜÐèÇó
¡ïÀî¼Ê
HOME: http://www.itpub.net MAIL: epub@itpub.net
4. ITPUB µç×ÓÔÓÖ¾ ±¾ÆÚµ¼¶Á
ÏÖÔÚ¹ÜÀíÈí¼þÅòÕÍ×î¿ìµÄÊг¡ÊÇÖÐСÐÍÊг¡¡
£µ«ÊÇ¿¼Âǵ½Ó¦ÓÃÐèÇóµÄ¸´ÔÓÐ
ÍêÕûÐÔ£¬ÆäʵÖÐÐÍÊг¡ÊÇ×î¾ßÓдú±íÐÔµÄÊг¡¡£±¾ÎÄ×ÅÖزûÊöÁËÖÐÐÍÊг¡µÄ¿Í
µã¼°¹¦ÄÜÐèÇó¡£
Cloning Oracle Applications, Release 11i ¡ï
Kevon zeng Òë
Oracle Applications ϵͳµÄ¿Ë¡ÊÇ Applications ÖØÒªµÄÒ»ÖÖ¼¼Êõ¡£ÓÐÁË
Oracle
Ëü£ÎÒÃÇÄܹ»Ñ¸ËÙ¶ÔÔ-ÓеÄÓ¦ÓÃϵͳ´Óһ̨»úÆ÷¸´ÖƵ½ÁíÍâһ̨»úÆ÷»
¬
·ÖÀë¡£
HOME: http://www.itpub.net MAIL: epub@itpub.net
5. ITPUB µç×ÓÔÓÖ¾ ORACLE Êý¾Ý¿â¹éµµÄ£Ê½µÄÉèÖÃ
ORACLE Êý¾Ý¿â¹éµµÄ£Ê½µÄÉèÖÃ
: tigerking
×÷Õß
ÔÚORACLE Êý¾Ý¿âµÄ¿ª·¢»·¾³ºÍ²âÊÔ»·¾³ÖУ¬Êý¾Ý¿âµÄÈÕÖ
¶¼ÊDz»ÉèÖõģ¬ÕâÑùÓÐÀûÓÚϵͳӦÓõĵ÷Õû£¬Ò²ÃâµÄÉú³
Á¿µÄÏûºÄ¡£µ«ÔÚϵͳÉÏÏߣ¬³ÉΪÉú²ú»·¾³Ê±£¬½«ÆäÉèÖÃΪ
ÒòΪ£¬ÕâÊDZ£Ö¤ÏµÍ³µÄ°²È«ÐÔ£¬ÓÐЧԤ·ÀÔÖÄѵÄÖØÒª´ëÊ
Á½´Î±¸·Ý¼ä¸ôÖ®¼äµÄÈÕÖ¾Îļþ£¬¿ÉÒÔÓÐЧµÄ»Ö¸´Õâ¶Îʱ¼
ʱºòÍì»Ø»ò×î´ó¿ÉÄܵļõÉÙÊý¾Ý¶ªÊ§¡£ËäÈ»
ORACLE Êý¾Ý¿âµÄÈÕ־ģʽºÍ×Ô¶¯¹éµ
²»¸´ÔÓ£¬µ«ÆäÖеÄһЩ¸ÅÄîºÍ²Ù×÷¹ý³Ì»¹ÊÇÈÝÒ×»ìÏýµÄ£
Ï£¬ËùÓû·¾³Îª
UNIX(HPUX,SOLARIES,AIX,TRU64UNIX)ºÍ
ORACLE8¡£
һҪʹ
. OARCLE Êý¾Ý¿â½øÐÐÈÕÖ¾µÄ×Ô¶¯¹éµµ£¬ÐèÒª×öÁ½·½ÃæµÄÊ Ò»ÊÇÊý¾Ý¿âÈÕ־ģʽ
µÄÉèÖÃ
(database log mode,¿ÉΪArchive Mode ºÍ Archive Mode)£¬ÁíÍâ¾ÍÊÇ×Ô¶¯¹éµµÄ
No
ʽÉèÖÃ
(Automatic archival,¿ÉΪ
Enabled ºÍDisabled)¡£
¶þÈçºÎ²é¿´Êý¾Ý¿âµÄÏÖÐÐÈÕÖ¾ºÍ×Ô¶¯¹éµµÄ£Ê½µÄÉèÖÃ
.
¿ÉÓÃ
archive log list ÃüÁîÀ´²é¿´¡£
ÀýÈ磺
ÔËÐÐÔÚÈÕÖ¾×Ô¶¯¹éµµÄ£Ê½ÏµÄÊý¾Ý¿âϵͳ²é¿´½á¹ûÈçÏ
SVRMGR> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /backup/archivelog
Oldest online log sequence 2131
Next log sequence to archive 2133
Current log sequence 2133
ûÓÐÆô¶¯Êý¾Ý¿âÈÕ־ģʽºÍ×Ô¶¯¹éµµµÄÊý¾Ý¿âϵͳ²é¿
SVRMGR> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u01/app/oracle/product/8.0.5/dbs/arch
Oldest online log sequence 194
Current log sequence 196
ÈýÊý¾Ý¿âÈÕ־ģʽµÄÉèÖÃ
.
ÔÚ´´½¨Êý¾Ý¿âʱ£¬¿ÉÒÔÔÚ
CREATE DATABASE Óï¾äÖÐÖ¸¶¨Êý¾Ý¿âµÄÈÕ־ģʽ
ÓÐÖ¸Ã÷£¬ÔòȱʡΪģʽ¡£ÓÉÓÚÈç¹ûÔÚ´´½¨Êý¾Ý¿âʱָÃ÷Ê
NOARCHIVELOG Archive Mode
µÄ»°£¬»áÔö¼ÓÔ¼
20%µÄ´´½¨Ê±¼ä£¬¶øÔÚÒÔºóÆô¶¯
INSTANCE ʱÔÙÉèÖõĻ°£¬Ò»°ãÖ»ÓÃ
ÃëµÄʱ¼ä£¬ËùÒÔÒ»°ãÔÚ´´½¨Êý¾Ý¿âʱÊDz»ÉèÖÃΪ
ARCHIVE MODE µÄ¡£ÈçҪȷ¶¨Ò»ÏµÍ³Êý
¿âµÄÈÕ־ģʽÉè
Ö㬳ýÁË
(¶þ
)Öеķ½·¨ÍâÒ²¿ÉÒÔÖ´ÐÐÈçϲÙ×÷²é¿´£º
SVRMGR> Select * from V$DATABASE
NAME CREATED LOG_MODE CHECKPOINT ARCHIVE_CH
HOME: http://www.itpub.net MAIL: epub@itpub.net
6. ITPUB µç×ÓÔÓÖ¾ ORACLE Êý¾Ý¿â¹éµµÄ£Ê½µÄÉèÖÃ
------- ------------ --------------- ---------------- -----------------
ORCL 05/21/97 17:55:06 NOARCHIVELOG 172185 170808
½«Êý¾Ý¿âµÄÈÕ־ģʽÉèÖÃÇл»£¨
Archive Mode ºÍ Archive Mode Ö®¼äµÄÇл»£©µÄ²½
No
ÖèºÍ²Ù×÷ÈçÏ£º
1. ¹Ø±ÕÔËÐеÄÊý¾Ý¿âʵÀý
SVRMGRL> shutdown
ÔÚ½øÐÐÈÕ־ģʽÇл»Ö®Ç°£¬±ØÐ뽫ÔËÐеÄÊý¾Ý¿âÕý³£¹
2. ±¸·ÝÊý¾Ý¿â
¸Ã±¸·Ý¸úÒÔºó²úÉúµÄÈÕÖ¾Ò»ÆðÓÃÓÚ½«À´µÄÔÖÄѻָ´£
ʽ£¬Ã»ÓÐÕâ¸öÊý¾Ý¿â±¸·Ý£¬½öÓÐÈÕÖ¾ÎļþÊÇÎÞ·¨´Ó¸ÃÊ
3. Æô¶¯Êý¾Ý¿âʵÀýµ½
mount ״̬£¬µ«²»Òª´ò¿ª¡£
SVRMGRL> startup mount
×¢Ò⣺Èç¹ûÊÇʹÓÃOPS µÄ»°£¬ÇëÖ»´ò¿ªÒ»¸öÊý¾Ý¿âʵÀý½øÐÐģʽ
»»²Ù×÷¡£
4. Çл»Êý¾Ý¿âÈÕ־ģʽ¡£
SVRMGRL> alter database archivelog;(ÉèÖÃÊý¾Ý¿âΪ¹éµµÈÕ־ģʽ
)
»ò
SVRMGRL> alter database noarchivelog;(ÉèÖÃÊý¾Ý¿âΪ¹éµµÈÕ־ģʽ
)
5. ´ò¿ªÊý¾Ý¿â
SVRMGRL> alter database open;
6. È·ÈÏÊý¾Ý¿âÏÖÔÚ´¦Óڹ鵵ÈÕ־ģʽ¡£
SVRMGRL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination for example: $ORACLE_HOME/dbs/arch
Oldest on-line log sequence 275
Next log sequence 277
Current log sequence 278
7. ½«Õâ¸öʱ¼äµãµÄ redo logs ¹éµµ
SVRMGRL> archive log all;
8. È·ÈÏвúÉúµÄÈÕÖ¾ÎļþÒÑÔÚÏàÓ¦µÄ¹éµµÄ¿Â¼ÏÂÃæ¡£
ËÄ
. ×Ô¶¯¹éµµÄ£Ê½ÉèÖÃ
(Automatic archival,¿ÉΪ
Enabled ºÍDisabled)¡£
ÔÚ¸ÃģʽÏ£¬Êý¾Ý¿âÆô¶¯Ò»¸ölogs дµ½ÏµÍ³¹éµµÉ豸µÄÏ
arch ½ø³Ì£¬×¨ÃŸºÔð½«
redo
ӦĿ¼Ï¡£ÔÚÊý¾Ý¿âµÄ²ÎÊýÎļþÖÐÉèÖòÎÊý£¨Ò»°ãÊÇÔÚ
$ORACLE_HOME/dbs/init*.ora Îļþ
ÖУ£©º
LOG_ARCHIVE_START=
LOG_ARCHIVE_DEST=
LOG_ARCHIVE_FORMAT=
LOG_ARCHIVE_START:
ÈçÒªÇó×Ô¶¯¹éµµµÄ»°£¬ÔòÉèΪ
TRUE£¬ÈçÒªÇóΪ·Ç×Ô¶¯¹éµµµÄ»°£¬ÔòÉèÎ
FALSE
LOG_ARCHIVE_DEST:
¸Ã²ÎÊýÉ趨Á˹鵵´æ·ÅµÄ·¾¶¡£
archive logs
LOG_ARCHIVE_FORMAT:
¸Ã²ÎÊýÉ趨ÁË
archive logs µÄÃüÃû¸ñʽ¡£ÀýÈ磬È罫¸ñʽÉèΪ
: arch%s.arc
HOME: http://www.itpub.net MAIL: epub@itpub.net
7. ITPUB µç×ÓÔÓÖ¾ ORACLE Êý¾Ý¿â¹éµµÄ£Ê½µÄÉèÖÃ
log Îļþ½«Îª
: arch1.arc, arch2.arc, arch3.arc
Õ⼸¸ö²ÎÊýÉèÖÃÖ»ÓÐÔÚÊý¾Ý¿âʵÀýÆô¶¯Ç°ÉèÖòÅÄÜÉú
Öã¬ÒªÊ¹ÆäÉúЧ£¬±ØÐëÖØÆðÊý¾Ý¿â¡£
Èç¹ûÊý¾Ý¿âÕýÔÚÔËÐÐÖУ¬²»Äܼ´¿ÌÖØÆð£¬ÒªÉèÖÃÆäΪ×
SVRMGRL> ALTER SYSTEM ARCHIVE LOG START;
ÈçÒªÉèÖÃÆäΪ·Ç×Ô¶¯¹éµµÄ£Ê½
(È¡Ïû×Ô¶¯¹éµµ
)£¬Ôò£º
SVRMGRL> ALTER SYSTEM ARCHIVE LOG STOP;
µ«Èç¹ûÊý¾Ý¿âÖØÆðºó£¬¸øÓï¾äÐ޸ĵĽá¹û¾ÍʧЧÁË£¬×
ÎļþÖеÄ
LOG_ARCHIVE_START µÄÖµÀ´ÉèÖá£
Îå
. ¼¸ÖÖÉèÖÃÇé¿ö£º
(1) Database log mode Archive Mode
Automatic archival Enabled
ÕâÊÇÔڴ󲿷ÖÉú²ú»·¾³ÖеÄ
ORACLE Êý¾Ý¿âÈÕÖ¾¼°¹éµµÄ£Ê½ÉèÖã¬ÕâÖÖ
Êý¾Ý¿âµÄ¶¨ÆÚ±¸·Ý£¨ÓÐÈȱ¸ºÍÀ䱸£©ºÍ¹éµµÈÕÖ¾±¸·Ý£¬¿
µÄÈ«²¿Ê±¼äµã¡£
(2) Database log mode Archive Mode
Automatic archival Disabled
ÕâÖÖÇé¿öÏ£¬Êý¾Ý¿â²»ÄÜ×Ô¶¯¹éµµ£¬ÐèÒª½øÐÐÊÖ¹¤¹éµ
ÓÖûÓеļ°Ê±½øÐÐÊÖ¹¤¹éµµµÄ»°£¬ÓÉÓÚ
LGWR ûÓпÉÓõÄÔÚÏßÈÕÖ¾¿Éд£¬Êý¾Ý
Õâ¶ù£¬Ö»ÓнøÐÐÊÖ¹¤¹éµµºó£¬ÓпÉÓõÄÔÚÏßÈÕÖ¾ºó²ÅÄܼ Çé
¿ö¡£
ÊÖ¹¤¹éµµ²Ù×÷ÈçÏ£º
SVRMGRL> ALTER SYSTEM ARCHIVE LOG ALL;
Êý¾Ý¿â½«»á°ÑÔÚÏßÈÕÖ¾½øÐй鵵´¦Àí
(3) Database log mode NO Archive Mode
Automatic archival Enabled
ÓÐЩÏà¶ÔǷȱ¾-ÑéµÄ¹ÜÀíÔ±ÔÚ½øÐÐÉèÖÃʱ£¬Ö»
LOG_ARCHIVE_START=TRUE£¬È»ºóÔÚÊý¾Ý¿âÆðÀ´ºó²é¿´µ½
ARCH ¹éµµ½ø³ÌÒѾ-ÆðÀ´ÁË£¬¿
ÊǾ¡¹Ü ÒѾ-×÷Á˼¸´ÎÈÕÖ¾Çл»£¬µ«»¹ÊÇûÓй鵵ÈÕÖ¾£¬
ORACLE ÊÇÕâÖÖÇé¿ö£¬
Èç¹ûÊý¾Ý¿â²»ÊÇ´¦ÔÚ redolog »¹ÊDz»»á±»¹éµµ¡£
ARVHIVELOG ģʽ£¬
(4) Database log mode NO Archive Mode
Automatic archival Disabled
ÕâÖÖÉèÖÃÊǸհ²×°µÄ oracle Êý¾Ý¿âµÄȱʡÉèÖ㬿ª·¢»·¾³Ò²´ó²¿·Ö
¹éµµ¡£
HOME: http://www.itpub.net MAIL: epub@itpub.net
8. ITPUB µç×ÓÔÓÖ¾ ²»ÓÃÖؽ¨
Standby Êý¾Ý¿âµÄÇл»·½·¨
²»ÓÃÖؽ¨ Standby Êý¾Ý¿âµÄÇл»·½·¨
: overtime
×÷Õß
Oracle µÄ standby Êý¾Ý¿â³£³£ÓÃÀ´×÷ΪÊý¾Ý¿â±¸·ÝµÄÖØÒª·½·¨ Oracle µÄÁª»úÎĵµ
ÖУ¬ Standby Êý¾Ý¿âÈç¹û±»¼¤»î£¨ activate£©ºó£¬¾Í³ÉΪÁË
primary Êý¾Ý¿â£¬Ô-À´µÄ primary
Êý¾Ý¿â±ØÐëÖؽ¨²ÅÄܳÉΪРstandby Êý¾Ý¿â£ ÕâÖ÷ÒªÊÇÒòΪ
¬ standby µÄ¼¤»îÏ൱ÓÚ¶ÔÊý¾Ý¿
½øÐÐÁË ²Ù×÷¡£Æäʵ£¬´Ó
resetlog Oracle 7.3 ¿ªÊ¼£¬Èç¹û
primary Êý¾Ý¿âµÄ ÔÚÇл»Ê±
redo log
ÊÇ¿ÉÓõÄÇé¿öÏ£¬¿ÉÒÔʵÏÖ primary µ½ standby Êý¾Ý¿âµÄÎÞ·ìÇл»£¨graceful switch£¡£ÕâÑù
©
¿ÉÒÔ²»ÓÃÖؽ¨ standby Êý¾Ý¿â£¬¼õÇáÁËά»¤¹¤×÷Á¿£¬ÁíÍ⣬ÔÚ activate standby Êý¾Ý¿âʱ»á
¶ªÊ§Ò»²¿·ÝÊÂÎñµÄÇé¿öÒ²¿ÉÒÔ±ÜÃâ¡£
ÕâÖÖÇл»·½·¨ÓëÕý³£¼¤»î standby µÄ·½·¨Ö÷Òª²»Í¬Ö®´¦ÔÚÓÚ£º
1. ÔÚ primary Êý¾Ý¿âÉú³É´´½¨Êý¾Ý¿â¿ØÖÆÎļþµÄ½Å±¾£¨ alter database backup
controlfile to trace noresetlogs£¡©£
2. primary Êý¾Ý¿âÒª¹Ø±Õ£¨¿ÉÒÔÒì³£¹Ø±Õ££¬Ö»ÒªËùÓÐµÄ redo og ¿ÉÓþÍÐС£¶øÕý³£
l ©
¼¤»îʱ¶ÔÊý¾Ý¿âûÓÐÒªÇó¡£
primary
3. standby Êý¾Ý¿âÔÚÓ¦ÓÃÍêËùÓеĹ鵵ÈÕÖ¾ºóÒªÕý³£¹Ø±Õ primary µÄËùÓеÄ
redo log ¿½±´µ½ Êý¾Ý¿âµÄÏàӦĿ¼Ï¡£
standby
4. ÒÔ nomount ·½Ê½´ò¿ªÊý¾Ý¿â£Ö´ÐÐÏÈÇ°ÔÚ
standby ¬ primary Êý¾Ý¿âÉÏÉú³ÉµÄ create
controlfile Óï¾ä¡£
5. ÔÚ standby Êý¾Ý¿âÉϽøÐÐ recover£´ò¿ªÊý¾Ý¿â¡Õâʱ£¬
¬ standby ¾Í³ÉΪеÄ
£ primary¡£
6. ÏÖÔÚ£¬Ô-À´µÄ primary Êý¾Ý¿â¾ÍÏ൱ÓÚ±£ÁôÁËÐ嵀 primary µÄËùÓÐÊý¾ÝÎļþÒ»Ñù£
Ö»ÐèÔÚÐ嵀 primary ÉÏ´´½¨ Êý¾Ý¿âµÄ¿ØÖÆÎļþ²¢½øÐÐÒ»´Î¹éµµ¾Í
standby
primary Êý¾Ý¿âµÄÎļþ´´½¨Ð嵀 standby ÁË¡£
Oracle standby µÄÕâÖÖÇл»·½Ê½£¬¿ÉÒÔÀí½â³É£º
standby Êý¾Ý¿â¾ÍÊÇÒ»¸öÔÚ²»Í£×ö»Ö¸´µÄ±¸·ÝÊý¾Ý¿â£¬Èç¹ activate£©·½Ê½£¬
¾ÍÏñÊÇ×öÁËresetlogs ²Ù×÷Ò»Ñù£¬ primary µÄÊý¾ÝÎļþÏ൱ÓÚÊÇresetlogs ֮ǰµÄ±¸·Ý£¬¾Íʧ
ЧÁË¡£¶øÕâÖÖÎÞ·ìÇл»·½Ê½£¬Ï൱ÓÚÔÚ±¸·ÝÊý¾Ý¿â×öÁËÒ
¼þ£¨
primary Êý¾Ý¿âµÄÊý¾ÝÎļþ£©ÈÔÈ»ÊÇÓÐЧµÄ¡£
µ±È»£¬ÓÐʱºòÓü¤»îµÄ·½Ê½ÊDz»¿É±ÜÃâµÄ£¬ÌرðÊÇÔÚ redo log ÒѾ-²»¿ÉÓÃʱ¡£ÔÚÐèÒ
¶Ô
primary ºÍ standby ×öÁÙʱÇл»£¨ÈçÓ²¼þÉý¼¶¡¢»ú·¿°áǨ£©Ê±£¬¿
·½Ê½¡£
ÒÔÏÂÊÇÒ»´Î standby Êý¾Ý¿âµÄʵ¼ÊÇл»¹ý³Ì£º
˵Ã÷£º
Êý¾Ý¿â°æ±¾£º Oracle 8.1.6.3
²Ù×÷ϵͳ£º Solaris 2.6
A »ú : primay database
B »ú : standby database
standby database ÔÚ recover managed standby database ״̬£»
Êý¾ÝÎļþ¶¼ÊÇ online ״̬£»
HOME: http://www.itpub.net MAIL: epub@itpub.net
9. ITPUB µç×ÓÔÓÖ¾ ²»ÓÃÖؽ¨
Standby Êý¾Ý¿âµÄÇл»·½·¨
initSID.ora Ö÷Òª²ÎÊý
:
log_archive_dest_1 "location=/t11a/oracle8i/switch_data/archive mandatory"
log_archive_dest_2 "service=standby reopen=300"
log_archive_dest_state_1 Enable
log_archive_dest_state_2 Enable
standby_archive_dest /t11a/oracle8i/switch_data/archive
db_file_name_convert ('/export/home2/oracle', '/t11a/oracle8i/switch_data')
log_file_name_convert ('/export/home2/oracle', '/t11a/oracle8i/switch_data')
Switchover ²½Öè
:
A »ú B »ú
1.¹éµµµ±Ç°µÄÈÕÖ¾1.¼ì²é
standby Êý¾Ý¿â
alter system archive log current;
È·ÈÏ datafile µÄ״̬²»ÊÇfuzzy »ò
recover:
2.Éú³É´´½¨¿ØÖÆÎļþµÄ½Å±¾
select name,fuzzy,recover
alter database backup controlfile from v$datafile_header;
to trace noresetlogs; ºóÀ´ÐµÄÔöµÄÊý¾ÝÎļþµÄ״̬¿É
recover
´Ë½Å±¾ÌáÈ¡³ö
create controlfile µÄÄÇÒ»
¾ä³öÀ´£¬Çл»Ê±ÔÚ
standby Êý¾Ý¿â´ò¿ª È·ÈÏdatafile µÄ
unrecoverable_change# <
ºóÖ´ÐÐ v$backup.change#:
select d.name,unrecoverable_change#,change#
3.¹Ø±ÕÊý¾Ý¿â from v$datafile d, v$backup b
shutdown immediate where b.file#=d.file#;
ÈôÊý¾Ý¿âÒì³£¹Ø±Õ£¬Ö»Òª
online redolog
ÍêºÃÒ²¿ÉÒÔ È·ÈÏÊý¾Ý¿âµÄ
resetlog version Ò»Ñù
:
select resetlogs_change#, resetlogs_time,
open_resetlogs
from v$database;
2.Ó¦ÓÃÍêËùÓеÄ
archivelog£¬ÖÐÖ¹
recovery
recover managed standby database cancel;
3.Õý³£¹Ø±ÕÊý¾Ý¿â
shutdown immediate;
4.¿½±´ online redolog µ½
ËùÓÐµÄ B
»ú:
²»ÒªÉ¾³ýÕâЩ
online redo log;
HOME: http://www.itpub.net MAIL: epub@itpub.net
10. ITPUB µç×ÓÔÓÖ¾ ²»ÓÃÖؽ¨
Standby Êý¾Ý¿âµÄÇл»·½·¨
4.Ð޸Ĵ´½¨¿ØÖÆÎļþµÄ½Å±¾
ÈçÊý¾ÝÎļþÃûµÈ£¨ÔÚ
standby ºÍ
primary Êý¾ÝÎļþÃû²»
Ò»ÖµÄÇé¿öÏ£©
5.´ò¿ªÊý¾Ý¿â
startup nomount;
create controlfile .....;
£¨´ËΪÔÚÊý¾Ý¿âÉϱ¸·Ý¿Ø
primary
ÖÆÎļþÉú³ÉµÄ½Å±¾£©
recover database;
alter database open;
6.¼ì²éÊý¾Ý¿âÊÇ·ñÕý³£
7.´´½¨
standby Êý¾Ý¿âµÄ¿ØÖÆÎļþ
alter database create standby controlfile as '....';
8.¿½±´
standby Êý¾Ý¿âµÄ¿ØÖÆÎļþµ½
A »ú
5.½ÓÊÕ archive log
B »úµÄ
6.¿ªÆô
standby Êý¾Ý¿â
:
startup nomount;
alter database mount standby
database;
recover managed standby database;
Switchback ºÍ
Switchover µÄ²½ÖèÒ»Ñù
³£¼ûÎÊÌâ
1.Çл»ºó£¬ÔÚÐ嵀 standby Ö´ÐÐ recover managed standby database£¬Ìáʾ ORA-308£¬
ÕÒ²»µ½ÏàÓ¦µÄ øÇÒ
archivelog£¬ ¶ archivelog µÄÎļþÃû»¹ÊÇ primary ÉϵÄÃû×Ö£¬Ã»Óиù¾Ý
log_file_name_convert ²ÎÊýת»»
ÕâÖÖ´íÎó·¢ÉúÔÚ¸ÕÇл»ºóµÄ Í·¼¸¸ö archivelog ÎļþÖУ¬ÊÇÒòΪµ±Ê±Ô¶³Ìarchive ûÓÐÕý
³£¹¤×÷£¬ Oracle ÈÏΪÄÇЩ archivelog Ó¦¸ÃÒѾ-ÔÚÏàÓ¦µÄĿ¼Ï (ÔÚÇл»ºóµÄprimary ÒѾ-
archive Á˸ÃÎļþÉú³É
log ºó²Å standby ¿ØÖÆÎļþ£¬ Oracle ¸ù¾Ý¿ØÖÆÎļþÅжÏÊÇ·ñÉú³
ÐèµÄ archivelog£¬ )£¬¾ÍûÓеȴý£¬¶øÊÇÖ±½ÓÈ¥ÏàӦĿ¼ÕҸà archivelog¡£
ÕâЩ archivelog ±ØÐëÊÖ¹¤´«µ½ standby µÄÏàӦĿ¼Ï£¬ÇÒÓÉÓÚ²»ÊÇÓÉ RFS ½ø³Ì½øÐÐ
archive£¬ÎļþÃûҲûÓиù¾Ý log_file_name_convert ²ÎÊý½øÐÐÏàÓ¦µÄת»»£¬ÕâЩ log Ҫͨ¹ý
recover standby database ÃüÁîÓ¦Óõ½ standby Êý¾Ý¿âÖÐ .
2.³öÏÖÌáʾ ºó£¬ÔÙ´ÎÖ´ÐÐ
ORA-308 recover managed standby database ʱ£¬Ìáʾ£º
ORA-00275: media recovery has already been started
ÖØÐÂ internal ¼´¿É
sqlplus
²Î¿¼×ÊÁÏ
:
Granceful Switchover and Switchback Oracle Standby Database
HOME: http://www.itpub.net MAIL: epub@itpub.net
11. ITPUB µç×ÓÔÓÖ¾ ÇÉÓÃ
Rman À´¹ÜÀíÂãÉ豸ÉϵÄÊý¾Ý¿â
ÇÉÓà Rman À´¹ÜÀíÂãÉ豸ÉϵÄÊý¾Ý¿â
×÷Õß
: chao_ping
ÎÒÃÇÖªµÀ£¬ Oracle Êý¾Ý¿â´ó¶à¶¼´æ·ÅÔÚÂãÉ豸ÉÏÃ棬ÒÔÀ
Unix ÉÏÃæµÄ IO ÐÔÄÜ
µÄÌáÉý¡£µ«ÊÇÂãÉ豸µÄ¹ÜÀí±È½ÏÂé·³£¬ÓÈÆäÊÇ°ÑÊý¾ÝÎļ
ÂãÉ豸°ÑÊý¾ÝÎļþת»»µ½Îļþϵͳ£¬ÕâЩ¸ø
dba ´øÀ´ºÜÍ·ÌÛµÄÊÂÇé¡£
±¾ÎĽéÉÜÒ»¸ö°ì·¨£¬¿ÉÒÔÓÃ
Rman À´ÇáËɸ㶨ÂãÉ豸
/Îļþϵͳ֮¼äÊý¾ÝÎļþµÄÇ
ÔÚ´«Í³·½·¨ÀïÃ棬ÎÒÃDZØÐë¶ÔÓÚÿ¸ö overhead µÄÖµ
Unix ²»Í¬µÄ´óС£¬
Block OS ¾í¹ÜÀíµÄ
×÷¼ÆË㣬²ÅÄܷdz£Ð¡ÐĵÄÓÃ
dd À´×öÕâЩ¿½±´
ºÍÒƶ¯£¬µ«ÊÇÏÖÔÚÔÚ
Rman µÄ°ïÖúÏ£¬ÎÒÃÇ¿É
ÒÔÍêÈ«ºöÂÔÕâЩ²»Í¬µÄµØ·½£¬ÔÚËùÓÐ
Unix ƽ̨ƽ̨ÉÏÖ±½ÓÔÚ
/NT Oracle ÄÚ²¿ÊµÏÖÕâÖÖÊý¾Ý
ÎļþµÄתÒÆ¡£
Ò»
. °ÑÊý¾ÝÎļþ´ÓÎļþϵͳתÒƵ½ÂãÉ豸
±ÈÈçÎÒÃÇÏÖÔÚÓÐÒ»¸öÊý¾Ý¿â£¬Æä
rbs.dbf Êý¾ÝÎļþµÄ
IO Á¿·Ç³£´ó£¬Ôì³É±È½Ï´óµÄ
IO µÈ
´ý£ ÎÒÃÇÏ£Íû°ÑËüתÒƵ½ÂãÉ豸ÉÏ£ ÒÔÌáÉýÐÔÄÜ¡ ¿ÉÒÔ¿´µ
¬ rbs.dbf µÄ´óСΪ£
¬ 60M£¬
ËùÒÔÎÒÃÇÐèÒª´´½¨Ò»¸ö
61M µÄÂãÉ豸£¨
1M ¿Õ¼äÓÃÀ´ÈòÙ×÷ϵͳʹÓ㬹ÜÀí¾í
²»ÓÃÒ²¿ÉÒÔ£¬ÎÒÃÇ·½±ãÆð¼û£¬¸ø
1M 1M£¡©£
s80_svc:oraprd 22> ls -l rbs.dbf
-rw-r----- 1 oraprd dba 62916608 Jan 20 21:48 rbs.dbf
ÎÒÃÇÏÈÒªÖªµÀ²Ù×÷ϵͳµÄÒ»¸ö
PP£¨
Physical Partition£©µÄ´óС£¬ÎÒÃÇÕâ¸öÀý×ÓÀï
µÄ´óСÊÇ
64M¡£
# lsvg oravg
VOLUME GROUP: oravg VG IDENTIFIER: 000c738d015de954
VG STATE: active PP SIZE: 64 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 543 (34752 megabytes)
MAX LVs: 256 FREE PPs: 114 (7296 megabytes)
LVs: 8 USED PPs: 429 (27456 megabytes)
OPEN LVs: 8 QUORUM: 2
TOTAL PVs: 1 VG DESCRIPTORS: 2
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 1 AUTO ON: no
MAX PPs per PV: 1016 MAX PVs: 32
ÎÒÃÇת»»µ½
root Óû§£ ´´½¨ÕâÑùÒ»¸öÂß¼-¾í£ ´óСÊÇ
¬ 66M£¬
²¢ÇÒ°ÑÕâ¸öÂß¼-¾í¸ø
¬ oracle
Óû§
oraprd£º
# mklv -y lvorarbs oravg 1
lvorarbs
# chown oraprd:dba /dev/rlvorarbs
ÓÉÓÚÕâ¸öÊǻعö¶ÎËùÔڵıí¿Õ¼ä£¬ÐèÒª°Ñ±í¿Õ¼ä
offline£¬ÏÈÒª »Ø¹ö¶Î£º
offline
HOME: http://www.itpub.net MAIL: epub@itpub.net
12. ITPUB µç×ÓÔÓÖ¾ ÇÉÓÃ
Rman À´¹ÜÀíÂãÉ豸ÉϵÄÊý¾Ý¿â
SQL> select segment_name,status from dba_rollback_segs;
SEGMENT_NAME STATUS
------------------------------ ----------------
SYSTEM ONLINE
RBS01 ONLINE
RBS02 ONLINE
RBS03 ONLINE
SQL> alter rollback segment rbs01 offline;
Rollback segment altered.
SQL> alter rollback segment rbs02 offline;
Rollback segment altered.
SQL> alter rollback segment rbs03 offline;
Rollback segment altered.
rman£¬Á¬½Óµ½Ä¿±êÊý¾Ý¿â£º
È»ºóÎÒÃǵǽ½øÈë
s80_svc:oraprd 25> rman target / nocatalog
Recovery Manager: Release 8.1.7.2.0 - Production
RMAN-06005: connected to target database: TEST (DBID=1749460842)
RMAN-06009: using target database controlfile instead of recovery catalog
ÎÒÃÇ¿ªÊ¼°ÑÊý¾ÝÎļþ´ÓÎļþϵͳ¿½±´µ½´ÅÅÌÂãÉ豸ÉÏÃæ£
RMAN> run{
2> allocate channel c3 type disk;
3> sql 'alter tablespace rbs offline';
4> copy datafile '/backup/test/datafile/rbs.dbf' to '/dev/rlvorarbs';
5> }
Ö´ÐÐÕâ¸öÃüÁî¿ÉÒÔ¿´µ½£¬ÃüÁî³É¹¦Ö´ÐУº
RMAN-03022: compiling command: allocate
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: c3
RMAN-08500: channel c3: sid=9 devtype=DISK
RMAN-03022: compiling command: sql
RMAN-06162: sql statement: alter tablespace rbs offline
RMAN-03023: executing command: sql
RMAN-03022: compiling command: copy
HOME: http://www.itpub.net MAIL: epub@itpub.net
13. ITPUB µç×ÓÔÓÖ¾ ÇÉÓÃ
Rman À´¹ÜÀíÂãÉ豸ÉϵÄÊý¾Ý¿â
RMAN-03023: executing command: copy
RMAN-08000: channel c3: copied datafile 4
RMAN-08501: output filename=/dev/rlvorarbs recid=8 stamp=451692882
RMAN-08031: released channel: c3
È»ºóÎÒÃÇÔÙ¸üпØÖÆÎļþÀïÃæ»Ø¹ö¶Î±í¿Õ¼äÊý¾ÝÎļþµÄ¶
SQL> alter tablespace rbs rename datafile
2 '/backup/test/datafile/rbs.dbf' to '/dev/rlvorarbs';
Tablespace altered.
SQL> alter tablespace rbs online;
Tablespace altered.
ÎÒÃǼì²éÊý¾Ý×ֵ䣬¿ÉÒÔ¿´µ½ÕýÈ·µÄеÄÊý¾ÝÎļþ£º
SQL> l
1* select tablespace_name,file_name from dba_data_files where
tablespace_name='RBS'
SQL> /
TABLESPACE_NAME FILE_NAME
------------------------------ --------------------
RBS /dev/rlvorarbs
°Ñ¼¸¸ö»Ø¹ö¶Î·Ö±ðÖØÐÂ
online ¾Í¿ÉÒÔÁË¡£
¶þ
. °ÑÊý¾ÝÎļþ´ÓÂãÉ豸תÒƵ½Îļþϵͳ
ÏÂÃæÎÒÃÇÔÙÑÝʾһÏÂÈçºÎ°ÑÊý¾ÝÎļþ´ÓÂãÉ豸תÒƵ½Î
ÎÒÃÇ
ÏȽ¨Á¢Ò»¸öÂãÉ豸£¬ÔÙ¹éÊôÓÚ
Oracle Óû§£¬ÓÃÕâ¸öÂãÉ豸À´´´½¨±ê¿Õ
# mklv -y lvrawtest oravg 1
lvrawtest
# chown oraprd:dba /dev/rlvrawtest
È»ºóÎÒÃÇÔÙ
Oracle ÀïÃæ´´½¨±í¿Õ¼ä£¬´´½¨±í£¬²åÈëʾÀýÊý¾Ý£º
SQL> create tablespace rawtofs datafile
2 '/dev/rlvrawtest' size 60m;
Tablespace created.
×¢ÒâÕâÀïÎÒÃÇ´´½¨µÄ±í¿Õ¼ä´óС²»ÄÜ´óÓÚ
65M£¬ÒòΪÂã·ÖÇø´óСֻÓÐ
66M£ Ó Òª×÷
¬ 1M
Ð
Ϊ µÄ¹ÜÀíʹÓá£
OS
SQL> create table testforraw (id number) tablespace rawtofs;
HOME: http://www.itpub.net MAIL: epub@itpub.net
14. ITPUB µç×ÓÔÓÖ¾ ÇÉÓÃ
Rman À´¹ÜÀíÂãÉ豸ÉϵÄÊý¾Ý¿â
Table created.
SQL> insert into testforraw values(100);
1 row created.
SQL> commit;
Commit complete.
RMAN> run{
2> allocate channel c3 type disk;
3> sql 'alter tablespace rawtofs offline';
4> copy datafile '/dev/rlvrawtest' to '/backup/test/datafile/testforraw.dbf';
5> }
RMAN-03022: compiling command: allocate
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: c3
RMAN-08500: channel c3: sid=13 devtype=DISK
RMAN-03022: compiling command: sql
RMAN-06162: sql statement: alter tablespace rawtofs offline
RMAN-03023: executing command: sql
RMAN-03022: compiling command: copy
RMAN-03023: executing command: copy
RMAN-08000: channel c3: copied datafile 5
RMAN-08501: output filename=/backup/test/datafile/testforraw.dbf recid=7
stamp=451692581
RMAN-08031: released channel: c3
È»ºóÎÒÃÇÔÙÔÚ
Oracle ÀïÃæ¶ÔÕâ¸öÊý¾ÝÎļþ¸üж¨Ò壺
SQL> alter tablespace rawtofs rename datafile '/dev/rlvrawtest' to
'/backup/test/datafile/testforraw.dbf';
Tablespace altered.
SQL> alter tablespace rawtofs online;
Tablespace altered.
ÎÒÃǼì²éÒ»ÏÂÎÒÃDzåÈëµÄÊý¾Ý£¬Ã»ÓÐÎÊÌ⣺
SQL> select *from testforraw;
ID
----------
100
ÎÒÃǼì²éÊý¾Ý×ֵ䣬ҲÕýÈ··´Ó³ÁËÕâ¸öеÄÊý¾ÝÎļþ£
HOME: http://www.itpub.net MAIL: epub@itpub.net
15. ITPUB µç×ÓÔÓÖ¾ ÇÉÓÃ
Rman À´¹ÜÀíÂãÉ豸ÉϵÄÊý¾Ý¿â
SQL> L
1* select tablespace_name,file_name from dba_data_files where
tablespace_name='RAWTOFS'
SQL> /
TABLESPACE_NAME FILE_NAME
------------------------------ --------------------------------------------------
RAWTOFS /backup/test/datafile/testforraw.dbf
>
HOME: http://www.itpub.net MAIL: epub@itpub.net
16. ITPUB µç×ÓÔÓÖ¾ ¿ª·¢
Pro*C/C++¶àÏß³ÌÓ¦Óõķ½·¨
¿ª·¢ Pro*C/C+ +¶àÏß³ÌÓ¦Óõķ½·¨
wangqis
×÷Õߣº ÕûÀí£º
jlandzpa
Ò» ±à³Ì²½ÖèÒÔ¼°³ÌÐòÁ÷³Ì
.
1) °²×°´íÎó´¦Àí¾ä±ú¡£
2) ·ÖÅäÔËÐл·¾³¡£
3) µ÷ÓÃ×Ó³ÌÐò
logon()£¬½¨Á¢µ½Ö¸¶¨ÔËÐл·¾³µÄÊý¾Ý¿âÁ¬½Ó¡£
4) ½¨Á¢Ïß³Ì
1£¬ÓÃÓÚÖ´ÐÐquery()×Ó³ÌÐò£¬¸Ã×Ó³ÌÐòÓÃÓÚ²éѯ£»
½¨Á¢Ïß³Ì
2£¬ÓÃÓÚÖ´ÐÐ modify()×Ó³ÌÐò£¬¸Ã×Ó³ÌÐòÓÃÓÚÐÞ¸Ä±í¡£
5) µ÷ÓÃ×Ó³ÌÐò
logoff()¶Ï¿ªÁ¬½Ó¡£
6) ÊÍ·ÅΪÔËÐл·¾³Ëù·ÖÅäµÄÄÚ´æ¡£
¶þ£®¾ßÌå´úÂëʵÏÖ
1. Á¬½Óµ½ Êý¾Ý¿â×Ó³ÌÐò
Oracle
void logon(sql_context ctx)
{
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR username[20],password[20],server[20];
EXEC SQL END DECLARE SECTION;
EXEC SQL CONTEXT USE :ctx;
printf("n ÊäÈëÓû§Ãû£º");
gets(username.arr);
username.len = (unsigned short)strlen((char *) username.arr);
printf("n ÊäÈë¿ÚÁ
");
gets(password.arr);
password.len = (unsigned short)strlen((char *) password.arr);
printf("n ÊäÈë·þÎñÃû£º
");
gets(server.arr);
server.len = (unsigned short)strlen((char *) server.arr);
EXEC SQL CONNECT :username IDENTIFIED BY
<img src="images/smilies/tongue.gif" border="0" alt="">assword
USING :server;
printf("n ÒÔÓû§ %s ³É¹¦µØÁ¬½Óµ½ÁË·þÎñÆ÷ %s ÉÏ£¡ n",
username.arr,server.arr);
}
2£®¶Ï¿ªÊý¾Ý¿âÁ¬½Ó×Ó³ÌÐò¡£
Void logoff(sql_context ctx)
{
EXEC SQL CONTEXT USE :ctx;
EXEC SQL COMMIT WORK RELEASE;
}
3£®´íÎó´¦Àí×Ó³ÌÐò¡£
void sql_ error(struct sqlca sqlca)
{
HOME: http://www.itpub.net MAIL: epub@itpub.net
17. ITPUB µç×ÓÔÓÖ¾ ¿ª·¢
Pro*C/C++¶àÏß³ÌÓ¦Óõķ½·¨
if (sqlca.sqlcode < 0)
printf("n%.*snn",sqlca.sqlerrm.sqlerrml,sqlca.sqlerrm.sqlerrmc);
exit(1);
}
4£®¸üÐÂ×Ó³ÌÐò
* ¸üÐÂÎÄÕ´úÂë±íÖÐ
TYPE ÖеÄÎÄÕÂÄÚÈÝ¡£
void modify(parameters *param)
{
struct sqlca sqlca;
sql_context ctx;
ctx=param->ctx;
EXEC SQL WHENEVER SQLERROR DO sql_error(sqlca);
EXEC SQL CONTEXT USE :ctx;
EXEC SQL UPDATE type SET type_remark='¿Æѧ
'
WHERE type_code='AA';
EXEC SQL COMMIT;
}
/
HOME: http://www.itpub.net MAIL: epub@itpub.net
18. ITPUB µç×ÓÔÓÖ¾ ½«²éѯ½á¹ûÁ¬½Ó³É±íµÄ¼¸¸ö·½·¨
½«²éѯ½á¹ûÁ¬½Ó³ÉÁбíµÄ¼¸¸ö·½·¨
: oldwain
×÷Õß
ÎÒÃÇÔÚʵ¼Ê¿ª·¢¹ý³ÌÖУ¬¾-³£ÐèÒª½«Ò»¸ö²éѯµÄ½á¹ûÁ
Èç˵½«Ò»¸ö²¿Ãż°ÆäËùÓÐÔ±¹¤ÁÐÔÚÒ»ÐÐÏÔʾ¡£
±¾ÎĽéÉÜÁË´Ó×î¼òµ¥µ½×îͨÓõļ¸ÖÖ·½·¨À´´ïµ½ÕâÒ»Ä
¡£
1. ÒÑÖªÁеÄÈ¡Öµ·¶Î§
±ÈÈç˵
£¬ÐÒÔϲúÆ·±í 3 ÖÖÑÕÉ« B-BLACK, W -WHITE)£º
Ó £¬¿ÖÖ²úÆ·Ö»ÓÐ
à (R-RED,
scott@ORCL> DESC PROD
Ãû³Æ ¿Õ
? ÀàÐÍ
----------------------------------------- -------- --------------
PRODNAME VARCHAR2(20)
COLOR VARCHAR2(1)
scott@ORCL> SELECT * FROM PROD;
PRODNAME C
-------------------- --
CAR R
CAR B
CAR W
MOTOR W
MOTOR B
ÎÒÃÇÏ£ÍûÁгöÿÖÖ²úÆ·¶¼ÓÐÄÄЩÑÕÉ«
¡£
ÕâÖÖÇé¿öÏ ʹÓÃ
, Ö»Òª¼òµ¥µÄ
decode()º¯Êý¼´¿É
.
ÏÂÃæÊÇ´úÂë¼°ÏàÓ¦µÄÔËÐнá¹û
script ¡£
scott@ORCL> COLUMN COLORS FORMAT A10
scott@ORCL >select PRODNAME,
2 max(decode( COLOR, 'B', COLOR, null )) ||
3 max(decode( COLOR, 'W', COLOR, null )) ||
4 max(decode( COLOR, 'R', COLOR, null )) COLORS
5 from PROD
6 group by PRODNAME
7 /
PRODNAME COL
-------------------- ---
CAR BWR
MOTOR BW
HOME: http://www.itpub.net MAIL: epub@itpub.net
19. ITPUB µç×ÓÔÓÖ¾ ½«²éѯ½á¹ûÁ¬½Ó³É±íµÄ¼¸¸ö·½·¨
2.¾²Ì¬
SQL
ÕâÖÖ·½·¨ÊʺÏÓÚÁеÄÈ¡Öµ²»ÄÜÔ¤Öª£ÓÉÓÚʹÓþ²Ì¬
sql£¬
Ïà¶Ô·½·¨
3 À´Ëµ±È½Ï¼òµ¥£¬
¬
²»¹ý¸Ãº¯ÊýÖ»ÄÜÓÃÓÚÌض¨µÄ±í¡£
ʾÀýËùÓÃµÄ±í¼°Êý¾ÝʹÓÃ
oracle Ëæ»ú ±í
demo emp¡£
×¢Òâ varchar2 µÄ³¤¶ÈÏÞÖÆ£¬ÁеÄÈ¡ÖµµÄ×ܳ¤¶ÈÊÇÓÐÏÞÖÆ
: ÊÜ 3 ÖÐÒ²ÓÐ
ͬÑùµÄÎÊÌâ¡£
ÏÂÃæÊǺ¯Êý¼°ÆäÔËÐнá¹û£º
create or replace
function list_func1( p_dept in varchar2 )
return varchar2
is
l_str varchar2(4000) default null;
l_sep varchar2(2) default null;
begin
for x in ( select empno from emp where deptno = p_dept ) loop
l_str := l_str || l_sep || to_char(x.empno);
l_sep := ', ';
end loop;
return l_str;
end;
/
scott@ORCL> column emplist format a60
scott@ORCL> select deptno, emplist1(deptno) emplist
2 from emp
3 group by deptno
4 /
DEPTNO EMPLIST
---------- ------------------------------------------------------------
10 7782, 7839, 7934
20 7369, 7566, 7788, 7876, 7902
30 7499, 7521, 7654, 7698, 7844, 7900
scott@ORCL>
3.¶¯Ì¬
SQL
ÕâÖÖ·½·¨ÓÉÓÚʹÓö¯Ì¬
sql£¬Ïà¶ÔÀ´Ëµ±È½Ï¸´ÔÓ£¬µ«Óë´Ëͬʱ£¬Ë
2 À´Ëµ
¹¦ÄÜ´ó´óÔöÇ¿£º
Ëü¿ÉÒÔÓÃÓÚÈÎÒâ±í£¬²¢¿ÉÒÔÁ¬½Ó±íÖеÄÈÎÒâÁ
º¯Êý´úÂ룺
create or replace
function list_func2( p_key_name in varchar2,
p_key_val in varchar2,
HOME: http://www.itpub.net MAIL: epub@itpub.net
20. ITPUB µç×ÓÔÓÖ¾ ½«²éѯ½á¹ûÁ¬½Ó³É±íµÄ¼¸¸ö·½·¨
p_other_col_name in varchar2,
p_tname in varchar2 )
return varchar2
as
type rc is ref cursor;
l_str varchar2(4000);
l_sep varchar2(2);
l_val varchar2(4000);
l_cur rc;
begin
open l_cur for 'select '||p_other_col_ name||'
from '|| p_tname || '
where ' || p_key_name || ' = :x '
using p_key_val;
loop
fetch l_cur into l_val;
exit when l_cur%notfound;
l_str := l_str || l_sep || l_val;
l_sep := ', ';
end loop;
close l_cur;
return l_str;
end;
/
²ÎÊý˵Ã÷£º
p_key_name¡ª¡ª ²éѯÒÀ¾ÝµÄÁÐÃû
p_key_val¡ª¡ª²éѯÒÀ¾ÝµÄÁÐÃûËù¶ÔÓ¦µÄÁÐÖµ
p_other_col_name¡ª¡ª
ÒªÁ¬½Ó³ÉÁбíµÄÁÐÃû
p_tname¡ª¡ª ±íÃû
ÏÂÃæÊÇÔËÐнá¹û£º
scott@ORCL> column emplist format a60
scott@ORCL> select DEPTNO,
2 list_func2('DEPTNO', DEPTNO, 'EMPNO', 'EMP') emplist
3 from emp
4 group by deptno
5 /
DEPTNO EMPLIST
---------- --------------------------------------------------
10 7782, 7839, 7934
20 7369, 7566, 7788, 7876, 7902
HOME: http://www.itpub.net MAIL: epub@itpub.net
21. ITPUB µç×ÓÔÓÖ¾ ½«²éѯ½á¹ûÁ¬½Ó³É±íµÄ¼¸¸ö·½·¨
30 7499, 7521, 7654, 7698, 7844, 7900
scott@ORCL>
HOME: http://www.itpub.net MAIL: epub@itpub.net
22. ITPUB µç×ÓÔÓÖ¾ ¼¸¸ö³£Óýű¾
¼¸¸ö³£Óýű¾
×÷Õߣº ÕûÀí£º
sean jlandzpa
ÊÕµ½µÚÒ»ÆÚ µç×Ó¿¯Î¾õµÃºÜºÃ£¬Ò»¶¨»á¶Ô´ó¼ÒÓкܶà
IT PUB
µÄ
script¡·Ò»ÎĵÄÆô·¢£¬ÎÒÏë°Ñ×Ô¼º¾õµÃ±È½ÏÓÐÓõļ¸¸ö
script ¹±Ï׳öÀ´£¬ºÍ´ó¼Ò¹²Ïí¡
Ò»¡¢´´½¨Óû§Êý¾Ý×ÖµäµÄ½Å±¾
ÎļþÃû
LCOLUMN7.SQL
BREAK ON TABLE_NAME SKIP 1
SET LONG 180
SET LINE 255
SET ARRAY 10
SET PAGES 50000
COLUMN TABLE_NAME HEADING TABLENAME FORMAT A30
COLUMN COLUMN_ID HEADING CID FORMAT 999
COLUMN NULLABLE HEADING NULLABLE
COLUMN COLUMN_NAME HEADING COLUMNNAME FORMAT A30
COLUMN DATA_TYPE HEADING DATATYPE FORMAT 999
COLUMN DATA_LENGTH HEADING D_L FORMAT 9999
COLUMN DATA_PRECISION HEADING D_P FORMAT 99
COLUMN DATA_SCALE HEADING D_S FORMAT 99
COLUMN COL_COMMENT HEADING C_COMMENT FORMAT A150
SPOOL c:LSTSLCOLUMN7.LST
Select substr(o.name,1,30) TABLE_NAME,
c.col# COLUMN_ID,
decode(sign(c.null$),-1,'D', 0, 'Y', 'N') NULLABLE,
substr(c.name,1,30) COLUMN_NAME,
decode(c.type#, 1, 'VARCHAR2',
2, decode(c.scale, null,
decode(c.precision, null, 'NUMBER', 'FLOAT'),
'NUMBER'),
8, 'LONG', 9, 'VARCHAR',
12, 'DATE', 23, 'RAW', 24, 'LONG RAW',
69, 'ROWID',96,'CHAR', 105, 'MLSLABEL',
106, 'MLSLABEL', 'UNDEFINED') DATA_TYPE,
c.length DATA_LENGTH,
c.precision DATA_PRECISION,
c.scale DATA_SCALE,
substr(co.comment$,1,150) COL_COMMENT
from sys.col$ c, sys.obj$ o, sys.com$ co
where o.obj# = c.obj#
and o.owner# = userenv('SCHEMAID')
HOME: http://www.itpub.net MAIL: epub@itpub.net
23. ITPUB µç×ÓÔÓÖ¾ ¼¸¸ö³£Óýű¾
and c.obj# = co.obj#(+)
and c.col# = co.col#(+)
and o.type in (1,2,3,4,5)
order by o.type,o.name,c.col#;
SPOOL OFF
ÒÔÉÏÊÇÕë¶Ô
7.3 ·þÎñÆ÷µÄ½Å±¾£¬Èç¹ûÊÇ
8 °æ±¾µÄ·þÎñÆ÷ÒªÉÔ×÷Ð޸ģ È
COLUMN8.SQL£º ¬ ç
BREAK ON TABLE_NAME SKIP 1
SET LONG 180
SET LINE 255
SET ARRAY 10
SET PAGES 50000
COLUMN TABLE_NAME HEADING TABLENAME FORMAT A30
COLUMN COLUMN_ID HEADING CID FORMAT 999
COLUMN NULLABLE HEADING NULLABLE
COLUMN COLUMN_NAME HEADING COLUMNNAME FORMAT A30
COLUMN DATA_TYPE HEADING DATATYPE FORMAT 999
COLUMN DATA_LENGTH HEADING D_L FORMAT 9999
COLUMN DATA_PRECISION HEADING D_P FORMAT 99
COLUMN DATA_SCALE HEADING D_S FORMAT 99
COLUMN COL_COMMENT HEADING C_COMMENT FORMAT A150
SPOOL c:LSTSLCOLUMN8.LST
select substr(o.name,1,30) TABLE_NAME,
c.col# COLUMN_ID,
decode(sign(c.null$),-1,'D', 0, 'Y', 'N') NULLABLE,
substr(c.name,1,30) COLUMN_NAME,
decode(c.type#, 1, 'VARCHAR2',
2, decode(c.scale, null,
decode(c.precision#, null, 'NUMBER', 'FLOAT'),
'NUMBER'),
8, 'LONG', 9, 'VARCHAR',
12, 'DATE', 23, 'RAW', 24, 'LONG RAW',
69, 'ROWID',96,'CHAR', 105, 'MLSLABEL',
106, 'MLSLABEL', 'UNDEFINED') DATA_TYPE,
c.length DATA_LENGTH,
c.precision# DATA_PRECISION,
c.scale DATA_SCALE,
substr(co.comment$,1,150) COL_COMMENT
from sys.col$ c, sys.obj$ o, sys.com$ co
where o.obj# = c.obj#
and o.owner# = userenv('SCHEMAID')
and c.obj# = co.obj#(+)
HOME: http://www.itpub.net MAIL: epub@itpub.net
24. ITPUB µç×ÓÔÓÖ¾ ¼¸¸ö³£Óýű¾
and c.col# = co.col#(+)
and o.type# in (1,2,3,4,5)
order by o.type#,o.name,c.col#;
SPOOL OFF
¶þ¡¢È¡µÃ±í£¨ÁУ©×¢ÊÍ£¬²¢Éú³ÉÖؽ¨½Å±¾µÄ½Å±¾
Èç¹ûÔÚΪÓû§¿ª·¢Ò»¸öÓ¦Ó㬿ªÊ¼Îĵµ²»½¡È«£¨Êµ¼
¸øÆäËûÓû§£¬²¢Ö𽥹淶ÆðÀ´µÄ»°¾ÍÓÐÓÃÁË¡£
1.È¡µÃ±í×¢ÊÍ
COMMGETT.SQL
SET LONG 180
SET LINE 255
SET ARRAY 20
SET PAGES 0
SET FEED OFF
SPOOL C:LSTSCOMMSETT.SQL
SELECT 'SPOOL COMMSETT.ERR' FROM DUAL;
SELECT 'COMMENT ON TABLE',
TABLE_NAME,
'IS',
'''',
SUBSTR(COMMENTS,1,150),
'''',
';'
FROM USER_TAB_COMMENTS
WHERE TABLE_TYPE='TABLE'
ORDER BY TABLE_NAME;
SELECT 'SPOOL OFF' FROM DUAL;
SPOOL OFF
2.È¡µÃÁÐ×¢ÊÍ
COMMGETC.SQL
SET LONG 180
SET LINE 255
SET ARRAY 20
SET PAGES 0
SET FEED OFF
SPOOL C:LSTSCOMMSETC.SQL
SELECT 'SPOOL COMMSETC.ERR' FROM DUAL;
SELECT 'COMMENT ON COLUMN',
LPAD(SUBSTR(A.TNAME,1,30),30),
'.',
SUBSTR(A.CNAME,1,30),
'IS',
HOME: http://www.itpub.net MAIL: epub@itpub.net
25. ITPUB µç×ÓÔÓÖ¾ ¼¸¸ö³£Óýű¾
'''',
SUBSTR(A.REMARKS,1,150),
'''',
';'
FROM COL A,
TAB B
WHERE A.TNAME=B.TNAME
AND B.TABTYPE='TABLE'
ORDER BY A.TNAME,A.CNAME;
SELECT 'SPOOL OFF' FROM DUAL;
SPOOL OFF
Èý¡¢Öؽ¨Óû§Ë÷ÒýµÄ½Å±¾
INDXGET7.SQL
SPOOL C:LSTSINDXCRA.SQL
Select 'create '||
decode(rtrim(i.uniqueness),'UNIQUE','unique index ','index ')||
rtrim(i.index_name)||
' on '||
rtrim(decode(i.table_owner,user,'',table_owner||'.'))||
rtrim(i.table_name)||
'('||
max(decode(c.column_position,1,rtrim(c.column_name),null))||
max(decode(c.column_position,2,','||rtrim(c.column_name),null))||
max(decode(c.column_position,3,','||rtrim(c.column_name),null))||
max(decode(c.column_position,4,','||rtrim(c.column_name),null))||
max(decode(c.column_position,5,','||rtrim(c.column_name),null))||
max(decode(c.column_position,6,','||rtrim(c.column_name),null))||
max(decode(c.column_position,7,','||rtrim(c.column_name),null))||
max(decode(c.column_position,8,','||rtrim(c.column_name),null))||
max(decode(c.column_position,9,','||rtrim(c.column_name),null))||
max(decode(c.column_position,10,','||rtrim(c.column_name),null))||
');'
from user_indexes i, user_ind_columns c
where i.index_name = c.index_name
group by i.index_name,i.table_owner,i.table_name,i.uniqueness;
SPOOL OFF
ËÄ¡¢Öؽ¨Óû§Í¬Òå´ÊµÄ½Å±¾
SYNOGET7.SQL
SPOOL C:LSTSSYNOCRA.SQL
Select 'create synonym '||synonym_name||' for '||
decode(table_owner,user,'',table_owner||'.')||table_name||';'
from user_synonyms;
HOME: http://www.itpub.net MAIL: epub@itpub.net
26. ITPUB µç×ÓÔÓÖ¾ ¼¸¸ö³£Óýű¾
SPOOL OFF
Îå¡¢ÁгöÓû§ËùÓÐ±í¡¢ÊÓͼ¡¢ÐòÁнű¾
LSTTVS7.SQL
set line 30;
SET PAGES 0;
SPOOL C:LSTSUERTAB.LST;
SELECT TNAME FROM TAB WHERE TABTYPE='TABLE';
SPOOL OFF
SPOOL C:LSTSUSRVEW.LST;
SELECT TNAME FROM TAB WHERE TABTYPE='VIEW';
SPOOL OFF
SPOOL C:LSTSUSRSEQ.LST;
SELECT OBJECT_NAME FROM OBJ WHERE OBJECT_TYPE='SEQUENCE';
SPOOL OFF
ÒÔÉÏ£¬Ï£Íû¶Ô
IT PUB µÄÐËÍúÓй±Ïס£
SEAN 20020109
seanf@sohu.com
HOME: http://www.itpub.net MAIL: epub@itpub.net
27. ITPUB µç×ÓÔÓÖ¾ Developer2000 ϵÁн²×ùÖ®¶þ
Deveoper2000 ϵÁн²×ùÖ®¶þ
Developer2000 µÄ°²×°ºÍ¹¹³É
×÷Õß÷ÂíÀï
£º
Ë
Ò» ¼þºÍÈí¼þÐèÇó
. Ó²
win95,win98 »òÕß
winnt(service pack 5 »òÒÔÉÏ
)
128M ÄÚ´æ×ö¿ª·¢£¬Èç¹û
runtime »·¾³£¬ÔòÈ¡¾öÓںܶàÒòËØ£¬
IBM ¼°Æä¼æÈÝ»úÉÏ
¶þ
. Ïà¹ØÈí¼þ
1. Êý¾Ý¿âÈí¼þ
. Oracle8,Oracle8i,ÐèÒª for windows
net8
»òÕß
personal oracle »òÕß
personal oracle lite£¬ÄãÒ²¿ÉÒÔͨ¹ý
ODBC Á¬½Ó·Ç
oracle
Êý¾Ý¿â¡£
2. Web Server
ÈçûÄã´òËã°ÑÄãµÄÓ¦ÓóÌÐò·¢²¼ÔÚÍøÉÏ
¹ (Èý²ã¼Ü¹¹
)£ÄãÐèÒª°²×°Ò»¸ö
¬ Webserver ×öΪ
¼àÌýÆ÷¡£Èç¹ûÑ¡Ôñ·½±ãµÄ»°£¬Ê¹ÓÃ
oracle ×Ô¼º´øµÄ
oracle webDB Linstener£¬µ«ÆäËü
ÈκÎÒ»¸ö ¶¼ÄÜʹÓáÈç¹ûʹÓÃ
webserver £
OAS(oracle application server),ÔòÐèÒª
4.0.8
ÒÔÉÏ°æ±¾¡£
Èý
. ORACLE_HOME µÄÑ¡ÔñÎÊÌâ¡£
(Õâ¸öÎÊÌⱻѯÎÊÁ˷dz£¶à´ÎÁË£¬Õâ¸ö×ö
)
Oracle µÄ²úÆ·¶¼±»Éè¼Æµ½Ò»¸ö
Oracle_home Ï¡£
°²×° Form Developer ʱ£¬Äã±ØÐëÑ¡ÔñÒ»¸ö
Oracle Oracle Home£¬µ«Òª×ñÑ-Èçϼ¸µã£
1. Form Developer6i ±ØÐë±»°²×°ÔÚÒ»¸öĬÈϵÄ
ORACLE_HOME ÖÐ
2. Èç¹û Developer Óë
Form Oracle8/8i server ·ÅÔÚһ̨»úÆ÷ÉϵÄʱºò±ØÐë±
²»Í¬µÄ
ORACLE_HOME ÖС£
3. ͬÑù£¬Èç¹û
Form Developer Óë ·ÅÔÚͬһ̨»úÆ÷ÉϵÄʱºò±ØÐë±
OAS
µÄ
ORACLE_HOME ÖÐ
Èç¹ûÄã´òËã°²×°¼¸¸ö
Form Developer£¬Äã±ØÐë×¢ÒâÒÔϼ¸µã£º
1£®
Oracle Developer 1.6.1 ºÍ
Form Developer 6i ÄÜͬʱװÔÚͬһ¸ö
ORACLE_HOME ÖÐ
2£®
Oracle Developer 2.1 ºÍ
Form Developer 6i ÄÜͬʱװÔÚͬһ¸ö
ORACLE_HOME ÖÐ
3£®
Oracle Developer 1.6.1 ºÍ
Oracle Developer 2.1 ²»ÄÜͬʱװÔÚͬһ¸ö
ORACLE_HOME ÖÐ
4£®
Form Developer 6.0 ºÍ
Form Developer 6i ²»ÄÜͬʱװÔÚͬһ¸ö
ORACLE_HOME ÖÐ
ËÄ
. ¿ª·¢Èí¼þµÄʱºòÊDzÉÓÃ
C/S ¼Ü¹¹»¹ÊÇÈý²ã£¿
ÄãÐèÒª°²×°Á½ÖÖ»·¾³£º
1£®
Éè¼Æ»·¾³
2£®
ÔËÐл·¾³
web ÔËÐл·¾³
HOME: http://www.itpub.net MAIL: epub@itpub.net
28. ITPUB µç×ÓÔÓÖ¾ Developer2000 ϵÁн²×ùÖ®¶þ
/·þÎñÆ÷ÔËÐл·¾³
¿Í»§
Îå
. °²×°
ÕâÀïÎÒÃǽéÉܵÄÊÇ´Ó ÏÂÔØµÄ Developer6i¸ø´ó¼Ò¼òÂÔ½éÉÜ
http://otn.oracle.com Forms
Ò»ÏÂÈí¼þµÄ°²×°¡£
Ö´ÐРϵÄ
D2K setup.exe,Èç¹ûÊǵÚÒ»´Î°²×°£¬³öÏÖÈçÏÂÆÁÄ»
ÓÉÓÚ
English ÔÚÒÔºóµÄ±íÊö¸üΪ·½±ãºÍÇå³þ£¬²»ÖÁÓÚÒýÆðÎó»á£¬
English¡£
°´È·¶¨£¬ÎÒÃǽøÈëÏÂÒ»²½
ÈÃÄãÑ¡ÔñÀïÃæµÄ²úÆ·£¬Èç¹ûÎÒÃÇÐèҪװ
Form ¿ª·¢»·¾³µÄ»°£¬ÎÒÃÇÑ¡µÚÒ»ÏÈ
ÓóÌÐòתÒƵ½ÍøÉÏ£¨Èý²ã½á¹¹£©ÎÒÃÇÒª°²×°
Oracle Forms Server£¬¹ØÓÚÈçºÎ°ÑÓ¦ÓóÌÐò×
ÒƵ½ÍøÉÏ£¬ÎÒÃÇÏÂÃ潫רÃÅ»®³öÒ»ÕÂ×ö½éÉÜ£¬ÕâÀïÎÒÃÇÑ¡
Oracle Forms Developer¡£
°´ ½øÈëÏÂÒ»²½¡£
OK
HOME: http://www.itpub.net MAIL: epub@itpub.net
29. ITPUB µç×ÓÔÓÖ¾ Developer2000 ϵÁн²×ùÖ®¶þ
ÕâÒ»²½Èôó¼ÒÑ¡Ôñ°²×°µÄÀàÐÍ£¬Èç¹ûÄã¶Ô Typical
Forms Developer ÖеÄ×é¼þ²»ÊìϤ£¬ÇëÑ¡Ôñ
°²×°£¬Èç¹ûÄãÏ붨ÖÃ
Forms Developer µÄ»°£¬¶øÄúÓÖ¶Ô ×é¼þÓÖÊìϤµÄ»°£¬
Forms Developer
¿ÉÒÔ½øÐж¨Öã¬ÕâÀïÎÒÃÇÑ¡ÓÃ
Typical£¬°´
OK£¬½øÈëÏÂÒ»²½£¬
ÕâÒ»²½ÊÇÈÃÄãÊÇ·ñÊÔÓÃÒ»ÏÂ
Forms Server, ÓÉÓÚÄ¿Ç°ÎÒÃDz»×¼±¸¼Ü¹»Èý²ã½á¹¹
Ôñ £¬°´
NO OK£¬½øÈëÏÂÒ»²½
ÏÂÃæÎÒÃǾͽøÈëÁËÕýʽµÄ°²×°£¬ÔÚÇ°Ãæ»áÌø³ö¼¸¸ö¶Ô»°¿
ÇóµÄһЩÉèÖã¬ÎÒÃǶ¼°´
OK ¼´¿É¡£
ÓàÏµĹ¤×÷¾ÍÊǵȴýµçÄÔ°²×°Íê³É¡£
Ok,Ò»ÇÐ
¸ã¶¨£¬ÏÂÃæµÄÒ»²½¾ÍÊÇÓëÊý¾Ý¿â½¨Á¢Á¬½Ó¡£
HOME: http://www.itpub.net MAIL: epub@itpub.net
30. ITPUB µç×ÓÔÓÖ¾ Developer2000 ϵÁн²×ùÖ®¶þ
µã»÷ Net8 Easy Config£¬´ò¿ªÅäÖô°¿Ú£¬ÈçÏÂͼËùʾ£º
Oracle
ÔÚÕâÀïÎÒÃÇÊÇÔö¼ÓÒ»¸ö
Service Name(ÓÖ½ÐÊý¾Ý¿â±ðÃû
)£¬ËùÒÔÑ¡ Service£¬Ãû³ÆÎÒ
Add New
ÃǶ¨Îª
server£¬°´ ½øÈëÏÂÒ»²½
next
HOME: http://www.itpub.net MAIL: epub@itpub.net
31. ITPUB µç×ÓÔÓÖ¾ Developer2000 ϵÁн²×ùÖ®¶þ
ÔÚÕâÀïÑ¡Ôñͨ¹ýÄÄÖÖÍøÂçÐ-ÒéÓëÊý¾Ý¿â·þÎñÆ÷½øÐÐͨѶ¡£µ±È»ÕâÖÖÐ-Òéͨ³£ÒªÏÈ°²×°º
ÀïÎÒÃÇÑ¡Ôñ×î³£ÓÃµÄ Ð-Òé¡£
TCP/IP
ÏÂÃæÌîÈëÊý¾Ý¿âËùÔÚ·þÎñÆ÷µÄ
IP µØÖ·ºÍͨѶ¶Ë¿Ú£¨
Oracle ĬÈϵÄΪ
1521£©
ÕâÀïÎÒÃǶ¨ÒåÒªÁ¬½ÓµÄÿһ¸ö
oracle Êý¾Ý¿âµÄ
SID £¬ SID È·¶¨Ò»¸ö
oracle Êý¾Ý¿âʵÀý¡£
ORCL
ÊÇĬÈÏÖµ£¬ÓÉÓÚ×÷ÕßÕâÀïʹÓõÄÊý¾Ý¿âÊÇÁíÍâµÄÃû³Æ£¬Ë
µã
next£¬½øÈë²âÊÔÒ³Ã棬Èç¹ûÎÒÃÇ·ÅÐĵĻ°£¬Ö±½Ó°´
next ºó
Finished Íê³ÉÉèÖá£
Èç¹ûÐèÒª²âÊԵĻ°£¬µã»÷
test£¬ÊäÈëÊý¾Ý¿âÓû§ÃûºÍÃÜÂ룬½øÐÐÁ¬½Ó²â
ºóÐ޸ġ£
Ok,Ò»Ì× Developer ÒѾ-°²×°ºÃÁË¡£
Form
´ó¼Ò¿ÉÒÔ¼ÌÐø°²×°Ò»Ì×
Report Developer£¬ÓÃÀ´ÖÆ×÷±¨±íµÄ¹¤¾ß¡£¨ÏµÁн²×ù
Form
£
ÉÏ£¬ ½«ÔÚ ½²×ùÍêÁ˺óд£©
Report Form
£¨°²×°Íê³Éºó
oracle Developer µÄ´ó²¿·Ö×é¼þÒѾ-°²×°ÉÏÁË£©
Áù
. ˵˵ developer
oracle
ʵ¼ÊÉÏÎÒÃÇËù˵µÄ°æ±¾Ó¦¸ÃÊÇ
Oracle Developer 6i£¬«ÎªÁËÑØÓôó¼ÒµÄÏ°¹ß
µ £¬¹ÊdzÆΪ
»
HOME: http://www.itpub.net MAIL: epub@itpub.net
32. ITPUB µç×ÓÔÓÖ¾ Developer2000 ϵÁн²×ùÖ®¶þ
Developer2000
Ëü°üº¬ÈçÏÂ×é¼þ
£º
¡ñ
Project Builder£ºÉÒÔ·½±ãµÄ°ïÖúÄãÔÚÕû¸öÈí¼þµÄ¿ª
¿ ·¢ÖÜÆÚÖй¤×÷¡£¿ÉÒÔÀûÓÃËûµ
·Ç³£ÈÝÒ׵ĽøÈëÕû¸öÏîÄ¿µÄÎļþ²¢¶ÔËüÃǵĸı䡣¿ÉÒÔ×
Ðò¡£ÀûÓÃÕâ¸ö¹¤¾ß¶ÔÄãÉú³ÉµÄÏîÄ¿´ò°ü
£¬²×°µ½ÆäËü»úÆ÷ÉÏ¡£
°
¡ñ Builder£ºâÌ×¹¤¾ßÄÜ°ïÖú´ó¼ÒÉú³ÉÍêÉƵĽ»»¥Ê½µÄÓ¦Óó
Form Õ Form Builder ÄÜͨ¹ý
Îı¾£¬Í¼ÐÎÓû§½çÃ棬ͼÐÎÕ¹ÏÖÐÅÏ¢¡£ÓÐÏòµ¼ÄÜ°ïÖú´ó¼Ò
Form
Builder Ç¿´óµÄÌØÐÔÌá¸ßÓ¦ÓóÌÐòµÄÏÔʾºÍ¹¦ÄÜ¡£
¡ñ
Report Builder£ºâ¸ö¹¤¾ßÄÜ°ïÖúÄã·Ç³£·½±ãµÄÉú³ÉÇ¿´óµÄ±¨±í
Õ £¬
¡ñ
Graphics Builder£ºâ¸ö¹¤¾ßÄÜ°ïÖú´ó¼ÒÉú³É¸÷ÖÖͼ±í
Õ
¡ñ
Schema Builder£ºÉÓÃͼÐÎÓû§·½Ê½Éú³ÉÓû§¶ÔÏóºÍËüÃǵĹØϵ
²
¡ñ
Query Builder£º¹ÓÃ
Ê ReportBuilder µÄʱºòʹÓÃ
£¬¼ÐÎÓû§½çÃæ¿ÉÒÔ·½±ãµÄ´ÓÊý
Í
µÃËùÒªµÄÊý¾Ý¡£
¡ñ
Procedure Builder£ºÚ
Ô Form,Report,Graphics Öо-³£Óõ½
£¬ÃÀ´Éú³ÉÐ޸ijÌÐòµ¥Ôª¡£
Ó
¡ñ
Translation Builder£ºÜÀíÓ¦ÓóÌÐò½Ó¿ÚµÄÎı¾×ª»»
¹ £¬ÉÒÔÀûÓÃÕâ¸ö¹¤¾ßת»»Ó¦Óó
¿
¶à¸öÓïÑÔ
£¡
ÏÂÒ»½²ÎÒÃǽ«Õýʽ½øÈë
Developer2000 µÄ±à³ÌÊÀ½ç¡£
½²Êö Developer Êý¾Ý¿é
Form £¬
Frame
ºÍ item¡£
Text
HOME: http://www.itpub.net MAIL: epub@itpub.net
33. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
Åàѵ£º001 Lesson 1-10
: easyfree
×÷Õß
Lession1 Selecting Rows
* RELATIONSHIPS
Solid Line = Must Be
Dashed Line = May Be
Single Line = One and Only One
Crow's foot = One or More
UID = #
Secondary UID = ( # )
Mandatory attribute = ( * )
Optional Attribute = ( o )
* An SQL command is entered at the SQL prompt, and subsequent lines are numbered.
This is called the SQL buffer. £-¿ÉÓжà¸ö plus Óï¾ä
buffer ´æÖü
* Only one statement can be current at any time within the buffer, and the statement can
be executed in a number of ways: (Öصã )
Place a semicolon at the end of last clause.
Place a semicolon or slash on the last line in the buffer.
Place a slash at the SQL prompt.
Issue a SQL*Plus RUN command at the SQL prompt.
* Character and date column headings and data are left-justified within a column and
numbers are right-justified. Character and date column headings may be truncated, but
number headings may not be truncated. The column labels appear in uppercase by default.
You can override the column label display with an alias. £¨Øµã
Ö £¬×¢Ò⣺½öÊý×ÖÊÇÓÒ¶Ô
µÄ£¬¶øÇÒ±£ÁôÍêÕûµÄ heading£©
* SQL*Plus ignores blank spaces before and after the arithmetic operator.
* By default, alias headings will be forced to uppercase and cannot contain blank spaces
and special characters (such as # or $), unless the alias is enclosed in double quotation
marks (“ ).
”
* You can include the AS keyword before the alias name to comply with ANSI SQL 92
standards.
HOME: http://www.itpub.net MAIL: epub@itpub.net
34. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
* ¹ØÓÚ±ðÃûµÄʹÓã¨
Öصã
££
©º
1. Ò»µ©ÔÚ Öж¨ÒåÁ˱í±ðÃû£¬ÔòÔÚÕû¸ö
WHERE SELECT Óï¾äÖв»ÄÜÔÙʹÓñíÔ-Ãû
2. where,group by ×Ó¾äÖпÉÒÔʹÓñí±ðÃû£¬µ«²»ÄÜʹÓÃÁбðÃû
3. order by ×Ó¾äÖпÉÒÔʹÓÃÁбðÃû
£¬µ«²»ÄÜÓбíÃûǰ׺£¬²»ÄÜʹÓ㺱
.ÁбðÃû£¬
µ«¿ÉÒÔʹÓ㺱í±ðÃû
.ÁÐÔ-Ãû
4. ±í±ðÃû¿ÉÒÔÓëÁбðÃûÏàͬ
* A literal is any character, expression, or number included in the SELECT list that is not a
column name or a column alias. --¿ÉÒÔÀí½âΪ³ýÁË×Ö¶ÎÃû£¨°üÀ¨±ðÃû£©
·û¡¢Êý×Ö¡¢±í´ïʽ£©
* Currently, Oracle treats a character value with length of zero as null. However, this may
not continue to be true in future versions of Oracle. -- 8i Öл¹Ã»Óиı䣬 ''ÈÔÈ»ÊÓΪ null
´¦Àí
* You can use the NVL function to convert any datatype, but the return value is always the
same as the datatype of expr1. -- ³ý·Ç¿ÉÒÔÒþº¬×Ô¶¯×ª»»µÄÀàÐÍ£¬±ÈÈçÊ
* In SQL*Plus, you can display the structure of a table using the DESCRIBE command. The
result of the command is to see the column names, datatypes, and whether a column must
contain data(null or not null). £¨Øµã
Ö £©
* You terminate the SQL buffer by either entering one of the terminator characters
(semicolon or slash), or pressing [RETURN] twice. You will now see the SQL prompt. (Öصã
)
* SQLPLUS Command : 0 text Inserts a line before line 1.
* SPO[OL] [filename[.ext]|OFF|OUT] Stores query results in a file, OFF closes the spool
file. OUT closes the spool file and sends the file results to the system printer. (Öصã
)
* COLUMN ÃüÁ
JUS[TIFY] {align} Justifies the column heading (not the data) to be left, center, or
right.
NOPRI[NT] Hides the column.
NUL[L] text Specifies text to be displayed for null values.
PRI[NT] Shows the column.
TRU[NCATED] Truncates the string at the end of the first line of display. £-Óë
wrap
¶ÔÓ¦£¬¸ù¾ÝÁпí½Ø¶Ï
HOME: http://www.itpub.net MAIL: epub@itpub.net
35. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
WRA[PPED] Wraps the end of the string to the next line.
WOR[D_WRAPPED] Same as WRAPPED, but ensures that words do not split. £-ÔÚÖÐÎÄ
×Ö·û¼¯ÏµĴ¦Àí£¬Ò²ÊÇÒÔ¿Õ¸ñÇø·Ö
L Represents local currency. L9999 £-Óë
nls_currency µÄÉ趨
Ïà¹Ø
*
COL[UMN] column Displays the current settings for the specified column.
COL[UMN] Displays the current settings for all columns.
COL[UMN] column CLE[AR] Clears the settings for the specified column.
CLE[AR] COL[UMN] Clears the settings for all columns.
* The selection capability in SQL allows you to choose rows in a table to be returned by a
query. You can restrict the rows returned by selection using various criteria. The
projection capability in SQL allows you to choose columns in a table to be returned by a
query. You can control the number of columns returned by a query. Selection is often
considered horizontal partitioning, and projection is often considered vertical partitioning.
? SQL commands are not case sensitive, unless indicated.
Lession2 Limiting Selected Rows
* ORDER BY clause is last in SELECT command. £-£¨£©
Öصã
* If no ORDER BY clause, the Oracle7 Server may not fetch rows in the same order for the
same query twice. --ÓëÊý¾Ý´æÖüµÄ±ä»¯ÓйØ
* ASC orders the rows in ascending order. This is the default order.
* In Oracle7, null values are displayed last for ascending sequences and first for
descending sequences. -- 8i ÒÀÈ»ÊÇÕâ¸öÔ-Ôò£¨
Öص㠣©
* You can order by position to save time. -- ûÓвâÊÔ¹ý°´Î»ÖÃ
order by ÊÇ·ñ¿ÉÒÔ½ÚÊ¡ÔË
ÐÐʱ¼ä£¿
* Sort by position is especially useful when sorting by a long expression. Rather than typing
the expression again. £-±ðÃûÒ²¿ÉÒÔ½â¾öÎÊÌâ
* You can order by columns that are not in the SELECT list. --×¢ÒâÀýÍâÇé¿öÊÇ£ºÔÚ
SELECT
ÖÐʹÓÃÁË ºÍ×麯Êý
DISTINCT £¨Øµã
Ö £©
* Conditions consist of the following:
- Column name,expression,constant
HOME: http://www.itpub.net MAIL: epub@itpub.net
36. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
- Comparison operator
- Literal
* ...WHERE expr operator value : the expr cannot be an alias. £-²Î¼û µÄ¹ØÓÚ
Lession1
±ðÃûµÄÏÞÖÆ˵Ã÷
* SQL Operator Precedence ÓÅÏÈ´ÎÐòÖصã
£-£¨£©
1. Õý¸º- +
2. ³Ë³ý/ *
3. ¼Ó¼õ- ||
+
4. All comparison operators ±È½ÏÔËËã·û£º <> BETWEEN...AND... IN(list)
= < <= > >=
LIKE is(not) null
5. NOT
6. AND Âß¼-ÔËËã·û
7. OR
* = NULL that an error is not raised, the result is simply always FALSE.
* It may be faster and easier to eliminate rather than include. £-
?Åųý±È°üÀ¨Ëٶȿì
?Ðè
Òª²âÊÔ
* Search conditions can contain either literal characters or numbers.
* The % and _ symbols may be used in any combination with literal characters.
* When you need to have an exact match for the actual “ and “ characters, use the
%” _”
ESCAPE option. This option specifies what the ESCAPE character is.
? ÎÞ
ORDER BY ʱ
ORACLE ȱʡÓÃʲôÑùµÄ˳ÐòÏÔʾÊý¾Ý£¿
ROWID?
Lession3 Single Row Functions
* Functions are a very powerful feature of SQL and can be used to
Perform calculations on data.
Modify individual data items.
Manipulate output for groups of rows.
Alter date formats for display.
Convert column datatypes.
* An argument may be one of the following:
A user-supplied constant
A variable value
A column name
HOME: http://www.itpub.net MAIL: epub@itpub.net
37. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
An expression
* Features of Single Row Functions
They may expect one or more user arguments.
You can nest them.
You can use them in SELECT, WHERE, and ORDER BY clauses. --Ϊʲô²»Ð´£º
group
by?
* Lower(),Upper(): Converts alpha character
INITCAP(): Converts alpha character values to uppercase for the first letter of each
word, all other letters in lowercase.
CONCAT(): ͬ||
SUBSTR(column|expression,m[,n]): m ²»ÄÜȱʡ£¬ end, n=0 ·µØ
n ȱʡΪµ½ » null
NVL(column|expression1,column|expression2)£º
exp1 ºÍ
exp2 ±ØÐëͬÀàÐÍ£¬»òÕß¿ÉÒ
Òþº¬×ª»»
ROUND(column|expression,n)£º 0 »ò ²»Ö¸¶¨£¬Ôò
n£½ n round µ½ÕûÊýλ£»
n Ϊ¸ºÊý£¬Ôò
´ÓСÊýµãÆðÏò×ó±ß date at midnight.
round£» Round the
TRUNC(column|expression,n)£º 0 »ò ²»Ö¸¶¨£¬Ôò
n£½ n round µ½ÕûÊýλ£»
n Ϊ¸ºÊý£¬Ôò
´ÓСÊýµãÆðÏò×ó±ß
n λ trunc Ϊ0
NEXT_DAY(date,‘ )£º
char’ Finds the date of the next specified day of the week (‘ )
char’
following date. char may be a number representing a
day or a character string. (char ÔÚÓ¢ÎÄ×Ö·û¼¯Ï£¬ÓÃÈýλ±íʾ¼´¿É£¬È
mon, char ÊÇ
ºÍ×Ö·û¼¯Ïà¹ØµÄ£¿ÔÚÖÐÎÄ×Ö·û¼¯Ï¾ßÌåµÄ char ¸ñʽÈçºÎÑ°ÕÒ£¿
)
* Oracle stores dates in an internal numberic format. - Century, year, month, day,hours,
minutes, seconds.
* Default date display is DD-MON-YY. – ÓëCharacterSet ÉèÖÃÓйأ¬
nls_data_format,
nls_date_language
* Valid Oracle dates are between January 1, 4712 B.C. and December 31, 4712 A.D.
--Oracle8i Öв»ÖªÊÇ·ñ¸ü¸ÄÁË
?
* The DUAL table is owned by the user SYS and may be accessed by all users. It contains
one column, DUMMY, and one row with the value “X”
HOME: http://www.itpub.net MAIL: epub@itpub.net
38. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
* Add hours to a date by dividing the number of hours by 24. £-°´ÌìµÄ·½Ê½Ôö¼õ
* ÈÕÆÚÖµ¿ÉÒÔÖ±½Ó°´×Ö·ûÐÎʽ±È½Ï£¬±ÈÈ磺
WHERE start_date LIKE ’
%1991’ µ±È»ÓÚ
;
nls_date_format ÓйØ
* to_char(date): The names of days and months in the output are automatically padded
with blanks. To remove padded blanks or to suppress leading zeros, use the fill mode fm
element. The resultant column width is 80 characters by default. (×¢Ò⣺
8i ÖÐÒѾ-¸Ä±äÁË
²»ÊÇ )
80 ÁÐ
* TO_CHAR() format:
MONTH Name of month padded with blanks to length of 9 characters.
RM Roman numeral month.
DAY Name of day padded with blanks to length of 9 characters.
DY Name of day; 3-letter abbreviatio n.
Years in dates YYYY or SYYYY Year; S prefixes BC date with -.
SCC or CC Century; S prefixes BC date with -.
Q Quarter of year.
SSSSS Seconds past midnight (0-86399).
/., Punctuation is reproduced in the result.
“ the ” Quoted string is reproduced in the result.
of
TH Ordinal number (for example, DDTH for 4TH).
SP Spelled-out number (for example, DDSP for FOUR).
SPTH or THSP Spelled-out ordinal numbers (for example, DDSPTH for FOURTH).
L uses the floating local currency symbol set the NLS_CURRENCY parameter
MI Minus signs to right (negative values). 999999MI 1234-
PR Parenthesize negative numbers. 999999PR <1234>
EEEE Scientific notation (format must specify four Es). 99.999EEEE 1.234E+03
V Multiply by 10 n times (n= no of 9s after V). 9999V99 123400
B Display zero values as blank, not 0. B9999.99 1234.00
FM/fm Fill Mode ɾ³ýÇ°µ¼ 0 ºÍÓұߵĿոñ
FX Format Exact ¾«È·Æ¥Åä ORACLE Îĵµ
£-²Î¼û
* RR available in Oracle7, not Oracle Version 6.
* NLS parameters may be added to init.ora file to set default date formats and language
names and abbreviations. And you can use the dcl command: "Alter Session" to change it
in a session and can change it in register table in Windows system.
* The Oracle Server displays a string of pound signs (#) in place of a whole number whose
digits exceed the number of digits provided in the format model.
* Single row functions can be nested to any depth. Nested functions are evaluated from
the innermost level to the outermost level. ¿ÉÒÔǶÌ×ÈÎÒâ²ã´Î£¬Ö´ÐдÎÐò´ÓÄÚ
HOME: http://www.itpub.net MAIL: epub@itpub.net
39. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
£¿ÔÚÖÐÎÄ×Ö·û¼¯Ï¾ßÌåµÄ
char ¸ñʽÈçºÎÑ°ÕÒ£¿
Lession4 Displaying Data from Multiple Tables
* Cartesian Product µÑ¿¨¶ù³Ë»ý
* To join tables together, you need a minimum of the number of join conditions
summarized as the number of tables minus one. ×îÉÙµÄÁ¬½ÓÌõ¼þÊÇ ÖØ Á¬½Ó±íµÄ¸öÊý£-
1£¨
µã¿¼ÊÔÌâ may not apply if your table has a concatenated primary key, in which
£© rule
This
case more than one column is equired to uniquely identify each row. µ±ÓÐ×éºÏµÄÖ÷¼üʱ£¬
¸Õ²ÅµÄÔ-Ôò²»ÊÊÓã»
* Table aliases help to keep SQL code smaller, therefore using less memory.
* Once you use the table alias, you must continue to qualify every column reference with
the table alias. ±íÃûºÍ±í±ðÃû²»ÄÜͬʱʹÓã»particular table
If a table alias is used for a
name in the FROM clause, then that table alias must be substituted for the table name
hroughout the SELECT statement.
* Table aliases can be up to 30 characters in length. £-Öй涨£¿
8i
* The table alias is only valid for the current SELECT statement.
* A NON-EQUIJOIN's relationship is obtained using an operator other than equal (=).
£- ²»ÊÇʹÓÃ
=Á¬½ÓµÄ¾ÍÊǷǵÈÖµÁ¬½Ó
* Table aliases have been specified for performance reasons, not because of possible
ambiguity.
* (+) is placed on the “ side” the join that is deficient in information. (the side where
of
there is no value to join to, or which have no direct match in the other side , But not on
both sides. Place the outer join symbol following the name of the table without the
matching rows.)
* A condition involving an outer join may not use the IN operator or be linked to another
condition by the OR operator.
* Speed up database access with table ailiases.
? Additional join methods include the following:
HOME: http://www.itpub.net MAIL: epub@itpub.net
40. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
Outer joins
Self joins
Set operators ? update ?
? When writing a SELECT statement that joins tables, precede the column name with the
table name for clarity and to enhance database access. Äܹ»Ìá¸ßÓÅ»¯Æ÷µÄʹÓÃô£¿
? How to code with an outer join on both sides? This is possible with the UNION operator,
which is not addressed in this course.
Lession5 Group Functions
* ORACLE7 ÖÐÓÐ
7 ¸ö×麯Êý£»?????
£-ÖÐ
8i
* STDDEV() ±ê×¼·½²î£»
VARIANCE() ?
* COUNT(*)=COUNT(ROWID)=COUNT(1) ͳ¼Æ ºÍÖظ´µÄÖµ£»µ«
NULL COUNT(×Ö¶Î
)ͳ
¼Æ·Ç¿ÕÖµ
* MAX(),MIN() ºöÂÔ
NULL
* ×麯ÊýÖпÉÒÔʹÓÃALL ÊÇȱʡֵ£È磺 A),COUNT(ALL
DISTINCTºÍ
ALL£¬ COUNT(DISTINCT
»
A)£»
* The datatypes for the arguments may be CHAR, VARCHAR2, NUMBER, or DATE where
expr is listed. £-
? ???? 8i ÖÐÊÇ·ñÓб仯
?????
* You can use AVG and SUM functions against columns that store numeric data. You can
use MAX and MIN functions for any datatype.
* GROUP BY Clause Gidelines
Cannot select individual results as well unless the individual column appears in the
GROUP BY clause.
You cannot use the positional notation or column alias in the GROUP BY clause.
By default, rows are sorted by ascending order of the GROUP BY list. You can override
this by using the ORDER BY clause.
* The ORDER BY clause is always the last clause in a SELECT statement.
HOME: http://www.itpub.net MAIL: epub@itpub.net
41. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
Lession6 Subqueries
* You can place the subquery in a number of SQL command clauses:
WHERE clause
HAVING clause
FROM clause of a SELECT or DELETE statement
* Additionally, subqueries can be placed in the
CREATE VIEW statement,
CREATE TABLE statement,
CREATE SNAPSHOT statement,
UPDATE clause,
INTO clause of an INSERT statement,
SET clause of an UPDATE statement.
* A subquery executes once before the main query, and may execute multiple times in
correlated subqueries. --Ïà¹Ø×Ó²éѯÖÐÖ´Ðжà´Î
* Comparison operators fall into two classes: single row (>, =, >=, <, <>, <=) and
multiple row (IN, NOT IN) operators.
* The subquery generally executes first, and its output is used to complete the query
condition for the main or outer query.
* Subqueries Guidelines
Enclose a subquery within parentheses.
Place the subquery after the comparison operator.
Do not add an ORDER BY clause to a subquery. You can have only one ORDER BY
clause for a SELECT statement, and if specified, it must be the last clause in the main
SELECT statement.
Must appear on the right side of the operator.
* Single row subquery: =, >, <, >=, or <=. One common error with subqueries is more
than one row returned for a single row subquery.
* Multiple row subqueries: IN
* To produce a nonpairwise comparison in a multiple -column subquery, use a WHERE
clause with multiple conditions. A nonpairwise comparison produces a cross product.
HOME: http://www.itpub.net MAIL: epub@itpub.net
42. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
Lession7 Specifying Variable at Runtime
* In SQL*PLUS: ACCEPT reads a line of user input and stores it in a variable. DEFINE
creates and assigns a value to a variable.
* SQL*Plus does not support validation checks on user input.
* &user_variable: SQL*Plus discards a new variable once it is used. £-Èç¹ûʹÓÃ
&&£¬
SQLPLUS ½«¼ÇסʹÓÃÁË &&Ö®ºóͬÃû±äÁ¿µÄÖµ
* With the single ampersand, the user is prompted every time the command is executed.
* Setting SET VERIFY to ON forces SQL*Plus to display the text of a command before and
after it replaces substitution variables with values.
* ACCEPT variable [datatype][FORMAT][PROMPT text][HIDE]
HIDE suppresses what the user enters, for example a password.
* Both the ACCEPT and DEFINE commands will create a variable if the variable does not
exist; these commands will automatically redefine a variable if it exists.
* Use the ACCEPT command to:
Give a customized prompt when accepting user input. Otherwise, you will see the
default “ Enter value for variable.”
Explicitly define a NUMBER or DATE datatype variable.
Hide user input for security reasons.
* The ECHO variable controls whether START and @ commands list each command in a
command file as the command is executed.
* To define you wanted variables for every session, modify your login.sql file so that those
variables are created at startup.
* Reports can accept a maximum of nine parameters that are named from &1 to &9.
* SQL*Plus retains report parameters and their values until you redefine them, undefine
them, or terminate your SQL*Plus session.
* Without the single quotes encl sing the variable value an invalid column name error
o
occurs.
HOME: http://www.itpub.net MAIL: epub@itpub.net
43. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
Lession8 Overview of data Modeling and Database Design
* System Development Cycle
1. Strategy and Analysis
2. Design
3. Build and Document
4. Transition
5. Production
* Entity relationship models are derived from business specifications or narratives.
* Component Description
-------------------------------------------------------------
Entity A thing of significance about which information needs to be known.
Attribute Something that describes or qualifies an entity.
Relationship A named association between entities showing optionality or
degree.
* One-to-one Degree of one and only one in both directions. These types are rare,
and may really be the same entity, or an attribute of the entity.
Many-to-one Degree of one or more in one direction and a degree of one and
only one in the other direction. Very common.
Many-to-many Degree of one or more in both directions. Very common. Resolve
them with an intersection entity.
* First normal form (1NF) All attributes must be single-valued and not repeating.
Second normal form (2NF) An attribute must depend upon its entity’ entire
s
unique identifier.
Third normal form (3NF) No non-UID attribute can be dependent upon another
non-UID attribute.
* Integrity Constraint Type Description
----------------------------------------------------------------
Entity No part of a primary key can be NULL and the value must
be unique.
Referential Foreign key values must match a primary key or be NULL.
Column Values in the column must match the defined datatype.
HOME: http://www.itpub.net MAIL: epub@itpub.net
44. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
User-defined Values must comply with the business rules.
* A primary key consisting of multiple columns is called a composite primary key or a
compound primary key.
* A foreign key (FK) is a column or combination of columns in one table that refers to a
primary key or unique key in the same table or in another table.
* Database Design Steps
1. Map the Entities to Tables
2. Map the Attributes to Columns: Map mandatory attributes, tagged with an asterisk
(*), to columns defined as NOT NULL (NN).
3. Map the Unique Identifiers to Primary Keys: symbol (#) to primary key columns and
label the key type as PK.
4. Map relationship to foreign keys.
Lession9 Creating Tables
* When create table, you can use $, _, # , number for table name and column name, must
start with character (Öصã
)
* Tables can have up to 254 columns and must conform to standard database object
naming conventions. -- 8i ÖÐûÓÐÏÞÖÆ
* A schema is a collection of objects. Schema objects are the logical structures that directly
refer to the data in a database. Schema objects include tables, views, synonyms,
sequences, stored procedures, indexes, clusters, and database links.
* The default value can be a literal, an expression, or SQL function, such as SYSDATE and
USER, but the value cannot be the name of another column or a pseudocolumn, such as
NEXTVAL or CURRVAL. The default expression must match the datatype of the column.
* The basic datatypes are character, number, date, and RAW. --8i ÖÐÔö¼ÓÁË
????
* If not refered, default values are available (38 for NUMBER and 1 for CHAR).
* If you do not name your constraint, Oracle7 generates a name with the format SYS_Cn,
where n is an integer to create a unique constraint name.
HOME: http://www.itpub.net MAIL: epub@itpub.net
45. ITPUB µç×ÓÔÓÖ¾ Åàѵ£ºLesson 1-10
001
* Null values are allowed if the unique key is based on a single column.
* UNIQUE indexes are created automatically when you create PRIMARY KEY and UNIQUE
constraints.
* A foreign key that is part of a primary key cannot be a null value because no part of a
primary key can be NULL.
* FOREIGN KEY: Without the ON DELETE CASCADE option, the row in the parent table
cannot be deleted if it is referenced in the chil department.
* The CHECK constraint defines a condition that each row must satisfy. The condition can
use the same constructs as query conditions, with the following exceptions:
References to the CURRVAL, NEXTVAL, LEVEL, or ROWNUM pseudocolumns
Calls to SYSDATE, UID, USER, or USERENV functions
Queries that refer to other values in other rows
* CHECK constraints can be defined at the column-constraint level or table-constraint level.
The constraint syntax can apply to any column in the table, not only on the column on
which it is defined. --±í¼¶¶¨ÒåCHECK ʱ£¬¿ÉÒÔ¶Ô¶àÁÐ×éºÏ¶¨Ò壬È磺 CHECK (A+B=10)
* CTAS = CREATE TABLE AS SELECT
The column definition can contain only the column name, default value, and integrity
constraints, not the datatype or referential integrity constraint.
Only the NOT NULL constraint is inherited from the subquery table to corresponding
columns in the new table.
* ×¢ÒⶨÒå
CONSTRAINTS µÄÓï·¨£¬ÔÚ×ֶ춶¨Òåʱ·ÅÔÚ¡°£¡±Ç°Ã棬
¬
×îºóÒ»¸ö×ֶζ¨Òå½áÊøµÄ¡°£¡±ºóÃæºÍ±í¶¨Òå¡°£¡±Ç°Ãæ£
¬ CONSTRAINTS ÒÔ¡°£¡±·Ö¿ª
¬. ©
* The ENABLE clause can be used in the ALTER TABLE and CREATE TABLE commands.
* The keywords PRIVATE and OR REPLACE are invalid when creating a synonym. Triggers
may be enabled using the ENABLE clause in the ALTER TABLE command.
* By creating a public synonym for the table owned by user, you have eliminated the need
to qualify an object name with its schema name. The CREATE PUBLIC SYNONYM
statement makes a synonym accessible to all users. -- ¶ÔÓû§×ÔÉíÓµÓÐµÄ±í½¨Á¢Í
ʱ£¬ÐèҪȥ³ý SCHEMA ǰ׺
HOME: http://www.itpub.net MAIL: epub@itpub.net