请告诉我如何从提供的XSD中获取oracle数据库架构。这是代码,我传递
第1步:
begin dbms_xmlschema.registerSchema('xdb_usr.xsd',
'<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:per="xdb_usr.xsd"
xmlns:xdb="http://xmlns.oracle.com/xdb">
<xs:element name = "Employee1"
xdb:defaultTable="EMP31B_TAB">
<xs:complexType>
<xs:sequence>
<xs:element name = "EmployeeId" type = "xs:positiveInteger"/>
<xs:element name = "Name" type = "xs:string"/>
<xs:element name = "Salary" type = "xs:positiveInteger"/>
<xs:element name = "DeptId" type = "xs:positiveInteger"
xdb:SQLName="DEPTID"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>',
TRUE, TRUE, FALSE); end;
第2步: CREATE TABLE foo OF XMLType XMLSCHEMA "xdb_usr.xsd" ELEMENT "Employee1";
第3步:
LOAD DATA
INFILE ''
INTO TABLE foo TRUNCATE
xmltype(xmldata)
(
xmldata char(4000)
)
BEGINDATA
<Employee1> <EmployeeId>111</EmployeeId> <Name>Ravi</Name> <Salary>100000</Sal
ary> <DeptId>12</DeptId></Employee1>
<Employee1> <EmployeeId>112</EmployeeId> <Name>John</Name> <Salary>150000</Sal
ary> <DeptId>12</DeptId></Employee1>
<Employee1> <EmployeeId>113</EmployeeId> <Name>Michael</Name> <Salary>75000</S
alary> <DeptId>12</DeptId></Employee1>
<Employee1> <EmployeeId>114</EmployeeId> <Name>Mark</Name> <Salary>125000</Sal
ary> <DeptId>16</DeptId></Employee1>
<Employee1> <EmployeeId>115</EmployeeId> <Name>Aaron</Name> <Salary>600000</Sa
lary> <DeptId>16</DeptId></Employee1>
每当我运行Step1时,它会注册Schema,当我运行第2步时,它会创建表。当我运行第3步时:它表示已加载数据。但是,我可以看到已创建的表但无法找到已定义架构的表以及任何数据。非常感谢您的帮助。下面是显示我的表为空模式的快照..
答案 0 :(得分:0)
您缺少关键字(COLUMN):
CREATE TABLE foo (EMP XMLType) XMLType COLUMN EMP XMLSCHEMA "xdb_usr.xsd" ELEMENT "Employee1";
select * from FOO ;