Is there any difference between Rem and — comments for SQL*Plus?
-
16-10-2019 - |
문제
On SQL*Plus prompt, both Rem
and --
qualify as comment indicators:
Rem this is a comment
-- this is also a comment
create table emp (
id number primary key,
name cvarchar2(40));
Is there any difference at all between the two commenting techniques?
해결책
The difference is that --
and /* */
can be used in a PL/SQL block, while REM[ARK]
cannot. The following will work in SQL*Plus:
REM comment
-- comment
/* comment */
begin
DBMS_OUTPUT.PUT_LINE('Test'); --comment
DBMS_OUTPUT.PUT_LINE('Test'); /* comment */
end;
/
These will not:
begin
DBMS_OUTPUT.PUT_LINE('Test'); REM comment
end;
/
begin
REM comment
DBMS_OUTPUT.PUT_LINE('Test');
end;
/
The 11.2 documentation on all comment types has more comment information. The basics are...
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.
The documentation also includes notes on four places that comments should not be used, but these do not include any further differences.
다른 팁
REM is supported due to being the way MS BATCH files are commented, and this tool being used with automation environments.
-- is supported due to being part of the SQL standard. ( http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt page 83 cf <comment introducer> ::= <minus sign><minus sign>[<minus sign>...]
)
No there should be no difference at all.