SQL Server中的最大数据库名称长度 [英] Max database name length in SQL Server

查看:798
本文介绍了SQL Server中的最大数据库名称长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对数据库名称进行一些UI验证。我从不同的地方告诉我,SQL Server数据库名称存储为 sysname 内部SQL Server。我也验证了通过检查 sys.Databases

I am trying to do some UI validation on a database name. I was told from different places that the SQL Server database name is stored as sysname inside SQL Server. I also verified that by checking the sys.Databases.

所以,我使我的文本框在UI中有128个字符长度的maxlength。这是 sysname 类型的最大长度。

So, I make my textbox in the UI to have maxlength 128 characters long. This is the max length of sysname type.

但是,我发现在我的SQL Server 2005 Express版本中,如果我输入一个128个字符长的数据库名称,它总是抱怨

However, I found that in my SQL Server 2005 Express edition, if I enter a database name with 128 characters long, it always complains


无法创建默认日志文件, p>

Could not create default log file because the name was too long

为了确保我可以成功创建数据库,我发现我需要将最大限制设置为124个字符。

To make sure I can successfully create the database, I found that I need to set the max limit to 124 characters.

我现在的问题是,在所有不同的Windows操作系统上,所有版本的SQL Server是否都有124个字符限制。

My question now is whether 124 characters limit is true for all versions of SQL Server on all different Windows OS?

推荐答案

日志文件名不需要包括数据库名。

The log file name does not need to include the database name.

这对我来说很好。

CREATE DATABASE [AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA] ON  PRIMARY 
( 
NAME = N'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA', 
FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\A128.mdf')
 LOG ON 
( 
NAME = N'A128_log', 
FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\A128_log.LDF')

这篇关于SQL Server中的最大数据库名称长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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