c# - 在 MySql Connector/Net 上设置 PAD_CHAR_TO_FULL_LENGTH

标签 c# mysql connector-net

MySQL Reference Manual州,

The length of a CHAR column is fixed to the length that you declare when you create the table. The length can be any value from 0 to 255. When CHAR values are stored, they are right-padded with spaces to the specified length. When CHAR values are retrieved, trailing spaces are removed unless the PAD_CHAR_TO_FULL_LENGTH SQL mode is enabled.

如何在 Connector/Net 中启用 PAD_CHAR_TO_FULL_LENGTH 标志? (不是 ODBC)

最佳答案

Server SQL Modes 下所述:

To change the SQL mode at runtime, set the global or session sql_mode system variable using a SET statement:

SET GLOBAL sql_mode = '<strong><em>modes</em></strong>';
SET SESSION sql_mode = '<strong><em>modes</em></strong>';

Setting the GLOBAL variable requires the SUPER privilege and affects the operation of all clients that connect from that time on. Setting the SESSION variable affects only the current client. Each client can change its session sql_mode value at any time.

因此您想要按照以下几行执行一个普通的旧 SQL 命令:

SET SESSION sql_mode = 'PAD_CHAR_TO_FULL_LENGTH';

关于c# - 在 MySql Connector/Net 上设置 PAD_CHAR_TO_FULL_LENGTH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33583181/

相关文章:

c# - 与 Socket 相比,使用 TcpClient 和 Tcp Server 有何优势

php - 消息系统。多个收件人,正在检索数据。最佳实践

mysql - 不支持身份验证方法 'mysql_old_password'

c# - 想隐藏cmd提示画面

c# - 为什么在该 CLOB 字段的 GetOrdinal 函数中出现 OutOfRange 异常?

c# - 根据在另一个列表 C# 中找到的值对列表进行排序

php - 使用来自另一个表列的条件更新表列

mysql - Qt - 尝试 mysql 驱动程序

mysql - 引用: MySql Connector/Net Authentication to host using method 'mysql_native_password' failed

mysql - 使用 BulkCopy 时出错(无法读取结果集)