mysql自定义函数怎么写?

2024-10-28 01:57:30
推荐回答(1个)
回答1:

mysql> CREATE FUNCTION HelloWorld4()

-> RETURNS VARCHAR(20)

-> BEGIN

->   RETURN 'Hello World!';

-> END;

-> //

Query OK, 0 rows affected (0.00 sec)

mysql> select HelloWorld4() //

+---------------+

| HelloWorld4() |

+---------------+

| Hello World!  |

+---------------+

1 row in set (0.00 sec) ...展开mysql> CREATE FUNCTION HelloWorld4()

-> RETURNS VARCHAR(20)

-> BEGIN

->   RETURN 'Hello World!';

-> END;

-> //

Query OK, 0 rows affected (0.00 sec)

mysql> select HelloWorld4() //

+---------------+

| HelloWorld4() |

+---------------+

| Hello World!  |

+---------------+

1 row in set (0.00 sec)