postgresql := 在 SQL 中的含义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27859983/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:44:38  来源:igfitidea点击:

Meaning of := in SQL

sqlpostgresqlplpgsqlcolon-equals

提问by beniaminp

What does the :=operator mean in SQL? I am using Postgresql and I have no idea what it means. I have this code :

:=SQL中的运算符是什么意思?我正在使用 Postgresql,但我不知道它是什么意思。我有这个代码:

DECLARE
  i RECORD;
  q TEXT[];
  cfg_rec RECORD;
BEGIN
  SELECT * FROM xxx_private.function() INTO cfg_rec;
  q:=q || cfg_rec.q;

回答by Mureinik

:=isn't an SQL operator. It's a PL/pgSQLoperator (similar syntex can be found in PL1, Oracle's PL/SQL and even Pascal). Anyway, this is the assignment operator. In your case, it appends cfg_rec.qto the previous value of q(the ||operator), and then assigns it back to the qvariable you defined in the declareblock.

:=不是 SQL 运算符。它是一个PL/pgSQL运算符(类似的语法可以在 PL1、Oracle 的 PL/SQL 甚至 Pascal 中找到)。无论如何,这是赋值运算符。在您的情况下,它将附加cfg_rec.qq||运算符)的前一个值,然后将其分配回q您在declare块中定义的变量。