In MariaDB, SYSTEM_USER() è un sinonimo di USER() funzione. Restituisce il nome utente e il nome host correnti di MariaDB, forniti durante l'autenticazione a MariaDB.
Sintassi
La sintassi è questa:
SYSTEM_USER() Nessun argomento è richiesto o accettato.
Esempio
Ecco un esempio da dimostrare:
SELECT SYSTEM_USER(); Risultato:
+------------------+ | SYSTEM_USER() | +------------------+ | example@sqldat.com | +------------------+
SYSTEM_USER() vs CURRENT_USER()
C'è anche un'altra funzione chiamata CURRENT_USER() che fa una cosa simile. Tuttavia, non restituisce sempre lo stesso risultato di SYSTEM_USER() .
Ad esempio, se ci colleghiamo utilizzando anonymous :
mariadb --user="anonymous"
Quindi esegui SYSTEM_USER() e CURRENT_USER() :
SELECT
SYSTEM_USER(),
CURRENT_USER; Risultato:
+---------------------+--------------+ | SYSTEM_USER() | CURRENT_USER | +---------------------+--------------+ | example@sqldat.com | @localhost | +---------------------+--------------+
Ma se torniamo alla nostra sessione precedente (nella finestra del terminale originale), ogni funzione restituisce gli stessi risultati:
SELECT
SYSTEM_USER(),
CURRENT_USER; Risultato:
+------------------+------------------+ | SYSTEM_USER() | CURRENT_USER | +------------------+------------------+ | example@sqldat.com | example@sqldat.com | +------------------+------------------+
Nessun argomento è accettato
Passaggio di qualsiasi argomento a SYSTEM_USER() restituisce un errore:
SELECT SYSTEM_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 il SYSTEM_USER() funzione (o USER() e SESSION_USER() ) non sono sicuri per la replica a livello di istruzioni.