In MySQL, the sys.ps_thread_stack()
function returns a JSON formatted stack of all statements, stages, and events within the Performance Schema for a given thread ID.
Tag: what is
Understanding the sys.extract_schema_from_file_name() Function in MySQL
In MySQL, the sys.extract_schema_from_file_name()
function is a stored function in the sys
schema.
It accepts a path name, and returns the path component that represents the schema name.
This enables us to get the schema from a given file path.
Continue readingSERIAL vs AUTO_INCREMENT in MySQL
If you’ve ever encountered a SERIAL
column in a MySQL database, you might’ve wondered how it differs from an AUTO_INCREMENT
column. After all, they both generate values that automatically increment?
Read on to find out what the difference is between SERIAL
and AUTO_INCREMENT
in MySQL.
Using the sys.format_statement() Function in MySQL to Truncate a SQL Statement
In MySQL, the sys.format_statement()
system function reduces the length of a given string/SQL statement to the length stored in the statement_truncate_len
configuration option.
This function can be handy for truncating potentially long SQL statements retrieved from Performance Schema tables into a more suitable length (64 characters by default).
Continue readingUnderstanding the PS_THREAD_ID() Function in MySQL
In MySQL, we can use the PS_THREAD_ID()
function to get the Performance Schema thread ID assigned to a given connection ID. This can be useful whenever we use a function that takes the thread ID as its parameter, but we only know the connection ID.
If no thread ID exists for the connection, then NULL
is returned.
The built-in PS_THREAD_ID()
function does the same thing as the now deprecated sys.ps_thread_id()
function. Therefore, we can call the function without needing to qualify it with sys
or making sys
our current schema.
Understanding INFORMATION_SCHEMA in SQL
Behind every well-structured and organised SQL database lies a treasure trove of information called metadata. Metadata is data that provides information about other data. In relational database management systems, this metadata can typically include information like the names of databases, tables, columns, the data type of a column, access privileges, and much more.
The SQL standard provides a collection of tables/views that allow us to view metadata about the objects in the database. The SQL standard refers to this as the information schema and calls it INFORMATION_SCHEMA
.
Using the sys.format_path() Function to Dynamically Replace a Subpath with its Equivalent System Variable in MySQL
In MySQL, the sys.format_path()
function is a stored function in the sys
schema. It accepts a path name, and returns the modified path name after replacing subpaths that match the values of certain system variables.
So we can use the function to dynamically replace part or all of our path with a system variable that matches that path segment.
Continue readingUnderstanding the sys.extract_table_from_file_name() Function in MySQL
In MySQL, the sys.extract_table_from_file_name()
function is a stored function in the sys
schema.
It accepts a path name, and returns the path component that represents the table name.
Continue readingHow to Use the sys.ps_is_account_enabled() Function in MySQL
In MySQL, we can use the sys.ps_is_account_enabled()
function to check whether Performance Schema instrumentation for a given account is enabled.
The function returns YES
or NO
, depending on whether or not the instrumentation for the given account is enabled.
Using the sys.ps_thread_account() Function to Get the Account for a Given Thread IDÂ in MySQL
In MySQL, the sys.ps_thread_account()
function returns the account associated with a given thread ID. It returns the account in the form user_name@host_name
.