database_to_xml_and_xmlschema()

将数据库转换为 XML 并返回 XML Schema 的函数

database_to_xml_and_xmlschema() 是一个系统函数,用于以 XML 格式输出 PostgreSQL 数据库的内容及其定义。

database_to_xml_and_xmlschema() 函数于 PostgreSQL 8.3 中添加。

用法

database_to_xml_and_xmlschema ( nulls boolean, tableforest boolean, targetns text )
         → xml

database_to_xml_and_xmlschema() 结合了 database_to_xml()database_to_xmlschema() 函数的输出。更多详细信息,请参阅每个函数的条目。

变更历史

示例

database_to_xml_and_xmlschema() 的基本用法示例

postgres=# CREATE TABLE foo (id INT, val TEXT);
CREATE TABLE

postgres=# INSERT INTO foo VALUES(generate_series(1,2), clock_timestamp());
INSERT 0 2 

postgres=# CREATE TABLE bar (id INT, val TEXT);
CREATE TABLE 

                                   database_to_xml_and_xmlschema
----------------------------------------------------------------------------------------------------
 <postgres xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="#">+
                                                                                                   +
 <xsd:schema                                                                                       +
     xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                 +
                                                                                                   +
 <xsd:simpleType name="INTEGER">                                                                   +
   <xsd:restriction base="xsd:int">                                                                +
     <xsd:maxInclusive value="2147483647"/>                                                        +
     <xsd:minInclusive value="-2147483648"/>                                                       +
   </xsd:restriction>                                                                              +
 </xsd:simpleType>                                                                                 +
                                                                                                   +
 <xsd:simpleType name="UDT.postgres.pg_catalog.text">                                              +
   <xsd:restriction base="xsd:string">                                                             +
   </xsd:restriction>                                                                              +
 </xsd:simpleType>                                                                                 +
                                                                                                   +
 <xsd:complexType name="CatalogType.postgres">                                                     +
   <xsd:all>                                                                                       +
     <xsd:element name="public" type="SchemaType.postgres.public"/>                                +
   </xsd:all>                                                                                      +
 </xsd:complexType>                                                                                +
                                                                                                   +
 <xsd:element name="postgres" type="CatalogType.postgres"/>                                        +
                                                                                                   +
 </xsd:schema>                                                                                     +
                                                                                                   +
 <public>                                                                                          +
                                                                                                   +
                                                                                                   +
 <foo>                                                                                             +
   <id>2</id>                                                                                      +
   <val xsi:nil="true"/>                                                                           +
   <x xsi:nil="true"/>                                                                             +
 </foo>                                                                                            +
                                                                                                   +
 <foo>                                                                                             +
   <id>1</id>                                                                                      +
   <val xsi:nil="true"/>                                                                           +
   <x xsi:nil="true"/>                                                                             +
 </foo>                                                                                            +
                                                                                                   +
                                                                                                   +
 </public>                                                                                         +
                                                                                                   +
 </postgres>                                                                                       +

(1 row)

分类

系统函数, XML

另请参阅

database_to_xml(), database_to_xmlschema(), schema_to_xml_and_xmlschema(), table_to_xml_and_xmlschema(), query_to_xml_and_xmlschema(), cursor_to_xml_and_xmlschema()

反馈

提交有关 "database_to_xml_and_xmlschema()" 的任何评论、建议或更正,请在此处 提交