以编程方式创建和更新数据库结构 [英] Create and update programmatically database structure
问题描述
我想通过向客户更新我的软件来创建和更新数据库结构.
i would like to create and update database structure through the update of my software to customer.
最好的方法是什么?也许使用 Sql(创建表、更改表等)?谢谢
What is the best way ? Maybe Using Sql (create table, alter table etc.) ? Thanks
推荐答案
我看不到除了使用 SQL 语句(例如 CREATE TABLE
、ALTER TABLE
)之外的任何其他方法和 DROP TABLE
.您可能希望在某处放置一个架构版本号,以检查您的帮助脚本必须运行哪些更新才能更新数据库架构.这可能比使 SQL 语句具有幂等性更容易,因为您通常还需要进行一些数据转换.
I don't see any other way than using SQL statements such as CREATE TABLE
, ALTER TABLE
and DROP TABLE
. You might want to put somewhere a schema version number in order to check what updates your helper script must run in order to update the database schema. This is probably easier than making SQL statements idempotent, as often you also need to do some data conversion too.
这篇关于以编程方式创建和更新数据库结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!