|Function type:||Information function|
The CONNECTION_ID() function returns the connection ID for the current connection (session).
Each connection has an ID that is unique among currently connected clients. This also applies to events.
|The examples were created with the MyWAY SQL manager: |
How to use the CONNECTION_ID() function in MySQL and MariaDB databases
|In MySQL and MariaDB the CONNECTION_ID() function is used to get the unique identifier that the assigned to the current client connection (session). The function returns an integer value representing the connection ID assigned to each client connection by the database server. The function requires no arguments and can be used directly in SQL statements or within SQL queries.|
Each client connection is assigned a unique connection ID, which is used to distinguish and manage connections within the database server. The connection ID can be used for tracking and monitoring purposes, for example, logging connection activity, monitoring, or identifying long-running queries related to specific connections. Additionally, the connection ID can be used in combination with custom functions or procedures to implement custom access control or perform specific actions based on the client connection.
The connection ID is only available for the current session and does not persist across different sessions or server restarts.
Further MySQL und MariaDB SQL Information functions