文档首页 > > 工具指南> Migration Tool SQL语法迁移工具> Teradata语法迁移> DML> NAMED

NAMED

分享
更新时间: 2019/08/09 GMT+08:00

Teradata中的NAMED用于为表达式或列分配临时名称。用于表达式的NAMED语句在DWS中被迁移为AS。用于列名的NAMED语句保留在相同的语法中。

输入:NAMED表达式迁移为AS

SELECT Name, ((Salary + (YrsExp * 200))/12) (NAMED Projection)
  FROM Employee
 WHERE DeptNo = 600 AND Projection < 2500;

输出

SELECT Name, ((Salary + (YrsExp * 200))/12) AS  Projection
  FROM Employee
 WHERE DeptNo = 600 AND ((Salary + (YrsExp * 200))/12)  < 2500;

输入:用于列名的NAMED AS

SELECT product_id AS id
  FROM emp where pid=2 or id=2;

输出

SELECT product_id (NAMED "pid") AS id
  FROM emp where product_id=2 or product_id=2;

输入:用于列名的NAMED( )

INSERT INTO Neg100 (NAMED,ID,Dept) VALUES ('TEST',1,'IT');

输出

INSERT INTO Neg100 (NAMED,ID,Dept) SELECT 'TEST',1, 'IT';

输入:使用不含AS的NAMED别名和TITLE别名

SELECT dept_name (NAMED alias1) (TITLE alias2 ) 
  FROM employee 
 WHERE dept_name like 'Quality';

输出

SELECT dept_name 
    AS alias1 
  FROM employee
 WHERE dept_name like 'Quality';

输入:使用包含AS的NAMED别名和TITLE别名

Migration Tool将跳过NAMED别名和TITLE别名,并仅使用AS别名。

SELECT sale_name (Named alias1 ) (Title alias2) 
    AS alias3 
  FROM employee 
 WHERE sname = 'Stock' OR sname ='Sales';

输出

SELECT sale_name 
    AS alias3 
  FROM employee 
 WHERE sname = 'Stock' OR sname ='Sales';

输入:NAMEDTITLE

NAMED和TITLE一起使用,在括号中用逗号隔开。

SELECT customer_id (NAMED cust_id, TITLE 'Customer Id')
FROM Customer_T 
WHERE cust_id > 10;

输出

SELECT cust_id AS "Customer Id" 
FROM   (SELECT customer_id AS cust_id 
                FROM   customer_t 
                WHERE  cust_id > 10); 
分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!

非常感谢您的反馈,我们会继续努力做到更好!

反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

跳转到云社区