Go to the first, previous, next, last section, table of contents.


Miscellaneous functions.

DATABASE()
Returns current database name.
mysql> select DATABASE();               -> 'test'
USER()
SYSTEM_USER()
SESSION_USER()
Returns current user name.
mysql> select USER();                   -> 'davida'
PASSWORD(String)
Calculates a password string from plaintext password String. This must be used to store a password in the 'user' grant table.
mysql> select PASSWORD('badpwd');       -> '7f84554057dd964b'
ENCRYPT(String[, Salt])
Crypt String with the unix crypt() command. The Salt should be a string with 2 characters. If crypt() was not found NULL will always be returned.



LAST_INSERT_ID()
Returns the last automatically generated value that was set in an auto_increment column. See section How can I get the unique ID for the last inserted row?.
mysql> select LAST_INSERT_ID();         -> 1
FORMAT(Nr, Num)
Formats number Nr to a Format like '#,###,###.##' with Num decimals.
mysql> select FORMAT(12332.33, 2);      -> '12,332.33'
VERSION
Return the version of the MySQL server.
mysql> select version();                -> '3.21.16-beta-log'
GET_LOCK(String,timeout)
Tries to get a lock on named 'String' with a timeout of 'timeout' seconds. Returns 1 if one got the lock, 0 on timeout and NULL on error (like out of memory or if thread was killed with mysqladmin kill. A lock is released if one executes RELEASE_LOCK, executes a new GET_LOCK or if the thread ends. This function can be used to implement application locks or simulate record locks.
mysql> select get_lock("automaticly released",10);     -> 1
mysql> select get_lock("test",10);		       -> 1
mysql> select release_lock("test");                    -> 1
mysql> select release_lock("automaticly released")     -> NULL
RELEASE_LOCK(String)
Releases a lock this thread has got with GET_LOCK. Returns 1 if the lock was released, 0 if lock wasn't locked by this thread and NULL if the lock 'String' didn't exist.


Go to the first, previous, next, last section, table of contents.