Mysql评论信息显示

时间:2018-04-16 03:55:18

标签: mysql comments display

关于评论显示的问题,示例如下:

DROP FUNCTION IF EXISTS `foo`;
delimiter //
-- comment1
-- comment2
-- comment3
CREATE FUNCTION foo()
  RETURNS int(1)
BEGIN   
SET @var1 = @var1 + 1;   /* information here */
RETURN @var1;   
END;
//
delimiter ;

show create function foo;

函数foo的结果没有包含任何注释,反正只是出于开发目的显示注释?

1 个答案:

答案 0 :(得分:0)

仅当您在功能正文中包含注释时。

如果您在* nix平台上使用mysql cli,您可以通过设置PAGER来删除注释,然后使用SHOW CREATE PROCEDURE dbname.procedure_name或查询information_schema例程表。不要忘记之后重置PAGER。

e.g。

mysql> pager grep '\-\-'
PAGER set to 'grep '\-\-''

mysql> select routine_definition from information_schema.routines where routine_name = 'myaes_convert'\G
  DECLARE gtg TINYINT DEFAULT 0;     -- OK to proceed
  DECLARE vtable_schema VARCHAR(64); -- cursor var
  DECLARE vtable_name VARCHAR(64);   -- cursor var 
    -- Perform Backups on columns
    -- Perform Index backup
    -- Drop indexes
    -- Call column converter
    -- Create triggers on table
    -- Restore indexes and log
    -- rename the table _myaes
    -- create the view for this table
  SELECT 1; -- Phew!
1 row in set (0.02 sec)

mysql> pager
Default pager wasn't set, using stdout.

mysql> pager grep '\-\-'
PAGER set to 'grep '\-\-''

mysql> show create procedure myaes.myaes_convert\G
  DECLARE gtg TINYINT DEFAULT 0;     -- OK to proceed
  DECLARE vtable_schema VARCHAR(64); -- cursor var
  DECLARE vtable_name VARCHAR(64);   -- cursor var 
    -- Perform Backups on columns
    -- Perform Index backup
    -- Drop indexes
    -- Call column converter
    -- Create triggers on table
    -- Restore indexes and log
    -- rename the table _myaes
    -- create the view for this table
  SELECT 1; -- Phew!
1 row in set (0.00 sec)

mysql> pager
Default pager wasn't set, using stdout.