You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Oracle PL/SQL中能否使用双星号(**)作为幂运算符?

Oracle中双星号(**)无法作为幂运算符的说明
  • Oracle的SQL和PL/SQL环境均不支持以双星号(**)作为幂运算的运算符,实现幂运算只能使用内置的POWER()函数。
  • 报错的SQL测试语句:
select (2 **3) from dual;  ---执行报错
  • 报错的PL/SQL测试块:
declare
 kkk number;
begin
 select (2**3) into kkk from dual;
end;
  • 正确的幂运算写法:
    使用POWER(base, exponent)函数,SQL示例:
select POWER(2, 3) from dual; -- 返回结果8

PL/SQL块示例:

declare
 kkk number;
begin
 select POWER(2, 3) into kkk from dual;
 dbms_output.put_line(kkk); -- 输出结果8
end;

内容的提问来源于stack exchange,提问作者fred wu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 19:20:20