如果使用MVC不存在,如何创建表
问题描述:
我有员工表格
其中用户名,电子邮件,电话号码字段。
我是什么需要!
为数据库模式创建一个脚本。应该可以多次运行数据库脚本,所以它应该只创建表他们不存在。
我尝试过:
我不明白我该怎么做。
I have employee form
where Username, email, phone numbers field.
what I required!
create a script for database schema.it should be possible to run database script multiple time so it should create tables only if they don't exist.
What I have tried:
I do not understand how can I do this.
答
sql - 有条件地创建数据库和表 - 堆栈溢出 [ ^ ]
使用此sql脚本。如果数据库中不存在表,则将创建表。
Use this sql script. Table will be created if table is not exist in database.
IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = N'TableName')
BEGIN
CREATE TABLE tableName(
......
)
END