gpt4 book ai didi

mysql - SQL中定义字符串时前导 "X"是什么意思?

转载 作者:行者123 更新时间:2023-11-29 01:26:02 43 4
gpt4 key购买 nike

我正在从事一个项目,在该项目中我获得了一个 SQL 文件来生成数据库和一些示例值。其中一个字段 ( HTMLContent ) 是类型 blob插入其中的值的格式为 X'<long-string-of-numbers-and-letters>' .

前导“X”表示什么?

CREATE TABLE `advertDOM` (
`id` int(11) NOT NULL,
`HTMLContent` blob COMMENT 'DOM data to be displayed on screen',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `advertDOM` (`id`, `HTMLContent`)
VALUES
(1,X'3C646976206964203D2022636F6E74656E742220636C617373203D202266756C6C73637265656E2D6C616E647363617065223E0A20203C646976206964203D202277312D636F6E7461696E6572223E0A202020207B77317D0A20203C2F6469763E0A3C2F6469763E'),
(2,X'3C646976206964203D2022636F6E74656E742220636C617373203D202274776F2D77696E646F772D6C616E647363617065223E0A20203C646976206964203D202277312D636F6E7461696E6572223E0A202020207B77317D0A20203C2F6469763E0A20203C646976206964203D202277322D636F6E7461696E6572223E0A202020207B77327D0A20203C2F6469763E0A3C2F6469763E'),
(3,X'3C646976206964203D2022636F6E74656E742220636C617373203D202266756C6C73637265656E2D706F727472616974223E0A20203C646976206964203D202277312D636F6E7461696E6572223E0A202020207B77317D0A20203C2F6469763E0A3C2F6469763E'),
(4,X'3C646976206964203D2022636F6E74656E742220636C617373203D202274776F2D77696E646F772D706F727472616974223E0A20203C646976206964203D202277312D636F6E7461696E6572223E0A202020207B77317D0A20203C2F6469763E0A20203C646976206964203D202277322D636F6E7461696E6572223E0A202020207B77327D0A20203C2F6469763E0A3C2F6469763E');

最佳答案

来自 MySQL documentation :

Hexadecimal literal values are written using X'val' or 0xval notation, where val contains hexadecimal digits (0..9, A..F). Lettercase of the digits and of any leading X does not matter. A leading 0x is case-sensitive and cannot be written as 0X.

所以,您只是在查看十六进制字符串文字。根据您的表定义,您可以看到这些字符串以二进制形式存储在 BLOB 列中。

关于mysql - SQL中定义字符串时前导 "X"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54122331/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com