MySQL Tutorial/Procedure Function/VARCHAR
Версия от 13:44, 26 мая 2010; (обсуждение)
VARCHAR(255) DEFAULT "This will not be padded"
mysql>
mysql> delimiter $$
mysql>
mysql> CREATE PROCEDURE myProc()
-> BEGIN
-> DECLARE l_varchar VARCHAR(255) DEFAULT "This will not be padded";
->
-> select l_varchar;
-> END$$
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
mysql>
mysql> call myProc();
+-------------------------+
| l_varchar |
+-------------------------+
| This will not be padded |
+-------------------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> drop procedure myProc;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>
VARCHAR type variable
mysql>
mysql>
mysql> delimiter $$
mysql>
mysql> CREATE PROCEDURE myProc()
-> BEGIN
-> DECLARE my_varchar VARCHAR(30)
-> DEFAULT "Hello World!"; /* 30 bytes of text*/
->
-> select my_varchar;
-> END$$
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
mysql>
mysql> call myProc();
+--------------+
| my_varchar |
+--------------+
| Hello World! |
+--------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> drop procedure myProc;
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql>