设置

Ok, you have ​installed​ TimescaleDB, and now you are ready to work with some data. The first thing to do is to create a new empty database or convert an existing PostgreSQL database to use TimescaleDB.

安装好了TimescleDB以后,就可以准备处理数据了。首先创建一个空数据库,或者可以将一个现有的PostgreSQL数据库转化为TimescaleDB。

First connect to the PostgreSQL instance:

首先,连接到PostgreSQL实例:

# Connect to PostgreSQL, using a superuser named 'postgres'
# 使用名为‘postgres’的超级用户连接到PostgreSQL
psql -U postgres -h localhost

Now create a new empty database (skip this if you already have a database):

现在创建一个空数据库(如果有数据库的话跳过此步骤):

-- Create the database, let's call it 'tutorial'
--创建一个名为‘toturial’的数据库
CREATE database tutorial;

Lastly add TimescaleDB:

最后,添加TimescaleDB;

-- Connect to the database
--连接到数据库
\c tutorial

-- Extend the database with TimescaleDB
--使用TimescaleDB扩展数据库
CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;

​That's it!​ Connecting to the new database is as simple as:

按照如下示例将数据库连接到新数据库:

psql -U postgres -h localhost -d tutorial

From here, you will create a TimescaleDB hypertable using one of the following options:

  1. Start from scratch​​: You don't currently have any data, and just want to create an empty hypertable for inserting data.
  2. Migrate from Postgres​​: You are currently storing time-series data in Postgres, and want to move this data to a TimescaleDB hypertable.

可以使用下面其中一种方式创建一个TimescaleDB hypertable:

  1. 从一个空数据库开始:目前没有任何数据,创建一个空的hypertable插入数据。
  2. 从Postgres迁移数据:目前Postgres中存有时间序列数据,将这些数据移动到TimescaleDB hypertable中。

results matching ""

    No results matching ""