位置: 编程技术 - 正文

PostgreSQL中的XML操作函数代码

编辑:rootadmin

XML内容生成部分 SQL数据生成XML的函数。 1. xmlcomment:生成注释函数。 xmlcomment(text ) 例: SELECT xmlcomment('hello'); xmlcomment -------------- <!--hello--> 2. xmlconcat:XML连接函数 xmlconcat(xml [, ...]) 例: SELECT xmlconcat('<abc/>', '<bar>foo</bar>'); xmlconcat ---------------------- <abc/><bar>foo</bar> 连接的XML数据中如果有多个版本声明的话,连接后的XML只有一个版本声明。 例: SELECT xmlconcat('<?xml version="1.1"?><foo/>', '<?xml version="1.1" standalone="no"?><bar/>'); xmlconcat ----------------------------------- <?xml version="1.1"?><foo/><bar/> 3. xmlelement:生成XML元素函数 xmlelement(name name [, xmlattributes( value [AS attname ] [, ... ])] [ , content, ... ]) 例: SELECT xmlelement(name foo); xmlelement ------------ <foo/> SELECT xmlelement(name foo, xmlattributes('xyz' as bar)); xmlelement ------------------ <foo bar="xyz"/> SELECT xmlelement(name foo, xmlattributes(current_date as bar), 'cont', 'ent'); xmlelement ------------------------------------- <foo bar="--">content</foo> 如果有非法字符的话,非常字符会用 进制的数字表示出来。 例子:SELECT xmlelement(name "foo$bar", xmlattributes('xyz' as "a&b")); xmlelement ---------------------------------- <foo_x_bar a_x_b="xyz"/> 4. xmlforest:生成XML FOREST函数 xmlforest(content [AS name ] [, ...]) 例: SELECT xmlforest('abc' AS foo, AS bar); xmlforest ------------------------------ <foo>abc</foo><bar></bar> SELECT xmlforest(table_name, column_name) FROM information_schema.columns WHERE table_schema = 'pg_catalog'; xmlforest ------------------------------------------------------------------------------------------- <table_name>pg_authid</table_name><column_name>rolname</column_name> <table_name>pg_authid</table_name><column_name>rolsuper</column_name> ... 5. xmlpi:生成XML处理命令函数。 xmlpi(name target [, content ]) 例: SELECT xmlpi(name php, 'echo "hello world";'); xmlpi ----------------------------- <?php echo "hello world";?> 6. xmlroot:修改XML值的根节点属性函数 xmlroot(xml , version text |no value [, standalone yes|no|no value]) 例子:SELECT xmlroot(xmlparse(document '<?xml version="1.1"?><content>abc</content>'), version '1.0', standalone yes); xmlroot ---------------------------------------- <?xml version="1.0" standalone="yes"?> <content>abc</content> 7. xmlagg:xmlagg是集约函数 xmlagg(xml ) 例: CREATE TABLE test (y int, x xml); INSERT INTO test VALUES (1, '<foo>abc</foo>'); INSERT INTO test VALUES (2, '<bar/>'); SELECT xmlagg(x) FROM test; xmlagg ---------------------- <foo>abc</foo><bar/> 可以用下面类型的方法改变连接顺序。 SELECT xmlagg(x) FROM (SELECT * FROM test ORDER BY y DESC) AS tab; xmlagg ---------------------- <bar/><foo>abc</foo> Processing XML 为了处理XML数据,PostgreSL中提供了xpath函数。 xpath(xpath , xml [, nsarray ]) 例: SELECT xpath('/my:a/text()', '<my:a xmlns:my=" ARRAY[ARRAY['my', ' xpath -------- {test} (1 row) XML和table的映射 以下函数可以导出XML。 table_to_xml(tbl regclass, nulls boolean, tableforest boolean, targetns text) query_to_xml(query text, nulls boolean, tableforest boolean, targetns text) cursor_to_xml(cursor refcursor, count int, nulls boolean, tableforest boolean, targetns text) 这些函数的返回值都是XML类型。 还有以下函数。具体内容可以参看用户手册。 table_to_xmlschema(tbl regclass, nulls boolean, tableforest boolean, targetns text) query_to_xmlschema(query text, nulls boolean, tableforest boolean, targetns text) cursor_to_xmlschema(cursor refcursor, nulls boolean, tableforest boolean, targetns text) table_to_xml_and_xmlschema(tbl regclass, nulls boolean, tableforest boolean, targetns text) query_to_xml_and_xmlschema(query text, nulls boolean, tableforest boolean, targetns text) schema_to_xml(schema name, nulls boolean, tableforest boolean, targetns text) schema_to_xmlschema(schema name, nulls boolean, tableforest boolean, targetns text) schema_to_xml_and_xmlschema(schema name, nulls boolean, tableforest boolean, targetns text) database_to_xml(nulls boolean, tableforest boolean, targetns text) database_to_xmlschema(nulls boolean, tableforest boolean, targetns text) database_to_xml_and_xmlschema(nulls boolean, tableforest boolean, targetns text)

推荐整理分享PostgreSQL中的XML操作函数代码,希望有所帮助,仅作参考,欢迎阅读内容。

PostgreSQL中的XML操作函数代码

文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!

PostgreSQL 数据库性能提升的几个方面 1.使用EXPLAINEXPLAIN命令可以查看执行计划,在前面的blog中已经介绍过。这个方法是我们最主要的调试工具。2.及时更新执行计划中使用的统计信息由于统

PostgreSQL 创建表分区 创建表分区步骤如下:1.创建主表CREATETABLEusers(uidintnotnullprimarykey,namevarchar());2.创建分区表(必须继承上面的主表)CREATETABLEusers_0(check(uid=0anduid))INHERITS(us

PostgreSQL中的OID和XID 说明 oid:行的对象标识符(对象ID)。这个字段只有在创建表的时候使用了WITHOIDS,或者是设置了default_with_oids配置参数时出现。这个字段的类型是oid(和字

标签: PostgreSQL中的XML操作函数代码

本文链接地址:https://www.jiuchutong.com/biancheng/319650.html 转载请保留说明!

上一篇:用一整天的时间安装postgreSQL NTFS权限(一整天的时间从几点到几点)

下一篇:PostgreSQL 创建表分区

  • 公司代缴个人所得税做账
  • 买房契税如何计算
  • 增值税抵扣怎么取消
  • 长期股权投资中应采用成本法核算的是
  • 税控盘维护费发票普通发票
  • 房屋租赁的发票备注怎么写
  • 审计调整分录汇总的内容
  • 售后回购确认为租赁的
  • 个体户怎么网上报税流程
  • 小规模纳税人建筑服务税率是多少
  • 开具3%增值税发票
  • 经营活动现金净流量在报表上怎么看
  • 企业所得税的征税对象包括
  • 建筑企业城建税及教育附加税率
  • 顾客退货补差价怎么做账?
  • 车的违章处理
  • 销售货物多收款怎么处理
  • 开保函会计分录
  • 退货但发票不冲销
  • 公司不收员工的个人所得税怎么处理?
  • 计提年终奖金的会计分录怎么写
  • 代扣代缴税种有几个
  • 增值税税负率税率怎么算
  • 金税盘非征期汇总资料未报送
  • 个人出租房屋合同协议书
  • 个人对公益事业的认识与看法
  • 如何将货物卖出去
  • 企业银行基本户
  • 工资 转账
  • 一般纳税人减免的增值税怎么记账
  • 按揭购入固定资产怎么算
  • win7硬盘安装win10教程
  • 无法设置面容id怎么办
  • 抵扣联必须当月认证吗
  • win11怎么安装CAD2008
  • 应用程序无法正常启动0xc000012d
  • yii gridview
  • 伊兰简介
  • php文件包含的4种方式
  • uni-app实战教程
  • linux中suid
  • tar -xvf命令
  • 其他应付款用什么冲掉
  • 红字发票信息表编号
  • 认缴倒闭无力实缴强制执行
  • 购买方享受的现金折扣
  • 出库单可以自制吗
  • sqlserver有实例吗
  • 土地摊销年限是什么意思
  • 企业银行存款的利息收入计入财务费用的借方A对B错
  • 专用发票的用途
  • 增值税专用发票怎么开
  • 车间房屋的日常修理费
  • 委托加工物资受托发的会计处理
  • 以存货抵偿债务
  • 固定资产折旧方法的选择
  • 换工作后个税app单位会自动更改吗
  • 银行贷款给个人用于经营属于消费贷款
  • sql平均数函数
  • sql存储过程实例详解
  • win8windows设置在哪里
  • centos硬盘扩容
  • wbs是什么的缩写
  • xp系统怎么没有无线网络连接
  • win8 设置
  • window8输入法不见了
  • easyui 日期格式化
  • unity shaderlab新手宝典
  • unity的monodevelop
  • Mongoose中document与object的区别示例详解
  • unityai寻路
  • jquery div innerhtml
  • 实现非常简单的英文
  • javascript五种数据类型
  • javascript下拉列表怎么做
  • html键盘监听
  • jQuery+ajax实现实用的点赞插件代码
  • 广东增值税电子普通发票怎么开
  • 广东税务实名注册
  • 重庆税务电子发票登录
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设