PostgreSQL学习篇9.14 XML类型

前端之家收集整理的这篇文章主要介绍了PostgreSQL学习篇9.14 XML类型前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. 注:要使用xml数据类型,在编译Postgresql的时候必须使用:
  2. configure --with-libxml
  3.  
  4. 如果编译的时候没有使用此选项:
  5. postgres=# select xml '<osdba>hello world</osdba>';
  6. ERROR: unsupported XML feature at character 12
  7. DETAIL: This functionality requires the server to be built with libxml support.
  8. HINT: You need to rebuild Postgresql using --with-libxml.
  9. STATEMENT: select xml '<osdba>hello world<osdba>';
  10. ERROR: unsupported XML feature
  11. LINE 1: select xml '<osdba>hello world</osdba>';
  12. ^
  13. DETAIL: This functionality requires the server to be built with libxml support.
  14. HINT: You need to rebuild Postgresql using --with-libxml.
  15. postgres=#
  16.  
  17. 以--with-libxml重新装一次pg
  18. postgres=# select xml '<osdba>hello world</osdba>';
  19. xml
  20. ----------------------------
  21. <osdba>hello world</osdba>
  22. (1 row)
  23.  
  24. postgres=#
  25.  
  26. 关于xml存储的参数:
  27. postgres=# show xmloption;
  28. xmloption
  29. -----------
  30. content
  31. (1 row)
  32.  
  33. postgres=#
  34.  
  35. xmloption有两个参数:contentdocument
  36. 改变语法:set xmloption to document;
  37.  
  38. 使用xmlparse函数sql标准中将字符串换成XML的唯一方式。
  39. postgres=# select xmlparse (content '<persion><name>john</name><sex>f</sex></persion>');
  40. xmlparse
  41. --------------------------------------------------
  42. <persion><name>john</name><sex>f</sex></persion>
  43. (1 row)
  44.  
  45. postgres=#

猜你在找的Postgre SQL相关文章