A look at Db2 and S3 storage |
Recently, I was contacted about an old blog post where I discussed how to access Cloud Object Storage from Db2. Since writing that article, both Db2 and (IBM) Cloud Object Storage have evolved. Thus, it is time for an update on how to backup data to cloud storage, load from external storage and even directly query data somewhere in the Internet...
S3 API
Db2 and S3 API-based storage
Db2 and S3 examples
How does it look like when accessing IBM Cloud Object Storage (COS) from Db2 when using the S3 API? Here are some examples to get you started:
Catalog a COS instance in Db2:
CATALOG STORAGE ACCESS alias mys3 VENDOR S3 SERVER s3.eu-de.cloud-object-storage.appdomain.cloud user 'f7foobarxxxcfeb4bxxx' password '22223333foobarfoobar22223333'"
Or use a specific file in a COS bucket to define an external table:
CREATE EXTERNAL TABLE exttab2(a int) using (dataobject 'mydatafile.dat' s3('s3.eu-de.cloud-object-storage.appdomain.cloud', 'f7foobarxxxcfeb4bxxx', '22223333foobarfoobar22223333', 'mybucket' ) )
Or reference a file hosted in a COS bucket to insert its data into a database table:
INSERT INTO mytable SELECT * FROM EXTERNAL 'mydata.txt' USING (CCSID 1208 s3('s3.eu-de.cloud-object-storage.appdomain.cloud', 'f7foobarxxxcfeb4bxxx', '22223333foobarfoobar22223333', 'myotherbucket'))
The above links and examples should get you over any bumps and should let you make use of cloud storage, as additional backup location (disaster recovery) or to easily integrate external data.
If you have feedback, suggestions, or questions about this post, please reach out to me on Twitter (@data_henrik) or LinkedIn.