我在sqlplus中运行了以下语句。它插入了第2行的副本。在日志中我发现我也在注释行之后创建了一行 所以,在这里我要求多行评论在/ *和评论之间应该有空格和* /?
insert into table values (1);
insert into table values (2);
/*comments here*/
insert into table values (3);
commit;
记录:
SQL> insert into table values (1);
1 row created.
SQL> insert into table values (2);
1 row created.
**SQL> /*comments here*/
1 row created.**
SQL> insert into table values (3);
1 row created.
select A from table;
A
------------
1
2
2
3
答案 0 :(得分:1)
所有
我在sqlplus中尝试过。我们需要在/ *和后面的字符之间给出空格或换行符。所以它被视为多行评论。
正确的语法:
<强> /* comments here */
强>
或
<强> /*
comments here
*/
强>
语法错误:
<强> /*comments here*/
强>
答案 1 :(得分:0)
我认为你的代码包含一个额外的正斜杠。看看:
SQL> create table test (id number);
Table created.
SQL> insert into test values (1);
1 row created.
SQL> insert into test values (2);
1 row created.
SQL> /* comments
SQL> here
SQL> */
SQL> / --> this one; it executes the last command in buffer ...
1 row created. --> ... and results with yet another "2" begin inserted
SQL> insert into test values (3);
1 row created.
SQL> select * from test;
ID
----------
1
2
2
3
SQL>
没有它,一切都很好:
SQL> truncate table test;
Table truncated.
SQL> insert into test values (1);
1 row created.
SQL> insert into test values (2);
1 row created.
SQL> /* comments
SQL> here
SQL> */
SQL> insert into test values (3);
1 row created.
SQL> select * from test;
ID
----------
1
2
3
SQL>