ALTER 与 DROP &在 SQL Server 中创建 [英] ALTER vs DROP & CREATE in SQL Server

查看:17
本文介绍了ALTER 与 DROP &在 SQL Server 中创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 SQL Server 中创建存储过程后,为什么要将 Create 替换为 Alter?如果我们不改变它,执行时会发生什么?除了检查是否存在并删除之外,还有更好的替代方法吗?

After creating stored procedure in SQL Server why to replace Create with Alter? What will happen on execution if we do not change it? Is there a better alternate to it other then checking if exist and drop?

推荐答案

Create 如果表存在将失败.如果表不存在,Alter 将失败.

Create will fail if table exists. Alter will fail if table does not exist.

如果你问为什么要使用 Alter 如果你可以删除和创建,有几个原因:

If you ask why to use Alter if you can drop and create, a few reasons:

  • 某些权限已分配给对象,如果您删除它,则需要重新授予权限
  • 对象可能被其他具有模式绑定的对象使用

这篇关于ALTER 与 DROP &在 SQL Server 中创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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