创建超级表
-- 创建超级表
注意:TAGS不应该包含时间,这里的TAGS是给子表贴的标签,一般情况都是时间无关的
CREATE STABLE wpp_wind_turbines_data (ts timestamp, speed float, direction nchar(10), direction_angle float,ideal_power float, available_power float, actual_power_output float, capacity_power float)
TAGS (device_id int, create_by nchar(10), create_time TIMESTAMP, update_by nchar(10), update_time TIMESTAMP, no nchar(10));
create stable wpp_wind_measurement_tower_data (ts timestamp, ten_speed float, ten_direction nchar(10), ten_direction_angle float, thirty_speed float, thirty_direction nchar(10), thirty_direction_angle float, fifty_speed float, fifty_direction nchar(10), fifty_direction_angle float, seventy_speed float, seventy_direction nchar(10), seventy_direction_angle float, hub_speed float, hub_direction nchar(10), hub_direction_angle float, surface_temperature float, surface_humidity float, surface_pressure float, create_by nchar(10), create_time timestamp, update_by nchar(10), update_time timestamp )
tags (tower_id int, no nchar(10))
create stable wpp_wind_farm_data (ts timestamp, actual_power_output float, capacity_power float, create_time timestamp) tags (no nchar(10))
create stable wpp_prediction_data (ts timestamp, predicted_power float, is_reported tinyint, lower_confidence_limit float, upper_confidence_limit float, create_by nchar(10), create_time timestamp, update_by nchar(10), update_time timestamp) tags (device_id int, no nchar(10))
create stable wpp_prediction_fram_data (ts timestamp, predicted_power float, lower_confidence_limit float, upper_confidence_limit float, create_by nchar(10), create_time timestamp, update_by nchar(10), update_time timestamp) tags(no nchar(10))
创建子表
-- 创建子表
CREATE TABLE wpp_wind_turbines_data_660 using wpp_wind_turbines_data TAGS(660, "admin", null, "admin", null, "j56fUdq8")
create table wpp_wind_measurement_tower_data_1 using wpp_wind_measurement_tower_data tags(1, "一号测风塔")
自动建表
-- 自动建表
INSERT INTO wpp_wind_turbines_data_660 using wpp_wind_turbines_data TAGS(660, "admin", null, "admin", null, "j56fUdq8") VALUES ('2024-03-04 10:45:00.0',660.0,null,77.0,881.862,777.0,777, 777);
insert into wpp_wind_measurement_tower_data_1 using wpp_wind_measurement_tower_data tags(1, "一号测风塔") values ('2024-03-04 10:45:00.0',660.0,null,77.0,881.0 ...)
其他
-- 查看超级表
show stables
--查看表
show tables
-- 查看表结构
DESCRIBE wpp_prediction_data;
-- 查看建表语句
SHOW CREATE DATABASE wpp_server;
-- 修改表
alter table wpp_weather_forecast_data add column seventy_direction_angle float AFTER seventy_direction;
-- 删除表
drop table wpp_server.wpp_wind_turbines_data;
向多个表插入数据
INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33)
d21002 USING meters (groupId) TAGS (2) VALUES ('2021-07-13 14:06:34.255', 10.15, 217, 0.33)
d21003 USING meters (groupId) TAGS (2) (ts, current, phase) VALUES ('2021-07-13 14:06:34.255', 10.27, 0.31);
标签:10,建表,tdengine,create,float,wpp,data,nchar
From: https://www.cnblogs.com/code-jia/p/18143146