postgre-插入数据时的单引号问题

场景:

将一个HTML页面存储到数据库中

问题:

HTML页面中既包含单引号也包含双引号

解决办法:

  1. 双单引号

    INSERT INTO table VALUES ('<html><script>let a=''a''</script></html>')
    
  2. 转义字符和 E

    INSERT INTO table VALUES (E'<html><script>let a=\'a\'</script></html>')
    
posted @ 2019-05-13 10:52  枫子_dan  阅读(2135)  评论(0编辑  收藏  举报