为什么 ORACLE 不允许命令中出现连续的换行符?
我写:
CREATE TABLE Person (
name CHAR(10),
ssn INTEGER);
并将其保存到文件“a.sql”中。
如果我然后通过在 SQL*Plus 命令提示符中键入“@a”来运行它,它会告诉我以“ssn”开头的行不被识别为命令,并且会被忽略。
据我所知,如果 sqlplus 在一行中遇到多个换行符,它似乎会终止命令。 这是一个准确的说法吗? 如果是这样,有谁知道这是否有必要/为什么选择这样做?
I write:
CREATE TABLE Person (
name CHAR(10),
ssn INTEGER);
and save it to a file "a.sql".
If I then run it by typing "@a" in the SQL*Plus command prompt, it will tell me that the line starting with "ssn" is not recognized as a command, and is ignored.
From what I gather, it seems that sqlplus terminates a command if it encounters multiple newline characters in a row. Is this an accurate statement? If so, does anyone know if this is necessary/ why it chooses to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道为什么,但是一个完全空白的行终止了 SQL*Plus 中的命令。
引自SQL*Plus 文档 :
结束 SQL 命令:
您可以通过以下三种方式之一结束 SQL 命令:
您还可以使用 SET SQLBLANKLINES 更改处理空行的方式
I don't know about the why, but a completely blank line terminates a command in SQL*Plus.
Quote from the SQL*Plus docs :
Ending a SQL Command:
You can end a SQL command in one of three ways:
You can also change how blank lines are treated with SET SQLBLANKLINES
默认情况下,当输入空行时,SQLPlus 会终止(但不执行)语句。 它一直都是这样做的。 在屏幕编辑器和查询工具出现之前,这似乎是一个好主意。
更改默认行为,
您可以使用set SQLBLANKLINES on
在这种情况下,您必须输入只有句号的行才能终止(但不执行)语句。
By default, SQLPlus does terminate (but not execute) a statement when a blank line is entered. It has always done this. It probably seemed like a good idea in the days before screen editors and query tools.
You can change that default behaviour with
set SQLBLANKLINES on
In which case you'd have to enter a line with just a full stop to terminate (but not execute) a statement.
但是如果您想在 varchar2 或 clob 字段中插入多行文本,您可以使用
由于上述原因, chr(10)
将不起作用。
But if you are wanting to insert multiline text in a varchar2 or a clob field, you may use
chr(10)
will not work for reasons explained above.