SQL Server 编辑表名以 dbo 为前缀 [英] SQL Server edits the table name with dbo as prefix

查看:49
本文介绍了SQL Server 编辑表名以 dbo 为前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 SQL Server CE 有一段时间了.在那个数据库中,表名就像UserPostsUserProfile.

I have been using SQL Server CE for a while. In that database the table names were like UserPosts, UserProfile.

但是在我从 SQL Server CE 升级到 SQL Server 之后,名称被编辑为 dbo.UserPostsdbo.UserProfile.并且列的名称也用方括号括起来,例如:[UserProfile].

But after my upgrade from SQL Server CE to SQL Server the names are edited to dbo.UserPosts, dbo.UserProfile. And also the names of columns are wrapped in square brackets like: [UserProfile].

为什么要使用这个括号?

Why is this bracket used?

推荐答案

括号用于在 SQL Server 中将名称括起来(它们的作用与双引号相同).

Brackets are used to surround names in SQL Server (they server the same purpose as double quotes).

对于由字母数字字符和下划线组成的名称,不要以数字开头,并且不是保留字,则不需要方括号.它们通常用于具有不规则"名称的列,例如 [Column Name](注意空格)或像 [from] 这样的保留字.

For names that consist of alphanumeric characters and underscore, do not start with a digit, and are not reserved words, the square brackets are not needed. They are typically used for columns that have "irregular" names, such as [Column Name] (note the space) or a reserved word like [from].

当 SQL Server 生成代码时,对于方括号的使用过于保守(在我看来).它将它们用于 create table 语句中的所有列名、表名,甚至类型名.因为我从不在我的名字中使用不规则"字符,我发现所有的括号都是不必要的混乱.

When SQL Server generates code, it is overly conservative (in my opinion) about the use of square brackets. It uses them for all column names, table names, and even type names in create table statements. Because I never use "irregular" characters in my names, I find all the brackets to be unnecessary clutter.

dbo 是一种称为模式的东西.SQL Server 对数据库中的表使用三部分命名约定: ... 如果当前数据库不存在,则数据库名称默认为当前数据库.架构默认为 dbo(或其他默认架构,如果已更改,几乎从未更改).并且,有四部分命名约定,其中第一部分是服务器名称.

The dbo is something called a schema. SQL Server uses a three part naming convention for tables in a database: ... The database name defaults to the current data base, if it is not present. The schema defaults to dbo (or another default schema if that has been changed, which is almost never). And, there is a four part naming convention, where the first part is the server name.

这篇关于SQL Server 编辑表名以 dbo 为前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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