In MariaDB, USER() è una funzione integrata che restituisce il nome utente e il nome host correnti di MariaDB, forniti durante l'autenticazione a MariaDB.
Sintassi
La sintassi è questa:
USER() Nessun argomento è richiesto o accettato.
Esempio
Ecco un esempio da dimostrare:
SELECT USER(); Risultato:
+------------------+ | USER() | +------------------+ | example@sqldat.com | +------------------+
USER() vs CURRENT_USER()
Il USER() la funzione non restituisce sempre lo stesso risultato di CURRENT_USER() funzione.
Ad esempio, se ci colleghiamo utilizzando anonymous :
mariadb --user="anonymous"
Quindi esegui USER() e CURRENT_USER() :
SELECT
USER(),
CURRENT_USER; Risultato:
+---------------------+--------------+ | USER() | CURRENT_USER | +---------------------+--------------+ | example@sqldat.com | @localhost | +---------------------+--------------+
Nessun argomento è accettato
Passaggio di qualsiasi argomento a USER() restituisce un errore:
SELECT USER(123); Risultato:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '123)' at line 1
Dichiarazioni che utilizzano USER() funzione o uno dei suoi sinonimi (SYSTEM_USER() e SESSION_USER() ) non sono sicuri per la replica a livello di istruzioni.