Rex Mao

分享java技术与生活

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 on 2008-05-17 14:11 Rex Mao 阅读(3106) 评论(2)  编辑  收藏 所属分类: 技术

评论

# re: Oracle SQLPLUS 常用命令小结(一) 2008-09-05 00:52 I appreciate you

It's simple, but it's useful ^^  回复  更多评论   

# re: Oracle SQLPLUS 常用命令小结(一) 2008-09-24 21:40 somebody

怎么不更新了呢?  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航: