SQL开发人员帮助输入替换变量

7
我正在使用脚本输入约15,000行数据到我的表中,但是当我运行脚本时,弹出一个窗口要求我输入替换变量。如何阻止这个窗口的弹出以便我可以输入日期?以下是我需要输入的一些数据行示例:
INSERT INTO description 
 (description, item_weight, pickup_customer, delivery customer, category)
VALUES 
 ('Normal', 4771, 'Carfax & Co', 'Matriotism Plc', 'A');

INSERT INTO description 
 (description, item_weight, pickup_customer, delivery customer, category) 
VALUES 
 ('Normal', 2525, 'Matriotism Plc', 'Carfax & Co', 'A');

INSERT INTO description 
 (description, item_weight, pickup_customer, delivery customer, category) 
VALUES 
 ('Normal', 693, 'Matriotism Plc', 'Sylph Fabrication', 'A');

INSERT INTO description 
 (description, item_weight, pickup_customer, delivery customer, category) 
VALUES 
 ('Fragile', 2976, 'Nosophobia Fabrication', 'Carfax & Co', 'B');

INSERT INTO description 
 (description, item_weight, pickup_customer, delivery customer, category) 
VALUES 
 ('Fragile', 3385, 'Nosophobia Fabrication', 'Carfax & Co','B');
2个回答

9

字符 & 告诉Oracle您想要使用替换变量。

您可以通过在插入时以转义字符为前缀来转义这些字符:

SET ESCAPE '\'

INSERT INTO description 
 (description, item_weight, pickup_customer, delivery customer, category) 
VALUES 
 ('Fragile', 3385, 'Nosophobia Fabrication', 'Carfax \& Co','B');

或者完全禁用扫描替换变量:

SET SCAN OFF

INSERT INTO description 
 (description, item_weight, pickup_customer, delivery customer, category) 
VALUES 
 ('Fragile', 3385, 'Nosophobia Fabrication', 'Carfax & Co','B');

如需更多信息,请随时查看:http://ss64.com/ora/syntax-escape.html

这个链接提供了关于Oracle数据库中转义字符的语法和用法的详细说明。

3
&符号被解释为替换变量的开头。你可以通过执行以下命令来完全关闭替换:
set define off;

在运行你的语句之前,或者在&符号后立即结束字符串,像这样:
INSERT INTO description 
  (description, item_weight, pickup_customer, delivery customer, category) 
VALUES 
  ('Normal', 2525, 'Matriotism Plc', 'Carfax &'||' Co', 'A');

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接