I write:
- :CREATE TABLE Person (
- :name CHAR(10),
- :
- :ssn INTEGER);
:CREATE TABLE Person(
and save it to a file "a.sql" (colon represents beginning of line, is not in actual code.)
并将其保存到文件“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.
如果我然后在SQL * Plus命令提示符下键入“@a”来运行它,它将告诉我以“ssn”开头的行不被识别为命令,并被忽略。
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?
从我收集的内容来看,如果连续遇到多个换行符,sqlplus似乎会终止命令。这是一个准确的陈述吗?如果是这样,有人知道这是否必要/为什么选择这样做?
3 个解决方案
#1
I don't know about the why, but a completely blank line terminates a command in SQL*Plus.
我不知道原因,但是一个完全空行终止SQL * Plus中的命令。
Quote from the SQL*Plus docs :
从SQL * Plus文档引用:
Ending a SQL Command: You can end a SQL command in one of three ways:
结束SQL命令:您可以通过以下三种方式之一结束SQL命令:
- with a semicolon (;)
- with a slash (/) on a line by itself
- with a blank line
用分号(;)
在一条线上单独使用斜杠(/)
用空白行
You can also change how blank lines are treated with SET SQLBLANKLINES
您还可以使用SET SQLBLANKLINES更改空白行的处理方式
SQLBL[ANKLINES] {ON|OFF}
Controls whether SQL*Plus allows blank lines within a SQL command or script. ON interprets blank lines and new lines as part of a SQL command or script. OFF, the default value, does not allow blank lines or new lines in a SQL command or script or script.
控制SQL * Plus是否允许SQL命令或脚本中的空行。 ON将空行和新行解释为SQL命令或脚本的一部分。 OFF(默认值)不允许SQL命令或脚本或脚本中出现空行或换行。
Enter the BLOCKTERMINATOR to stop SQL command entry without running the SQL command. Enter the SQLTERMINATOR character to stop SQL command entry and run the SQL statement.
输入BLOCKTERMINATOR以停止SQL命令输入而不运行SQL命令。输入SQLTERMINATOR字符以停止SQL命令条目并运行SQL语句。
#2
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.
默认情况下,SQLPlus会在输入空行时终止(但不执行)语句。它一直都是这样做的。在屏幕编辑器和查询工具之前的几天看起来似乎是一个好主意。
You can change that default behaviour with
您可以使用更改默认行为
set SQLBLANKLINES on
设置SQLBLANKLINES
In which case you'd have to enter a line with just a full stop to terminate (but not execute) a statement.
在这种情况下,您必须输入一个只有句号的行来终止(但不执行)一个语句。
#3
But if you are wanting to insert multiline text in a varchar2 or a clob field, you may use chr(10)
但是,如果您想在varchar2或clob字段中插入多行文本,可以使用chr(10)
insert into t values ('Hello,'||chr(10)||chr(10)||' How are you?');
insert into t values (
'Hello,
How are you');
will not work for reasons explained above.
由于上述原因不起作用。
#1
I don't know about the why, but a completely blank line terminates a command in SQL*Plus.
我不知道原因,但是一个完全空行终止SQL * Plus中的命令。
Quote from the SQL*Plus docs :
从SQL * Plus文档引用:
Ending a SQL Command: You can end a SQL command in one of three ways:
结束SQL命令:您可以通过以下三种方式之一结束SQL命令:
- with a semicolon (;)
- with a slash (/) on a line by itself
- with a blank line
用分号(;)
在一条线上单独使用斜杠(/)
用空白行
You can also change how blank lines are treated with SET SQLBLANKLINES
您还可以使用SET SQLBLANKLINES更改空白行的处理方式
SQLBL[ANKLINES] {ON|OFF}
Controls whether SQL*Plus allows blank lines within a SQL command or script. ON interprets blank lines and new lines as part of a SQL command or script. OFF, the default value, does not allow blank lines or new lines in a SQL command or script or script.
控制SQL * Plus是否允许SQL命令或脚本中的空行。 ON将空行和新行解释为SQL命令或脚本的一部分。 OFF(默认值)不允许SQL命令或脚本或脚本中出现空行或换行。
Enter the BLOCKTERMINATOR to stop SQL command entry without running the SQL command. Enter the SQLTERMINATOR character to stop SQL command entry and run the SQL statement.
输入BLOCKTERMINATOR以停止SQL命令输入而不运行SQL命令。输入SQLTERMINATOR字符以停止SQL命令条目并运行SQL语句。
#2
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.
默认情况下,SQLPlus会在输入空行时终止(但不执行)语句。它一直都是这样做的。在屏幕编辑器和查询工具之前的几天看起来似乎是一个好主意。
You can change that default behaviour with
您可以使用更改默认行为
set SQLBLANKLINES on
设置SQLBLANKLINES
In which case you'd have to enter a line with just a full stop to terminate (but not execute) a statement.
在这种情况下,您必须输入一个只有句号的行来终止(但不执行)一个语句。
#3
But if you are wanting to insert multiline text in a varchar2 or a clob field, you may use chr(10)
但是,如果您想在varchar2或clob字段中插入多行文本,可以使用chr(10)
insert into t values ('Hello,'||chr(10)||chr(10)||' How are you?');
insert into t values (
'Hello,
How are you');
will not work for reasons explained above.
由于上述原因不起作用。