Rex Mao

分享java技术与生活

2008年5月17日 #

关于留言

由于留言的提示邮件会被标记为垃圾邮件, 所以很多留言我没能发现并回复。
如果有问题要讨论,请大家直接发邮件到邮箱rex_mao@hotmail.com

另外,如果需要源程序,可联系购买,也可提供程序扩展开发。

谢谢。

posted @ 2008-05-24 01:04 Rex Mao| 编辑 收藏

Oracle SQLPLUS 常用命令小结(一)


1. 显示当前连接。

SQL:
        SELECT *                                                                                                                                                 
        FROM V$SESSION                                                                                                                                 
        WHERE STATUS = 'INACTIVE'                                                                                                             
        AND USERNAME IS NOT NULL;                                                                                                         


2. 强制关闭用户的连接

SQL:
    a) SELECT USERNAME, SID, SERIAL#                                                                                                   
        FROM V$SESSION                                                                                                                                 
        WHERE STATUS = 'INACTIVE'                                                                                                             
        AND USERNAME IS NOT NULL;                                                                                                         
                                                                                                                                                                          
    b) ALTER SYSTEM KILL SESSION 'SID, SERIAL#'; --SID 和 SERIAL#是在步骤a)中得到的结果。


3. 从返回的结果中选择第m到n条记录

SQL:
        SELECT *                                                                                                                                                   
        FROM (                                                                                                                                                      
                     SELECT A.*, ROWNUM RN                                                                                                       
                     FROM (                                                                                                                                         
                                   SELECT *                                                                                                                        
                                   FROM YOURTABLE --这里请用你的SELECT语句代替                                            
                                  ) A                                                                                                                                     
                     WHERE ROWNUM <= n                                                                                                              
                     )                                                                                                                                                      
        WHERE RN >= m;                                                                                                                                      
    
4. 重新编译包 (package) 和 包体 (package body)
    此命令可以用于查看在SQLPLUS中创建的package的编译错误。

SQL:
        a) 编译 package
            ALTER PACKAGE YOUR_PACKAGE                                                                                                 
            COMPILE SPECIFICATION;                                                                                                                
        b) 编译 package body

            ALTER PACKAGE YOUR_PACKAGE                                                                                                 
            COMPILE BODY;                                                                                                                                   

        c) 查看错误
            SHOW ERR;                                                                                                                                             

5. 解除锁定的用户

SQL:
SQL:
    ALERT USER USERNAME UNLOCK;


 

posted @ 2008-05-17 14:11 Rex Mao 阅读(3110) | 评论 (2)编辑 收藏