只能說我菜,在網上找了下沒發現誰解釋過他們四個的區別,那就只能自己來了。下面是通過mysql客戶端查看到的幫助信息,直接貼解釋吧。
user:Returns the current MySQL username and hostname as a string in the utf8 character set.
system_user:SYSTEM_USER() is a synonym for USER().
session_user:SESSION_USER() is a synonym for USER().
current_user:
Returns the username and hostname combination for the MySQL account
that the server used to authenticate the current client. This account
determines your access privileges. As of MySQL 5.0.10, within a stored
routine that is defined with the SQL SECURITY DEFINER characteristic,
CURRENT_USER() returns the creator of the routine. The return value is
a string in the utf8 character set.
The value of CURRENT_USER() can differ from the value of USER().
其實想翻一下再放出來的,怎奈自己那見不人的英語水平,就不翻譯了。總的來說:user()、system_user()、session_user(),這三是同一個東西(synonym )。然後current_user()跟前三個也很像,不過他偶爾又會有點區別。