将简单的元数据附加到MySQL数据库 [英] Attaching simple metadata to a MySQL database

查看:130
本文介绍了将简单的元数据附加到MySQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以将一些元数据附加到MySQL数据库?我正在尝试编写代码以在代码升级需要它时自动更新数据库模式.这需要存储一个整数值-架构版本.我当然可以为此创建一个整个表,但是对于一个简单的数字来说似乎有点过分了.

Is there a way to attach a piece of metadata to a MySQL database? I'm trying to write code to automatically update the database schema whenever a code upgrade requires it. This requires the storage of a single integer value -- the schema version. I could of course create a whole table for it, but that seems like overkill for just a simple number.

推荐答案

您可以使用表注释来存储版本:

You can use table comments to store the version:

ALTER TABLE table1 COMMENT = '1.4';

您必须进行正则表达式才能从中获得评论:

You'll have to regex to get the comment from this:

SHOW CREATE TABLE table1;
/COMMENT='(.*)'/

这篇关于将简单的元数据附加到MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆