關於Oracle DB中SQL Script的註釋(REM,--,/* */)

perfychi發表於2014-02-19


 DB中SQL Script註釋的語法
  1. REM Single line comment   
  2.   
  3. -- Single line comment   
  4.   
  5. /* Single line comment */  
  6.   
  7. /*   
  8.   Multi Line  
  9.   comment  
  10. */  

補充:REM是REMARK的縮寫

那麼REM--的區別是什麼?

--或者/* */可以用於PL/SQL,但REM[ark]不可以。

下邊這段可以在SQL*PLUS中執行成功

  1. REM comment  
  2. -- comment   
  3. /* comment */  
  4. begin  
  5.    DBMS_OUTPUT.PUT_LINE('Test'); --comment   
  6.    DBMS_OUTPUT.PUT_LINE('Test'); /* comment */  
  7. end;   
  8. /  
但下邊這段就不行
  1. begin  
  2.    DBMS_OUTPUT.PUT_LINE('Test'); REM comment  
  3. end;   
  4. /  
  5.   
  6. begin  
  7.    REM comment  
  8.    DBMS_OUTPUT.PUT_LINE('Test');  
  9. end;   
  10. /  
11.2 documentation on all comment types 關於註釋有很清楚的說明。



You can enter comments in a script in three ways:

  • using the SQL*Plus REMARK command for single line comments.

  • using the SQL comment delimiters /*... */ for single or multi-line comments.

  • using ANSI/ISO (American National Standards Institute/International Standards Organization) comments - - for single line comments.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27042095/viewspace-1083737/,如需轉載,請註明出處,否則將追究法律責任。

相關文章