最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PostgreSQL中的XML操作函數(shù)代碼

 更新時間:2009年09月06日 01:03:22   作者:  
PostgreSQL中的XML操作函數(shù)代碼

XML內(nèi)容生成部分
SQL數(shù)據(jù)生成XML的函數(shù)。
1. xmlcomment:生成注釋函數(shù)。
xmlcomment(text )
例:

SELECT xmlcomment('hello');
xmlcomment
--------------
<!--hello-->

2. xmlconcat:XML連接函數(shù)
xmlconcat(xml [, ...])
例:
SELECT xmlconcat('<abc/>', '<bar>foo</bar>');

xmlconcat
----------------------
<abc/><bar>foo</bar>

連接的XML數(shù)據(jù)中如果有多個版本聲明的話,連接后的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元素函數(shù)
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="2007-01-26">content</foo>

如果有非法字符的話,非常字符會用 16進制的數(shù)字表示出來。
例子:SELECT xmlelement(name "foo$bar", xmlattributes('xyz' as "a&b"));
xmlelement
----------------------------------
<foo_x0024_bar a_x0026_b="xyz"/>

4. xmlforest:生成XML FOREST函數(shù)
xmlforest(content [AS name ] [, ...])
例:
SELECT xmlforest('abc' AS foo, 123 AS bar);
xmlforest
------------------------------
<foo>abc</foo><bar>123</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處理命令函數(shù)。
xmlpi(name target [, content ])
例:
SELECT xmlpi(name php, 'echo "hello world";');
xmlpi
-----------------------------
<?php echo "hello world";?>

6. xmlroot:修改XML值的根節(jié)點屬性函數(shù)
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是集約函數(shù)
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數(shù)據(jù),PostgreSL中提供了xpath函數(shù)。
xpath(xpath , xml [, nsarray ])

例:
SELECT xpath('/my:a/text()', '<my:a xmlns:my="http://example.com">test</my:a>',
ARRAY[ARRAY['my', 'http://example.com']]);
xpath
--------
{test}
(1 row)

XML和table的映射
以下函數(shù)可以導(dǎo)出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)
這些函數(shù)的返回值都是XML類型。

還有以下函數(shù)。具體內(nèi)容可以參看用戶手冊。
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)

相關(guān)文章

  • postgresql 中的加密擴展插件pgcrypto用法說明

    postgresql 中的加密擴展插件pgcrypto用法說明

    這篇文章主要介紹了postgresql 中的加密擴展插件pgcrypto用法說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-01-01
  • 詳解如何定位postgreSQL數(shù)據(jù)庫中未被使用過的索引

    詳解如何定位postgreSQL數(shù)據(jù)庫中未被使用過的索引

    在生產(chǎn)環(huán)境上,由于不規(guī)范的優(yōu)化措施,數(shù)據(jù)庫中可能存在大量的索引,并且相當一部分的索引重未被使用過,今天帶大家如何找出這些索引,本文給大家介紹了定位postgreSQL數(shù)據(jù)庫中未被使用過的索引的方法,需要的朋友可以參考下
    2024-03-03
  • PostgreSql 的hash_code函數(shù)的用法說明

    PostgreSql 的hash_code函數(shù)的用法說明

    這篇文章主要介紹了PostgreSql 的hash_code函數(shù)的用法說明,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-02-02
  • 基于PostgreSQL 權(quán)限解讀

    基于PostgreSQL 權(quán)限解讀

    這篇文章主要介紹了基于PostgreSQL 權(quán)限解讀,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-01-01
  • 關(guān)于PostgreSQL截取某個字段中的部分內(nèi)容進行排序的問題

    關(guān)于PostgreSQL截取某個字段中的部分內(nèi)容進行排序的問題

    這篇文章主要介紹了PostgreSQL截取某個字段中的部分內(nèi)容進行排序,本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-06-06
  • PostgreSQL limit的神奇作用詳解

    PostgreSQL limit的神奇作用詳解

    這篇文章主要介紹了PostgreSQL limit的神奇作用,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧
    2022-09-09
  • postgresql數(shù)據(jù)庫連接數(shù)和狀態(tài)查詢操作

    postgresql數(shù)據(jù)庫連接數(shù)和狀態(tài)查詢操作

    這篇文章主要介紹了postgresql數(shù)據(jù)庫連接數(shù)和狀態(tài)查詢操作,具有很好的參考價值,對大家有所幫助。一起跟隨小編過來看看吧
    2021-02-02
  • postgresql數(shù)據(jù)庫導(dǎo)出和導(dǎo)入及常用的數(shù)據(jù)庫管理工具

    postgresql數(shù)據(jù)庫導(dǎo)出和導(dǎo)入及常用的數(shù)據(jù)庫管理工具

    數(shù)據(jù)庫的導(dǎo)入導(dǎo)出是最常用的功能之一,而PostgreSQL提供的對應(yīng)工具為pg_dump和pg_restore。pg_dump是用于備份PostgreSQL數(shù)據(jù)庫的工具,下面這篇文章主要給大家介紹了關(guān)于postgresql數(shù)據(jù)庫導(dǎo)出和導(dǎo)入及常用的數(shù)據(jù)庫管理工具使用的相關(guān)資料,需要的朋友可以參考下
    2023-04-04
  • 基于postgreSql 常用查詢小結(jié)

    基于postgreSql 常用查詢小結(jié)

    這篇文章主要介紹了基于postgreSql 常用查詢小結(jié),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-01-01
  • Postgresql 截取字符串的案例

    Postgresql 截取字符串的案例

    這篇文章主要介紹了Postgresql 截取字符串的案例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-02-02

最新評論

上栗县| 清徐县| 吉安县| 花莲市| 澳门| 神农架林区| 汕尾市| 巴马| 宾阳县| 大城县| 南京市| 芦山县| 余庆县| 花莲市| 五原县| 沈阳市| 德清县| 武隆县| 长沙市| 惠州市| 常德市| 明溪县| 屏南县| 西乌| 阿城市| 常州市| 浠水县| 开封市| 永新县| 平顺县| 乌拉特中旗| 扎兰屯市| 平乡县| 合水县| 两当县| 虹口区| 陵川县| 丘北县| 谷城县| 塘沽区| 桂东县|