在使用postgresql进行数据插入时,出现错误
INSERT INTO table1 (name,number) VALUES ("王",123)
提示 “王” 这个列错误。数据库将”王”数据识别成了列数据。查看官方文档得知,postgresql对于字符串需要用单引号进行标识。
4.1.2.1. String Constants
A string constant in SQL is an arbitrary sequence of characters bounded by single quotes (‘), for example ‘This is a string’. To include a single-quote character within a string constant, write two adjacent single quotes, e.g., ‘Dianne”s horse’. Note that this is not the same as a double-quote character (“).
https://www.postgresql.org/docs/9.3/static/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS
修正后的指令
INSERT INTO table1 (name,number) VALUES ('王',123)
修正PostgreSQL字符串插入错误
本文介绍了一种在PostgreSQL中插入数据时遇到的常见错误——字符串数据未正确使用单引号导致的问题,并给出了修正方法。
5715

被折叠的 条评论
为什么被折叠?



