Parse RDF file and save to DB2

Want to parse RDF file and save to DB2 ? Want to schedule and automate this importing task?

To import Xml format RDF file (.rdf, .owl) to DB2, https://www.withdata.com/blog/rdftodb2/db2-import-rdf.html

To import RDF Turtle file (.ttl, .n3) to DB2, https://www.withdata.com/blog/rdftodb2/ttl-to-db2.html

To import RDF N-Triples file (.nt, .ntriples) to DB2, https://www.withdata.com/blog/rdftodb2/n-triples-to-db2.html

To import RDF N-Quads file (.nq, .nquads) to DB2, https://www.withdata.com/blog/rdftodb2/n-quads-to-db2.html

RDF → DB2 reference

Type mapping

Value kindin RDFin DB2
Int"1234"^^xsd:intINTEGER
Bigint"9007199254740993"^^xsd:longBIGINT
Decimal"1234.56"^^xsd:decimalDECIMAL(p,s)
Float"1.234e10"^^xsd:doubleDOUBLE
Textplain literal without a datatypeVARCHAR(n)
Long textplain literal; newlines allowed insideCLOB
Date"2026-09-18"^^xsd:dateDATE
Datetime"2026-09-18T14:30:00Z"^^xsd:dateTimeTIMESTAMP
Binary"base64..."^^xsd:base64BinaryBLOB
Boolean"true"^^xsd:booleanSMALLINT
JSONa literal, or reified as its own sub-graphCLOB

Dialect differences

RDF is a file format and DB2 is a database server, so the target has to be told the types the file never carried – the rows below are where the two sides diverge.

Propertyin RDFin DB2
port—50000
identifiersXML attribute quoting; entities for reserved characters"double quotes"
row limit—FETCH FIRST n ROWS
datesxsd:dateTime typed literalsDATE, TIME, TIMESTAMP
long text—CLOB
binaryxsd:base64Binary typed literalsBLOB
separatorXML elements (rdf:Description / rdf:resource)—
encodingDeclared in the XML declaration—
typingEvery value is a resource or a typed literal—
shapeGraph of triples; there are no rows or columnsTables of rows and columns
ceilingWhole document is usually parsed into memory—

Command line

SideCommand
DB2EXPORT TO out.csv OF DEL
DB2 (load)db2 IMPORT FROM file OF DEL

Convert your data online, free

Free in-browser converters for CSV, Excel, JSON, XML and SQL: Withdata Online Data Conversion. Large files, batch conversion or scheduling? See the offline desktop apps, or browse all data conversion tools.


Posted

in

by

Tags: