MySQL Tutorial/Procedure Function/BIGINT

Материал из SQL эксперт
Перейти к: навигация, поиск

Big integer with default value

mysql>
mysql> delimiter $$
mysql>
mysql> CREATE PROCEDURE myProc()
    -> BEGIN
    ->      DECLARE l_bigint1   BIGINT DEFAULT 4000000000000000;
    ->
    ->     select l_bigint1;
    -> END$$
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
mysql>
mysql> call myProc();
+------------------+
| l_bigint1        |
+------------------+
| 4000000000000000 |
+------------------+
1 row in set (0.02 sec)
Query OK, 0 rows affected (0.02 sec)
mysql>
mysql> drop procedure myProc;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>


Declare a big integer

mysql> delimiter $$
mysql>
mysql> CREATE PROCEDURE myProc()
    -> BEGIN
    ->     DECLARE my_big_integer BIGINT;        /* 64-bit integer */
    ->
    ->     set my_big_integer= 111111111111111111111;
    ->
    ->     select "my_big_integer="+my_big_integer;
    -> END$$
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
mysql>
mysql> call myProc();
+----------------------------------+
| "my_big_integer="+my_big_integer |
+----------------------------------+
|             9.2233720368548e+018 |
+----------------------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected, 2 warnings (0.00 sec)
mysql>
mysql> drop procedure myProc;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>