是否有数据库支持其命令行界面上的修订控制?
是否有数据库支持其命令行界面上的修订控制?
例如,我在 mysql>命令提示符。我要向表中添加一列。我输入 更改表 X 添加列 Y bigint; 然后数据库提示我: “好的。使用 git 检查这些更改吗?” 我回答是,它会打印出架构的修订号。
(不需要 mysqldump 来获取架构、删除数据并在 bash 命令行签入。)
在另一次,我决定也签入我的所有数据。所以我输入类似的内容 检查快照表 X
对我来说似乎是一种常识性方法,但是有人修改过数据库来支持这种行为吗?
谢谢
Does any database support revision control on its command line interface?
So for instance, I'm at the mysql> command prompt. I'm going to add a column to a table. I type
ALTER TABLE X ADD COLUMN Y bigint;
and then the database prompts me:
"OK. Check these changes in using git?"
I respond yes, and it prints out the revision number for the schema.
(No need for a mysqldump to get the schema, removing the data, and checkin at the bash command line.)
At another time, I decide to check in all of my data as well. So I type something like
CHECKIN SNAPSHOT TABLE X
Seems like a common sense approach to me, but has anyone modified a database to support such behavior?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,一方面,签入一张表是没有意义的;另一方面,它是一个关系数据库是有原因的;您不能只是将一个表回滚到之前的状态并期望一切正常。
相反,您可以将整个数据库回滚到以前的状态。数据库界称之为“时间点恢复”;您可以在 MySQL 中结合完整备份和复制日志来完成此操作。
我不知道为什么你想将备份存储在 git 中。
Well, for one thing, checking in one table makes no sense; its a relational database for a reason; you can't just roll back one table to a previous state and expect that to be OK.
Instead, you can roll back the entire database to a previous state. The database world calls this "point in time recovery"; and you can do it in MySQL with a combination of a full backup and replication logs.
I have no idea why you'd want to store your backups in git.
我相信你正在寻找的是“迁移”。这些通常是在代码级别而不是数据库级别完成的。 Rails 支持迁移,Django 支持 南,我确信那里还有其他人。
这些迁移只是可以签入的代码文件(采用所选的编程语言或 SQL 脚本)。
通常的情况是架构迁移,不迁移数据,但有些(大多数?)允许您编写自定义代码如果你愿意的话就这样做吧。
一般来说,您不希望对数据进行版本控制,但也有例外,即某些数据是逻辑的一部分,但您通常希望将您认为是功能一部分的数据类型与您不认为是功能的部分分开't。
如果您想存储所有内容,那就称为备份。这些通常不会仅仅因为大小而参与版本控制。要么它是二进制格式,不能很好地区分,要么它比文本格式所需的大小大很多倍。如果您需要比较数据,也有相应的工具。
What you're looking I believe are "migrations". These are usually done at the code level rather than at the database level. Rails supports migrations, Django does with South, I'm sure there's others out there as well.
These migrations are just code files (either in the programming language of choice, or sql scripts) that can be checked in.
The usual case is Schema migrations that don't migrate data but some (most?) allow you to write custom code to do so if you wish.
Generally speaking you wouldn't want to version control data, but there are exceptions when some of the data is part of the logic, but you generally want to separate the type of data that you consider part of the functionality and the parts that you don't.
If you want to store everything, that's just called backing up. Those generally don't do into version control just because of the size. Either it's in a binary format that doesn't diff well, or it's many times larger than it needs to be in a text format. If you need to diff the data, there are tools for that as well.