zoukankan      html  css  js  c++  java
  • mysql GET DIAGNOSTICS 语法

    MySQL 5.6 提供了 get diagnostic 语句来获取错误缓冲区的内容,然后把这些内容输出到不同范围域的变量里,以便我们后续灵活操作 语法如下:

    GET [CURRENT] DIAGNOSTICS
    {
        statement_information_item
        [, statement_information_item] ... 
      | CONDITION condition_number
        condition_information_item
        [, condition_information_item] ...
    }
    
    statement_information_item:
        target = statement_information_item_name
    
    condition_information_item:
        target = condition_information_item_name
    
    statement_information_item_name:
        NUMBER
      | ROW_COUNT
    
    condition_information_item_name:
        CLASS_ORIGIN
      | SUBCLASS_ORIGIN
      | RETURNED_SQLSTATE
      | MESSAGE_TEXT
      | MYSQL_ERRNO
      | CONSTRAINT_CATALOG
      | CONSTRAINT_SCHEMA
      | CONSTRAINT_NAME
      | CATALOG_NAME
      | SCHEMA_NAME
      | TABLE_NAME
      | COLUMN_NAME
      | CURSOR_NAME
    
    condition_number, target:
        (see following discussion)

    例子:获取删除表时的错误信息

    mysql> DROP TABLE test.no_such_table;
    ERROR 1051 (42S02): Unknown table 'test.no_such_table'
    mysql> GET DIAGNOSTICS CONDITION 1
        ->   @p1 = RETURNED_SQLSTATE, @p2 = MESSAGE_TEXT;
    mysql> SELECT @p1, @p2;
    +-------+------------------------------------+
    | @p1   | @p2                                |
    +-------+------------------------------------+
    | 42S02 | Unknown table 'test.no_such_table' |
    +-------+------------------------------------+

    参考:

    13.6.7.3 GET DIAGNOSTICS Syntax

  • 相关阅读:
    SQL基础学习_03_数据更新
    SQL基础学习_02_查询
    SQL基础学习_01_数据库和表
    HCA数据下载
    Multiclonal Invasion in Breast Tumors Identified by Topographic Single Cell Sequencing
    gg_pie
    ggnetwork
    ggplot2画简单的heatmap
    简单R语言爬虫
    突变数据清洗
  • 原文地址:https://www.cnblogs.com/langtianya/p/5534222.html
Copyright © 2011-2022 走看看