当前位置: 首页 > 面试题库 >

以'开头的标识符太长。最大长度为128

巫培
2023-03-14
问题内容

我将数据库转移到MS SQL Server 2008 R2,当我尝试保存长字符串时,它给了我最大长度错误,而我将它替换后将该列的数据类型设置为“文本”与“
varchar(max)”,但那里没有解决方案。

请为我提供一个解决此问题的解决方案。我正在执行以下查询:

update hotel 
set hotel_policy = 
    "Overview of Park Central New York - New York
    This hotel is making improvements.
        The property is undergoing renovations. The following areas are affected:
        Bar/lounge
        Business center
        Select guestrooms

    Every effort will be made to minimize noise and disturbance.
    Occupying a Beaux Arts building dating to 1927, Park Central New York Hotel is within a block of famed concert venue Carnegie Hall and within a 5-minute walk of Manhattan’s world-renowned Broadway theater district. Prefer the great outdoors to the Great White Way? Central Park is just 3 blocks from the hotel. There, you can rent a rowboat at the lake, play a game of tennis, or visit the Central Park Zoo. The international boutiques and flagship department stores of Fifth Avenue start within a 10-minute walk of the hotel. For travel to sights farther afield, there are 7 subway lines located within 3 blocks of the Park Central.
    The hotel has a snack bar for guests' convenience, and coffee and tea in the lobby.
    Retreat to your guestroom and sink into a bed with a pillowtop mattress and down comforter and pillows. Need to check email or finish up some work? You’ll find a desk with an ergonomic chair and wireless high-speed Internet access (surcharge). Unwind with a video game (surcharge) on the flat-panel HDTV."

where hotel_id = 1

我进行了很多搜索,但是找到的解决方案对我没有用。

谢谢!


问题答案:

根据ANSI SQL标准,对象标识符(例如,而不是字符串定界符())使用双引号(如有 必要 ),UPDATE "hotel" ...)"Overview of Park Central ..."SQL
Server在QUOTED_IDENTIFIERis时具有此行为ON

编辑1: 使用单引号和双引号作为对象标识符(包括列别名)的分隔符的用法如下所述:

                        Delimiter   Delimiter
                        for         for
SET QUOTED_IDENTIFIER   Object ID   Alias ID        StringDelimiter
ON                      " or []     " or ' or []    '
OFF                     []          " or ' or []    " or '
  • ON那么双引号可以用作对象标识符(包括列别名)的定界符,单引号可以用作字符串文字和/或列别名(SELECT Column1 AS 'Alias1' ....)标识符的定界符。
  • OFF那么双引号可以用作列别名的定界符(SELECT Column1 AS "Alias1" ...)和字符串文字的定界符(SELECT "String1" AS Alias1 ...)。单引号可以用作字符串定界符,也可以用作列别名的定界符(SELECT Column1 ASAlias1 ...)。

改用单引号:

update hotel 
set hotel_policy = 'Overview of Park Central ...'
where hotel_id = 1


 类似资料:
  • 我读过关于隐性策略的书,但不确定。你知道怎么解决这个问题吗?

  • 问题内容: 我陷入了这个问题。数据库架构是由其他人提供的,因此我不能简单地更改名称。我尝试在各处添加适当的注释,也许我遗漏了一些(显而易见的)? 这是我的完整映射(很多类),我将省略getter / setter。 问题是当hibernate试图获得全部 控制规则 ControlRuleAttrib ControleRuleAttribPK 这里的问题是,是否有可能以某种方式得到实体的?如您所见,

  • 问题内容: 我无法在上创建索引。 MySQL: 问题答案:

  • 问题内容: 我陷入了这个问题。数据库架构是由其他人提供的,因此我不能简单地更改名称。我尝试在各处添加适当的注释,也许我遗漏了一些(显而易见的)? 这是我的完整映射(很多类),我将省略getter / setter。 问题是当冬眠试图获得全部 控制规则 ControlRuleAttrib ControleRuleAttribPK 这里的问题是,是否有可能以某种方式得到实体的?如您所见,以下是的ID

  • 我目前正在与一个项目,需要实现支付使用贝宝帐户在一些非洲国家。由于在https://developer.paypal.com/developer/中注册了测试帐户,我可以开发一个允许我与API交互的演示项目。在做一些测试用例时,我尝试指定一个非常长的数量(以美元为单位),以便查看如何处理抛出的错误。因此,看一下这个异常,我看到了以下跟踪: {“name”:“validation_error”,“d

  • 问题内容: 当我执行以下命令时: 我收到此错误消息: 有关column1和column2的信息: 我认为只需要21个字节,而只需要501个字节。因此,总字节数是522,少于767。那么为什么收到错误消息? 问题答案: 在MySQL版本5.6(及更早版本)中,InnoDB表的前缀限制为767个字节。MyISAM表的长度为1,000字节。在MySQL 5.7及更高版本中,此限制已增加到3072字节。