【Postresql】插入字符串问题

来源:互联网 发布:笔记本支架哪个好 知乎 编辑:程序博客网 时间:2024/05/21 06:21

在使用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) 
原创粉丝点击