如果使用MVC不存在,如何创建表 [英] How to create table if it not exist using MVC

查看:110
本文介绍了如果使用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


这篇关于如果使用MVC不存在,如何创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆