When or Why to use a quot;SET DEFINE OFFquot; in Oracle Database(何时或为何使用“SET DEFINE OFF在 Oracle 数据库中)
问题描述
我正在 Oracle 中观看脚本,但看到了一些我不认识的内容
I'm watching a Script in Oracle and I see something I don't recognize
REM INSERTING into database1."Users"
SET DEFINE OFF;
Insert into database1."Users" ("id","right") values ('1','R');
我正在寻找有关set define off"的文档,它的字面意思是禁用命令解析以将替换变量替换为其值"
I'm looking for documentation about "set define off" and it's literally writing "disable the parsing of commands to replace substitution variable with their values"
我真的不明白他们想说什么.
I don't really understand what they want to say.
有人可以帮我吗?
推荐答案
默认情况下,SQL Plus 处理&"作为开始替换字符串的特殊字符.这在运行包含&"的脚本时可能会导致问题其他原因:
By default, SQL Plus treats '&' as a special character that begins a substitution string. This can cause problems when running scripts that happen to include '&' for other reasons:
SQL> insert into customers (customer_name) values ('Marks & Spencers Ltd');
Enter value for spencers:
old 1: insert into customers (customer_name) values ('Marks & Spencers Ltd')
new 1: insert into customers (customer_name) values ('Marks Ltd')
1 row created.
SQL> select customer_name from customers;
CUSTOMER_NAME
------------------------------
Marks Ltd
如果您知道您的脚本包含(或可能包含)包含&"的数据字符,并且您不希望出现上述替换行为,然后使用 set define off
在运行脚本时关闭行为:
If you know your script includes (or may include) data containing '&' characters, and you do not want the substitution behaviour as above, then use set define off
to switch off the behaviour while running the script:
SQL> set define off
SQL> insert into customers (customer_name) values ('Marks & Spencers Ltd');
1 row created.
SQL> select customer_name from customers;
CUSTOMER_NAME
------------------------------
Marks & Spencers Ltd
您可能希望在脚本末尾添加 set define on
以恢复默认行为.
You might want to add set define on
at the end of the script to restore the default behaviour.
这篇关于何时或为何使用“SET DEFINE OFF"在 Oracle 数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:何时或为何使用“SET DEFINE OFF"在 Oracle 数据库中


- 更改自动增量起始编号? 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01