Example for regular data: Create a regular time series
This example shows how to create a TimeSeries data type, create a time series table, and create a regular time series by running the TSCreate function.
Before you begin
- The stores_demo database must exist. You create the stores_demo database by running the dbaccessdemo command.
About this task
Time series property | Definition |
---|---|
Timepoint size | 15 minutes |
When timepoints are valid | Every 15 minutes with no invalid times |
Data in the time series | The following data:
|
Time series table | The following columns:
|
Origin | All meter IDs have an origin of 2010-11-10 00:00:00.00000 |
Regularity | Regular |
Metadata | No metadata |
Where to store the data | In an automatically created container in the same dbspace as the stores_demo database, which is in the root dbspace by default |
How to access the data | A virtual table |
Creating a TimeSeries data type and table
About this task
Procedure
To create the TimeSeries data type and table:
Creating regular, empty time series
About this task
Procedure
To create regular, empty time series:
Accessing time series data through a virtual table
About this task
Procedure
To create a virtual table based on the time series table:
Use the TSCreateVirtualTab procedure
to create a virtual table named my_vt2 that is based on the my_ts_data table
by running the following SQL statement:
EXECUTE PROCEDURE TSCreateVirtualTab("my_vt2", "my_ts_data",
"calendar(ts_15min), origin(2010-11-10 00:00:00.00000)");
Results
SELECT * FROM my_vt2 WHERE timestamp = "2010-11-10 00:00:00.00000";