简体   繁体   English

在SQL中自动创建数据库/表

[英]Automatic Database/Table Creation in SQL

I have a really weird idea that I can't find information on anywhere; 我有一个很奇怪的想法,就是我找不到任何地方的信息。 I want to make it so when a new "parent user"/"admin" signs up, then a new database is created and appropriate table, this would mean that I would need a command/script to grab the connection string respective to each database and somehow place it into a asp.net web form, surely this would be less complicated than using a token to identify a user than pull all data in respect to them, that way each users data would be stored on a separate database but still have things in common with the main database? 我要这样做,以便在注册新的“父用户” /“ admin”时创建一个新数据库并创建适当的表,这意味着我将需要一个命令/脚本来获取每个数据库各自的连接字符串并以某种方式将其放入asp.net网络表单中,这肯定比使用令牌来标识用户要简单,而不是提取有关他们的所有数据,这样每个用户的数据将存储在单独的数据库中,但仍然具有与主数据库有什么共同点?

Assuming you are usign an MS SQL Database then you can create all the desired tables in the model database. 假设您使用的是MS SQL数据库,则可以在模型数据库中创建所有所需的表。 This way when you create any new database it will always have the default tables you need. 这样,当您创建任何新数据库时,它将始终具有所需的默认表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM