Skip to main content
Glama
Teradata

Teradata MCP Server

Official
by Teradata

dba_tableSqlList

Retrieve SQL queries executed against a Teradata table within a specified timeframe to analyze database activity and monitor table usage patterns.

Instructions

Get a list of SQL run against a table in the last number of days.

Arguments: table_name - table name no_days - number of days

Returns: ResponseType: formatted response with query results + metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
no_daysNo

Implementation Reference

  • The core handler function implementing the 'dba_tableSqlList' tool. It executes a SQL query to retrieve recent queries against a specified table from Teradata's query log views (DBC.QryLogSqlV and DBC.QryLogV), formats the results using utility functions, and returns a structured response with metadata.
    def handle_dba_tableSqlList(conn: TeradataConnection, table_name: str, no_days: int | None = 7,  *args, **kwargs):
        """
        Get a list of SQL run against a table in the last number of days.
    
        Arguments:
          table_name - table name
          no_days - number of days
    
        Returns:
          ResponseType: formatted response with query results + metadata
        """
        logger.debug(f"Tool: handle_dba_tableSqlList: Args: table_name: {table_name}, no_days: {no_days}")
    
        with conn.cursor() as cur:
            if table_name == "":
                logger.debug("No table name provided")
            else:
                logger.debug(f"Table name provided: {table_name}, returning SQL queries for this table.")
                rows = cur.execute(f"""SELECT t1.QueryID, t1.ProcID, t1.CollectTimeStamp, t1.SqlTextInfo, t2.UserName
                FROM DBC.QryLogSqlV t1
                JOIN DBC.QryLogV t2
                ON t1.QueryID = t2.QueryID
                WHERE t1.CollectTimeStamp >= CURRENT_TIMESTAMP - INTERVAL '{no_days}' DAY
                AND t1.SqlTextInfo LIKE '%{table_name}%'
                ORDER BY t1.CollectTimeStamp DESC;""")
    
            data = rows_to_json(cur.description, rows.fetchall())
            metadata = {
                "tool_name": "dba_tableSqlList",
                "table_name": table_name,
                "no_days": no_days,
                "total_queries": len(data)
            }
            logger.debug(f"Tool: handle_dba_tableSqlList: metadata: {metadata}")
            return create_response(data, metadata)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Teradata/teradata-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server