SQL Server 列的默认值 [英] SQL Server Default value for columns

查看:76
本文介绍了SQL Server 列的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您在 SQL Server Management Studio 表设计器中为列使用默认值时,SSMS 会更改您的默认值并在其周围加上括号(在 SQL Server 的所有版本和所有版本中).例如,如果您将 0 设置为默认值,则此默认值更改为 (0).不知道sql server为什么要用括号,有没有实际的原因.

When you use default value for a column in SQL Server Management Studio table designer, SSMS change your default and stand Parenthesis around of that (In all editions and all versions of SQL Server). For example if you set 0 as default value, this default changed to (0). I don't know why sql server use parenthesis, and is there a practical reason.

提前致谢.

推荐答案

某些类型的对象,例如 SQL Server 没有的 DEFAULTs 和 CHECK 约束't 存储原始的文本形式 - 与存储过程相反,您可以(没有加密)始终以您提供给服务器的确切形式检索它 - 包括任何空格,格式,注释等.

There are certain types of objects, such as DEFAULTs and CHECK constraints that SQL Server doesn't store the original, textual form of - in contrast with, say, stored procedures, where you can (absent encryption) always retrieve it in the exact form you gave it to the server - complete with any white space, formatting, comments, etc.

因为 SQL Server 不存储文本形式,所以当用户请求此类对象时,它总是必须重新生成文本形式以显示给用户.它选择在何时何地插入括号可能有点神秘(没有记录),但由于它们不会改变表达式的含义,因此不必担心.

Because SQL Server doesn't store the textual form, it always has to re-generate textual forms to show to users when they ask for such objects. When and where it chooses to insert parentheses can be a bit of a mystery (it's not documented) but since they don't change the meaning of the expression, they shouldn't be a concern.

这篇关于SQL Server 列的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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