1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
SET timestamp=UNIX_TIMESTAMP('2014-09-30 08:00:00');
CREATE FUNCTION f1(str char(20))
RETURNS CHAR(100)
RETURN CONCAT('Hello, ', str, '!');
SELECT * FROM mysql.proc WHERE name like 'f1';
db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment character_set_client collation_connection db_collation body_utf8
test f1 FUNCTION f1 SQL CONTAINS_SQL NO DEFINER str char(20) char(100) CHARSET latin1 RETURN CONCAT('Hello, ', str, '!') root@localhost 2014-09-30 08:00:00 2014-09-30 08:00:00 NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION latin1 latin1_swedish_ci latin1_swedish_ci RETURN CONCAT('Hello, ', str, '!')
SELECT f1('world');
f1('world')
Hello, world!
CREATE FUNCTION f1(str char(20))
RETURNS TEXT
RETURN CONCAT('Hello2, ', str, '!');
ERROR 42000: FUNCTION f1 already exists
SELECT body FROM mysql.proc WHERE name like 'f1';
body
RETURN CONCAT('Hello, ', str, '!')
CREATE FUNCTION IF NOT EXISTS f1(str char(20))
RETURNS CHAR(100)
RETURN CONCAT('Hello3, ', str, '!');
Warnings:
Note 1304 FUNCTION f1 already exists
SELECT body FROM mysql.proc WHERE name like 'f1';
body
RETURN CONCAT('Hello, ', str, '!')
CREATE OR REPLACE FUNCTION IF NOT EXISTS f1(str char(20))
RETURNS CHAR(100)
RETURN CONCAT('Hello4, ', str, '!');
ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS
SELECT body FROM mysql.proc WHERE name like 'f1';
body
RETURN CONCAT('Hello, ', str, '!')
CREATE OR REPLACE FUNCTION f1(str char(20))
RETURNS CHAR(100)
RETURN CONCAT('Hello5, ', str, '!');
SELECT body FROM mysql.proc WHERE name like 'f1';
body
RETURN CONCAT('Hello5, ', str, '!')
DROP FUNCTION f1;
CREATE FUNCTION IF NOT EXISTS f1(str char(20))
RETURNS CHAR(100)
RETURN CONCAT('Hello6, ', str, '!');
SELECT body FROM mysql.proc WHERE name like 'f1';
body
RETURN CONCAT('Hello6, ', str, '!')
SELECT f1('world');
f1('world')
Hello6, world!
DROP FUNCTION IF EXISTS f1;
SELECT body FROM mysql.proc WHERE name like 'f1';
body
DROP FUNCTION IF EXISTS f1;
Warnings:
Note 1305 FUNCTION test.f1 does not exist
|