READ_NOS combined with a CREATE TABLE AS clause accesses data from the object store and creates a permanent table for the data inside the database, without needing to create a foreign table first.
In this example, all the data in the object store identified by the LOCATION is loaded into the database. This allows the columns to be referenced without using DOT notation and allows you to cast the fields to appropriate data types.
The examples and results show a sample river flow data set. To use your own data, replace the table and column names, and authorization object.
- To run NOS-related commands, log on to the database as a user with the required privileges.
- Create and load the table:
CREATE MULTISET TABLE riverflowperm_json(site_no,flow,gageheight,datetime) AS ( SELECT payload.site_no, payload.Flow, payload.GageHeight, payload.datetime FROM ( LOCATION='YOUR-OBJECT-STORE-URI' ) AS d ) WITH DATA;
See Variable Substitutions for Examples for the credentials and location values for the sample river flow data set.
For example, substitute /s3/td-usgs-public.s3.amazonaws.com/JSONDATA/ for YOUR-STORAGE-ACCOUNT
. - Find out how many rows are in the table:
SELECT COUNT(*) FROM riverflowperm_json;
Result:
Count(*) ----------- 36301