SQL*Plus 脚本执行了两次
SQL*Plus script executed twice
我正在尝试 运行 使用 sqlplus 的脚本。我的脚本是一个简单的删除语句。我通过在我的 ksh 终端中输入以下内容来执行它:
sqlplus username/'password' @../sql/delete_societes.sql
../sql/delete_societes.sql 是
DELETE FROM f2020.SOCIETES;
/
出于某种原因,它 运行s 两次,导致输出“0 行删除”被打印两次,并在我尝试执行插入而不是删除时导致错误。
让您的脚本执行任一操作;
DELETE FROM f2020.SOCIETES
/
或
DELETE FROM f2020.SOCIETES;
没有斜杠。
/(slash)
Executes the most recently executed SQL command or PL/SQL block which is stored in the SQL buffer.
在下面的示例中:
Enter a slash (/) to re-execute the command in the buffer
...这正是您所看到的。
The semicolon (;) means that this is the end of the command. Press Return or click Execute. SQL*Plus processes the command and displays the results
像许多客户一样 SQL*Plus 将 SQL 语句末尾的分号视为语句分隔符 - 它 不是 的一部分语句本身(这会导致一些混淆,例如动态 SQL 和 JDBC 调用) - 当它看到它时它会执行命令。执行的语句保留在命令缓冲区中;如果你 list
查看当前的命令缓冲区,它不会显示那个分号。当您发出斜杠时,它会再次执行缓冲区。
PL/SQL的情况略有不同; PL/SQL 块必须以分号结束,分号 是块的 部分,并出现在缓冲区中。 execute a PL/SQL block.
必须使用斜杠
一个示例,您可以在其中查看 SQL 和 PLSQL 的 sqlplus 缓冲区内容。
me@XEPDB1> help run
RUN
---
Lists and executes the most recently executed SQL command or
PL/SQL block which is stored in the SQL buffer. The buffer has
no command history list and does not record SQL*Plus commands.
R[UN]
me@XEPDB1> help /
/ (slash)
---------
Executes the most recently executed SQL command or PL/SQL block
which is stored in the SQL buffer. Use slash (/) at the command
prompt or line number prompt in SQL*Plus command line. The buffer
has no command history and does not record SQL*Plus commands.
/
me@XEPDB1> clear buffer [1/651]
buffer cleared
me@XEPDB1> l
SP2-0223: No lines in SQL buffer.
me@XEPDB1> select * from dual
2 /
D
-
X
me@XEPDB1> l
1* select * from dual
me@XEPDB1> select * from dual;
D
-
X
me@XEPDB1> l
1* select * from dual
me@XEPDB1> /
D
-
X
me@XEPDB1> r
1* select * from dual
D
-
X
me@XEPDB1> begin null; end;
2 /
PL/SQL procedure successfully completed.
me@XEPDB1> l
1* begin null; end;
me@XEPDB1> /
PL/SQL procedure successfully completed.
me@XEPDB1> r
1* begin null; end;
PL/SQL procedure successfully completed.
我正在尝试 运行 使用 sqlplus 的脚本。我的脚本是一个简单的删除语句。我通过在我的 ksh 终端中输入以下内容来执行它:
sqlplus username/'password' @../sql/delete_societes.sql
../sql/delete_societes.sql 是
DELETE FROM f2020.SOCIETES;
/
出于某种原因,它 运行s 两次,导致输出“0 行删除”被打印两次,并在我尝试执行插入而不是删除时导致错误。
让您的脚本执行任一操作;
DELETE FROM f2020.SOCIETES
/
或
DELETE FROM f2020.SOCIETES;
没有斜杠。
/(slash)
Executes the most recently executed SQL command or PL/SQL block which is stored in the SQL buffer.
在下面的示例中:
Enter a slash (/) to re-execute the command in the buffer
...这正是您所看到的。
The semicolon (;) means that this is the end of the command. Press Return or click Execute. SQL*Plus processes the command and displays the results
像许多客户一样 SQL*Plus 将 SQL 语句末尾的分号视为语句分隔符 - 它 不是 的一部分语句本身(这会导致一些混淆,例如动态 SQL 和 JDBC 调用) - 当它看到它时它会执行命令。执行的语句保留在命令缓冲区中;如果你 list
查看当前的命令缓冲区,它不会显示那个分号。当您发出斜杠时,它会再次执行缓冲区。
PL/SQL的情况略有不同; PL/SQL 块必须以分号结束,分号 是块的 部分,并出现在缓冲区中。 execute a PL/SQL block.
必须使用斜杠一个示例,您可以在其中查看 SQL 和 PLSQL 的 sqlplus 缓冲区内容。
me@XEPDB1> help run
RUN
---
Lists and executes the most recently executed SQL command or
PL/SQL block which is stored in the SQL buffer. The buffer has
no command history list and does not record SQL*Plus commands.
R[UN]
me@XEPDB1> help /
/ (slash)
---------
Executes the most recently executed SQL command or PL/SQL block
which is stored in the SQL buffer. Use slash (/) at the command
prompt or line number prompt in SQL*Plus command line. The buffer
has no command history and does not record SQL*Plus commands.
/
me@XEPDB1> clear buffer [1/651]
buffer cleared
me@XEPDB1> l
SP2-0223: No lines in SQL buffer.
me@XEPDB1> select * from dual
2 /
D
-
X
me@XEPDB1> l
1* select * from dual
me@XEPDB1> select * from dual;
D
-
X
me@XEPDB1> l
1* select * from dual
me@XEPDB1> /
D
-
X
me@XEPDB1> r
1* select * from dual
D
-
X
me@XEPDB1> begin null; end;
2 /
PL/SQL procedure successfully completed.
me@XEPDB1> l
1* begin null; end;
me@XEPDB1> /
PL/SQL procedure successfully completed.
me@XEPDB1> r
1* begin null; end;
PL/SQL procedure successfully completed.