Plsql-arithmetic-operators

提供:Dev Guides
移動先:案内検索

PL/SQL-算術演算子

次の表に、PL/SQLでサポートされているすべての算術演算子を示します。 *変数A *が10を保持し、*変数B *が5を保持すると仮定します-

Operator Description Example
+ Adds two operands A + B will give 15
- Subtracts second operand from the first A - B will give 5
* Multiplies both operands A* B will give 50
/ Divides numerator by de-numerator A/B will give 2
* * Exponentiation operator, raises one operand to the power of other A* *B will give 100000

BEGIN
   dbms_output.put_line( 10 + 5);
   dbms_output.put_line( 10 - 5);
   dbms_output.put_line( 10* 5);
   dbms_output.put_line( 10/5);
   dbms_output.put_line( 10 ** 5);
END;
/

上記のコードがSQLプロンプトで実行されると、次の結果が生成されます-

15
5
50
2
100000

PL/SQL procedure successfully completed.