Oracle 10gѧϰµãµÎ
°²×°ÍêOracle 10g£¬sql*plusµÇ½
"Óû§Ãû³Æ£¨U£©:"ÖÐÊäÈë'system'
"¿ÚÁP£©:"ÖÐÊäÈë'manager'
"Ö÷»ú×Ö·û´®£¨H£©:" tnsname.oraÖÐÅäÖõķþÎñÃû(Èç¹ûÊÇϵͳĬÈÏÊý¾Ý¿â¿ÉÒÔ²»ÊäÈë)
(×¢1£ºÕâ¸öÓû§Ãû/ÃÜÂëÊÇÔÚ°²×°¹ý³ÌÖÐ×Ô¼ºÉ趨µÄ)
(×¢2: Èç¹ûÉÏÊö²Ù×÷Å׳öûÓмàÌýÆ÷£¬ÔòÐè¿´×Ô¼ºÓÐûÌí¼Ó¼àÌýÆ÷£¬Èç¹ûÌí¼ÓÁËÔÚ·þÎñÖп´ÓÐûÆô¶¯)
¸ü¸Äscott/tigerȨÏÞ
1£©ÒÔsys»òsystemµÇ½
sys怫: conn / as sysdba
systemµÇ½£º conn system/manager
//unlock scott
2) alter user scott account unlock;
3) ÇåÆÁ
clear screen
4£©ÄÚÁª½ÓºÍÍâÁª½Ó ±ít_user£¬t_salary
ÄÚÁª½Ó
select t_user.user_name t_salary.salary
from t_user,t_salary
where t_user.user_id = t_salary.user_id
ÍâÁª½Ó t_userÍâÁ¬½Ót_salary
select t_user.user_name t_salary.salary
from t_user,t_salary
where t_user.user_id = t_salary.user_id£¨+£©
5)ÊÓͼ
create or replace view usview
as select u.user u, s.salary
from t_user u, t_salary s
where u.user_id = s.user_id
with read only;
×¢: ¶ÔÓÚʹÓÃINSERT, UPDATE,DELETE ÕâÑùµÄDMLÓï¾ä´æÔÚһЩÏÞÖÆ¡£¼´Ê¹²»¶¨Òåwith read only;Ö´ÐÐÕâЩ²Ù×÷ʱҲ
²»Ò»¶¨³É¹¦¡£ÄÜ·ñÔÚÊÓͼÉϳɹ¦Ö´ÐÐINSERT,UPDATE,DELETEÓï¾äÊÜÊÓͼ¶¨Òå¼°»ù±íµÄÏÞÖÆ¡£ÈçÊÓͼ¶¨ÒåÔÚÒ»¸ö±í»¹ÊǶà
¸ö±íÉÏ£¬±»ÒýÓûù±íÁеÄÐÔÖÊ(NULL£¬NOT NULL£©µÈ¡£
Ö´ÐÐdrop view usview¿Éɾ³ýÊÓͼ
6£©spoolÊä³ö
spool d:\tst.sql
select * from t_user
spool off
7£©SET TERMOUT ON/OFF ¿ØÖÆÊÇ·ñÏÔʾִÐÐSQLÓï¾äµÄÊä³ö½á¹û¡£Ä¬ÈÏÊÇON£¨ÏÔʾ£©
edit d:\tst.sql »á´ò¿ªd:\tst.sql ÄܽøÐбà¼
@d:\tst.sql»áÖ´ÐÐ tst.sqlÖеÄÄÚÈÝ
8£©ÈçºÎ´Ósql*blusÖÐÍ˳ö
ÊäÈë . ¼´¿É
/±íʾִÐÐÍê³É¡£
9£©ÉùÃ÷ºÍʹÓÃÓαê
ÔÚPL/SQL³ÌÐòÄÚʹÓÃÏÔʾÓαêµÄ²½Öè:
1£©ÉùÃ÷Óαê
2£©´ò¿ªÓαê
3£©´ÓÓαêÖÐÈ¡³öÐÐ
4£©¹Ø±ÕÓαê
Àý×Ó£º
SET SERVEROUT ON
DECLARE
--²½Öè1£ºÉùÃ÷
Ïà¹ØÎĵµ£º
CUBE ºÍ ROLLUP Ö®¼äµÄÇø±ðÔÚÓÚ£º
CUBE Éú³ÉµÄ½á¹û¼¯ÏÔʾÁËËùÑ¡ÁÐÖÐÖµµÄËùÓÐ×éºÏµÄ¾ÛºÏ¡£
ROLLUP Éú³ÉµÄ½á¹û¼¯ÏÔʾÁËËùÑ¡ÁÐÖÐÖµµÄijһ²ã´Î½á¹¹µÄ¾ÛºÏ¡£
OracleµÄGROUP BYÓï¾ä³ýÁË×î»ù±¾µÄÓï·¨Í⣬»¹Ö§³ÖROLLUPºÍCUBEÓï¾ä¡£Èç¹ûÊÇROLLUP(A, B, C)µÄ»°£¬Ê×ÏÈ·Ö³ÉÁ½´ó²½£º£¨1£©¶ÔÓÚ·ûºÏÌõ¼þµÄÿ ......
OracleµÄtrunc º¯ÊýÒ»°ãÓÃÀ´ ¶ÔÈÕÆÚºÍʱ¼ä½øÐнØÈ¡¡£
1¡¢Êý×Ö´¦Àí ¡£½ØÈ¡
select trunc(5.75),trunc(5.75,1),trunc(5.75,-1),trunc(556.234,-2) from dual;
Êä³ö:
TRUNC(5.75) TRUNC(5.75,1) TRUNC(5.75,-1) TRUNC(556.234,-2)
----------- ------------- -------------- ----- ......
Ê×ÏÈÒÔsysdbaÉí·ÝµÇ¼
sqlplus connect system/orcl as sysdba;
È»ºóÐ޸IJÎÊý
1.sga_target²»ÄÜ´óÓÚsga_max_size£¬¿ÉÒÔÉèÖÃΪÏàµÈ¡£
2.SGA¼ÓÉÏPGAµÈÆäËû½ø³ÌÕ¼ÓõÄÄÚ´æ×ÜÊý±ØÐëСÓÚ²Ù×÷ϵͳµÄÎïÀíÄÚ´æ¡£
alter system set sga_target=150M scope=spfile;
alter system set sga_max_size=150M scope=spfile;
//Êý¾Ý¿â ......
select i.sid,i.sname,i.birthday,i.schooltime,i.sphone,c.classname,a.assnname,sum(decode(subject,'ÓïÎÄ',s.score,0)) as chin,
......
OracleÖÐDecode()º¯ÊýʹÓü¼ÇÉ
¡¡¡¡decode()º¯ÊýÊÇORACLE PL/SQLÊǹ¦ÄÜÇ¿´óµÄº¯ÊýÖ®Ò»£¬Ä¿Ç°»¹Ö»ÓÐORACLE¹«Ë¾µÄSQLÌṩÁ˴˺¯Êý£¬ÆäËûÊý¾Ý¿â³§É̵ÄSQLʵÏÖ»¹Ã»Óд˹¦ÄÜ¡£
DECODEº¯ÊýÊÇORACLE PL/SQLÊǹ¦ÄÜÇ¿´óµÄº¯ÊýÖ®Ò»£¬Ä¿Ç°»¹Ö»ÓÐORACLE¹«Ë¾µÄSQLÌṩÁ˴˺¯Êý£¬ÆäËûÊý¾Ý¿â³§É̵ÄSQLÊµÏ ......