- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 oracle sql 查询中连接多个 (3) 列。目前我正在使用函数concat
。有人建议使用 ||
代替 concat
,因为它可以提高性能。
这是真的吗?如果是的话为什么?
我只看到 || 的好处书面查询更具可读性。
最佳答案
我设置了一个简单的 PL/SQL 脚本(如下),在循环中尝试两个串联选项,每个选项 1 亿次。 ||
的结果是 142.93 秒,CONCAT
的结果是 144.11 秒。不管怎样,每次操作大约需要 1.4 微秒。我的结论是,似乎没有任何明显的性能差异。
除了更具可读性之外,||
是连接运算符的 ANSI 标准。
DECLARE
i NUMBER;
j NUMBER := 100000000;
v VARCHAR2 (1000);
v_start TIMESTAMP := SYSTIMESTAMP;
BEGIN
FOR i IN 1 .. j LOOP
v := DBMS_RANDOM.VALUE () || DBMS_RANDOM.VALUE ();
END LOOP;
DBMS_OUTPUT.put_line ('1: ' || (SYSTIMESTAMP - v_start));
END;
DECLARE
i NUMBER;
j NUMBER := 100000000;
v VARCHAR2 (1000);
v_start TIMESTAMP := SYSTIMESTAMP;
BEGIN
FOR i IN 1 .. j LOOP
v := CONCAT (DBMS_RANDOM.VALUE (), DBMS_RANDOM.VALUE ());
END LOOP;
DBMS_OUTPUT.put_line ('2: ' || (SYSTIMESTAMP - v_start));
END;
<小时/>
作为脚注,Oracle关于 CONCAT
函数的用途如下:
When moving SQL script files between systems having different character sets, such as between ASCII and EBCDIC, vertical bars might not be translated into the vertical bar required by the target Oracle Database environment. Oracle provides the CONCAT character function as an alternative to the vertical bar operator for cases when it is difficult or impossible to control translation performed by operating system or network utilities. Use this function in applications that will be moved between environments with differing character sets.
关于oracle - concat 与 || 之间有性能差异吗在甲骨文中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26103027/
我正在尝试在 64 位 Windows 7 计算机上安装 Oracle Instant Client 和 ODBC 驱动程序。 我已经下载了两个 即时客户端包 - 基本 即时客户端包 - ODBC 我
每当我在 ORACLE 中授予用户“所有权限”(下面的示例)时,这实际上做了什么? 我的理解是,它赋予用户任何权限,例如在该架构中插入、删除等,但不数据库中的任何架构? grant all privi
我目前无法访问任何 Oracle 书籍,而且我的在线搜索几乎没有返回任何结果(Google 中的 (+) 什么也没有显示)。我正在查看现有代码以向查询添加一些字段并看到: AND lookup.Loo
我的访问表如下: insert into Visit values(12, to_date('19-JUN-13', 'dd-mon-yy'), to_date('19-JUN-13 12:00 A.
我的数据格式如下: cons_Type COLUMN_NAME P (COL1) R (COL6_REFERENCE) R (C
我希望我的表根据它的 TEMPLATE_ID 对其“排序依据”列进行排序。 我希望这发生在插入时(可能通过插入触发器)。 例如,如果我运行以下插入,我应该得到下表中的值。 INSERT INTO TE
我有一个场景,我必须为低于 SQL 阈值限制的值排名负数。任何人都可以帮助我吗? Name Target Rank John 2500 -2 Hopkins 4000 -1
我想用另一个表中的随机名称更新表中的名称。表 Users 中有真实的用户名。表 tmp_users 中有编造的名字。我想用 tmp_users 表中的随机名称更新用户表中的所有名称。这个想法是用假客户
如何从匹配删除表的表中删除记录?就像,我有一个记录键表,上面写着需要从我的主表中删除的内容。我将如何编写删除语句来表示“从我的主表中删除此字段与我的删除表中的字段匹配的任何内容?” 最佳答案 如果是小
我有一个关于表创建的问题。我想将“Ono”和“Pno”的属性组合成一个新表的主键。这些都是外键,每个都来自不同的表。我是否只使用 CONSTRAINT Ono_Pno_PK PRIMARY KEY (
我的情况(简化)如下所示: 表 UNITS 在 UNITS.NAME 上有一个 PK。 (单位名称, varchar(12)) 表 DEPTS 在 DEPTS.NAME 上有一个 PK。 (部门名称,
假设我有一个带有自动递增代理键的表。 这是使用反向索引的好例子吗? 我说的对吗: 插入(到索引中)会更快......因为新值会随机插入,而不是总是进入最右边的叶子(不断强制重新平衡)。 索引查找会稍微
我试图创建一个新表 (tableB),它带有到另一个表 (tableA) 的外键约束,只是想知道是否可以创建所有需要的约束和索引。我的目标是拥有一个 create table不需要 alter tab
唯一约束列中是否可以有2个或多个空值? 最佳答案 易于检查:(答案为是) create table t1 (col1 number unique); Table T1 created. insert
如何从delphi 7(ado组件)将blob数据插入oracle xe 最佳答案 使用TAdoQuery检查这些样本组件。 直接从文件加载数据 ADOQuery1.Parameters.AddPa
我试图在表 A 上创建一个约束,以检查表 B 中是否存在一组记录。我可以使用外键,但问题是表 B 中的数据不唯一。 有没有办法在不创建触发器的情况下创建这样的约束? 编辑:我无法更改表 B 结构。 最
我正在加载一个查找员工表的表。然而,有时源文件和 Employee 表中的名称不正确匹配。 **Employee table:** Employee Name Paul Jaymes **Source
我正在寻找在相对较大的表中进行相对复杂查询的最有效方法。 概念是: 我有一个表,其中包含可以相互并行运行的阶段的记录 记录量超过 500 万(并且还在增加) 时间段从大约 5 年前开始 由于性能原因,
我已经搜索了我的问题的解决方案,这个 question describes it perfectly . Let´s say I have one table called ProjectTimeSp
如何获取 varchar2 列中允许的最大和最小长度。我必须测试来自某个远程数据库的临时表的传入数据。并且要针对特定列测试每一行值是否具有可以设置到该列中的最大值或最小值。 所以我要使用其架构详细
我是一名优秀的程序员,十分优秀!