SQLPlus的登陸與退出sqlplus-H|-V-H將顯示sqlplus的版本及幫助信息,-V將顯示其版本信息登陸語(yǔ)法:is:([/][@]|/)[ASSYSDBA|ASSYSOPER]|/NOLOG[/]:登陸的用戶名,密碼@:數(shù)據(jù)庫(kù)的連接標(biāo)識(shí)符,當(dāng)未指定該參數(shù),則連接到缺省的標(biāo)識(shí)符ASSYSDBA|ASSYSOPER:這兩個(gè)參數(shù)描述使用數(shù)據(jù)庫(kù)管理員的權(quán)限登陸NOLOG:?jiǎn)?dòng)未連" />

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

SQLPlus 常用命令

系統(tǒng) 2327 0

SQLPlus提供了很多常用的命令,以下是常用命令的使用方法及示例。

1-> SQLPlus的登陸與退出

        sqlplus -H | -V -H 將顯示sqlplus的版本及幫助信息,-V將顯示其版本信息

登陸語(yǔ)法:

 
   
     
        
          
            is
          
          : (
    
      
          
            
        [/ 
       
            
              
         ][@ 
        
              
                
          ] | /) [AS SYSDBA | AS SYSOPER] | /NOLOG 
         
                
                  
           [/ 
          
                  
                    
            ]:登陸的用戶名,密碼 @ 
           
                    
                      
             :數(shù)據(jù)庫(kù)的連接標(biāo)識(shí)符,當(dāng)未指定該參數(shù),則連接到缺省的標(biāo)識(shí)符 AS SYSDBA | AS SYSOPER:這兩個(gè)參數(shù)描述使用數(shù)據(jù)庫(kù)管理員的權(quán)限登陸 NOLOG:?jiǎn)?dòng)未連接到數(shù)據(jù)庫(kù)的SQLPlus,在這之后可以使用conn登陸 下面是三種不同的登陸方式 [oracle@linux ~]$ sqlplus scott/tigger SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 30 14:04:06 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options [oracle@linux ~]$ sqlplus /nolog SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 30 14:04:45 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. SQL> conn scott Enter password: Connected. SQL> exit 
            
                      
                        /*使用exit或quit來(lái)退出*/
                      
                       SQL> exit Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options [oracle@linux ~]$ sqlplus " 
            
                      
                        /as sysdba
                      
                      " SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 30 14:05:44 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options 退出:使用使用exit或quit來(lái)退出,如例子中所演示的 
           
                    
                  
                
              
            
          
        
      
    2->help? 獲得某一個(gè)命令的幫助信息
  
      
        SQL
      
      > help 
      
        desc
      
      
        DESCRIBE
      
      
        --------
      
      

 Lists the 
      
        column
      
       definitions 
      
        for
      
       a 
      
        table
      
      , 
      
        view
      
      , 
      
        or
      
       synonym,

 
      
        or
      
       the specifications 
      
        for
      
       a 
      
        function
      
      
        or
      
      
        procedure
      
      .

 
      
        DESC
      
      [RIBE] {[
      
        schema
      
      .]object[@connect_identifier]
    
    3->LIST [m][*] [n](簡(jiǎn)寫L)顯示緩沖區(qū)的所有內(nèi)容。* 當(dāng)前行,m 第m行,n 第n行,m n 同時(shí)出現(xiàn),m到n行
  
      
        SQL
      
      > l

  1  
      
        select
      
       * 
      
        from
      
       emp

  2  
      
        where
      
       sal > 2000

  3* 
      
        and
      
       deptno = 20


      
        SQL
      
      > l 2 3

  2  
      
        where
      
       sal > 2000

  3* 
      
        and
      
       deptno = 20
    
    4->/ 執(zhí)行緩沖區(qū)的內(nèi)容
  
      
        SQL
      
      > l

  1  
      
        select
      
       * 
      
        from
      
       emp

  2  
      
        where
      
       sal > 2000

  3  
      
        and
      
       deptno = 20

  4* 
      
        and
      
       ename = '
      
        SCOTT
      
      '


      
        SQL
      
      > /



     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO


      
        ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
      
      

      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20  
    
    5->n 設(shè)置當(dāng)前行
  
      
        SQL
      
      > 2

  2* 
      
        where
      
       sal > 2000


      
        SQL
      
      > 3

  3* 
      
        and
      
       deptno = 20  
    
    6->n text 用text內(nèi)容替換第n行
  
        
          SQL
        
        > l

  1  
        
          select
        
         * 
        
          from
        
         emp

  2  
        
          where
        
         deptno = 20

  3* 
        
          and
        
         sal > 2000


        
          SQL
        
        > 2 
        
          where
        
         ename = '
        
          SCOTT
        
        '


        
          SQL
        
        > l

  1  
        
          select
        
         * 
        
          from
        
         emp

  2  
        
          where
        
         ename = '
        
          SCOTT
        
        '

  3* 
        
          and
        
         sal > 2000
      
7->;? 對(duì)于已輸入完畢的SQL語(yǔ)句,輸入;號(hào)表示該語(yǔ)句輸入完畢。對(duì)于設(shè)置語(yǔ)句可以不使用分號(hào),如上述的help desc
?

8->APPEND text(簡(jiǎn)寫A text) 將text的內(nèi)容追加到緩沖區(qū)尾部
      
        SQL
      
      > l

  1* 
      
        select
      
       * 
      
        from
      
       emp


      
        SQL
      
      > a 
      
        where
      
       sal > 2000;

  1* 
      
        select
      
       * 
      
        from
      
       empwhere sal > 2000
    
    9->CHANGE/old/new(簡(jiǎn)寫C /old/new) 將當(dāng)前行中的old替換為new
  
        
          SQL
        
        > l

  1  
        
          select
        
         * 
        
          from
        
         emp

  2  
        
          where
        
         sal > 2000

  3*    
        
          and
        
         deptno = 20


        
          SQL
        
        > 3

  3*    
        
          and
        
         deptno = 20


        
          SQL
        
        > c /20/10

  3*    
        
          and
        
         deptno = 10


        
          SQL
        
        > l

  1  
        
          select
        
         * 
        
          from
        
         emp

  2  
        
          where
        
         sal > 2000

  3*    
        
          and
        
         deptno = 10
      
    10->CHANGE/text(C/text) 刪除當(dāng)前行中的text
  
      
        SQL
      
      > l

  1  
      
        select
      
       * 
      
        from
      
       emp

  2  
      
        where
      
       sal > 2000

  3*    
      
        and
      
       deptno = 10


      
        SQL
      
      > 3

  3*    
      
        and
      
       deptno = 10


      
        SQL
      
      > c /
      
        and
      
       deptno = 10

  3*


      
        SQL
      
      > l

  1  
      
        select
      
       * 
      
        from
      
       emp

  2  
      
        where
      
       sal > 2000

  3*
    
    11->CLEAR BUFFER(CL BUFF)清除整個(gè)SQL緩沖區(qū)
  
        
          SQL
        
        > cl buff

buffer cleared


        
          SQL
        
        > l

SP2-0223: 
        
          No
        
         lines 
        
          in
        
        
          SQL
        
         buffer.
      
12->DEL 刪除當(dāng)前行
        
          SQL
        
        > l

  1  
        
          select
        
         * 
        
          from
        
         emp

  2* 
        
          where
        
         sal > 2000


        
          SQL
        
        > del 2


        
          SQL
        
        > l

  1* 
        
          select
        
         * 
        
          from
        
         emp
      
13->show user 顯示當(dāng)前登陸的用戶
        
          SQL
        
        > show 
        
          user
        
        
          USER
        
        
          is
        
         "
        
          SYS
        
        "


        
          SQL
        
        > conn scott/tigger

Connected.


        
          SQL
        
        > show 
        
          user
        
        
          USER
        
        
          is
        
         "
        
          SCOTT
        
        "
      
    14->SAVE 保存當(dāng)前緩沖區(qū)的內(nèi)容到文件
  
        
          SQL
        
        > l

  1  
        
          select
        
         *

  2  
        
          from
        
         emp

  3* 
        
          where
        
         sal > 2000


        
          SQL
        
        > 
        
          save
        
         query.
        
          sql
        
        

Created 
        
          file
        
         query.
        
          sql
        
      
    15->GET 把磁盤上的命令文件調(diào)入到當(dāng)前緩沖區(qū)
  
      
        SQL
      
      > cl buff

buffer cleared


      
        SQL
      
      > 
      
        get
      
       query.
      
        sql
      
      

  1  
      
        select
      
       *

  2  
      
        from
      
       emp

  3* 
      
        where
      
       sal > 2000
    
    16->START/@ filename 運(yùn)行命令文件 
  
      
        SQL
      
      > 
      
        get
      
       query.
      
        sql
      
      

  1  
      
        select
      
       *

  2  
      
        from
      
       emp

  3* 
      
        where
      
       sal > 2000


      
        SQL
      
      > @query.
      
        sql
      
    
    17->SET LINESIZE n 設(shè)置每行的字符數(shù),默認(rèn)80,如果一行的輸出內(nèi)容大于設(shè)置的一行可容納的字符數(shù),則折行顯示。 
  
        
          SQL
        
        > 
        
          select
        
         * 
        
          from
        
         scott.emp 
        
          where
        
         ename = '
        
          SCOTT
        
        '; 
        
          /*以下是未設(shè)置的結(jié)果*/
        
        



     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM


        
          ---------- ---------- --------- ---------- --------- ---------- ----------
        
        

    DEPTNO


        
          ----------
        
        

      7788 SCOTT      ANALYST         7566 19-APR-87       3000

        20




        
          SQL
        
        > 
        
          set
        
         linesize 200


        
          SQL
        
        > 
        
          select
        
         * 
        
          from
        
         scott.emp 
        
          where
        
         ename = '
        
          SCOTT
        
        ';  
        
          /*以下是設(shè)置后的結(jié)果*/
        
         



     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO


        
          ---------- ---------- --------- ---------- --------- ---------- ---------- ----------
        
        

      7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
      
18->dual 偽表的使用,注意Oracle與MSSQL的差異,下面的操作MSSQL無(wú)需偽表即可完成,幾不需要from dual就可以完成一些特定的功能
        
          SQL
        
        > 
        
          select
        
         3+2 
        
          from
        
         dual;



       3+2


        
          ----------
        
        

         5
      
    19->spool??? filename 將接下來(lái)屏幕上輸入的所有內(nèi)容輸出到文件,包括輸入的SQL語(yǔ)句
  
    20->spool off 需要使用off后,才能將內(nèi)容輸出到文件
  
    更多:
    
      Linux (RHEL 5.4)下安裝Oracle 10g R2
    
    
      使用Uniread實(shí)現(xiàn)SQLplus翻頁(yè)功能
    
  

SQLPlus 常用命令


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 秦皇岛市| 庄浪县| 望江县| 炎陵县| 建瓯市| 疏附县| 新疆| 广平县| 东辽县| 长宁区| 三台县| 梁平县| 茌平县| 荃湾区| 桑日县| 英德市| 方山县| 车致| 简阳市| 应用必备| 江陵县| 阿城市| 湖北省| 萨迦县| 齐齐哈尔市| 海原县| 新沂市| 民县| 松江区| 鹤峰县| 杨浦区| 瑞昌市| 岳阳市| 镇平县| 防城港市| 鹤壁市| 眉山市| 固镇县| 德江县| 都兰县| 横山县|