【问题标题】:Database provisioning of a multi tenant application多租户应用程序的数据库供应
【发布时间】:2012-08-14 17:49:06
【问题描述】:

我正在开发一个多租户应用程序,其中将自动执行配置过程。

配置过程将创建一个包含表、过程、函数的新 SQL Server 数据库,并将默认数据插入数据库。

我的问题是执行此过程的最佳方法是什么?

【问题讨论】:

  • 您想即时为新客户创建新数据库?并想知道哪种方法最好?
  • “通过以管理员帐户运行初始化 TSQL 脚本,替换 db-name”是否是一个太明显的答案?
  • 试试 PowerShell,powertool 来做这个
  • @CuongLe 本身并不是很有启发性......
  • 我刚刚添加了答案,请检查

标签: c# sql-server-2008 multi-tenant


【解决方案1】:

我的感受是:

1.Create multiple sets of SQL scripts like DBScripts,TableScripts,ProcScripts ect.
2.In DBScripts,just add create database code and here you can hardcode the db name also.
3.And whenver there are any changes in these scripts you can edit and release the new build for the client.

4.Client just has to click some button on front end to create DB,Tables,Sprocs etc.

【讨论】:

    【解决方案2】:

    在尝试从 C# 执行数据库脚本时,我决定使用以下脚本以编程方式恢复数据库。

    RESTORE FILELISTONLY
    FROM DISK = 'C:\BaackUpFile.bak'
    
    RESTORE DATABASE DbName
    FROM DISK = 'C:\BaackUpFile.bak'
    WITH MOVE 'YourMDFLogicalName' TO 'C:\DataYourMDFFile.mdf',
    MOVE 'YourLDFLogicalName' TO 'C:\DataYourLDFFile.ldf'
    

    【讨论】:

      猜你喜欢
      • 2017-12-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-04
      • 2014-11-01
      • 2012-04-26
      • 1970-01-01
      相关资源
      最近更新 更多