Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature]: support insert data by sql #1011

Open
stone1100 opened this issue Jan 17, 2024 · 2 comments
Open

[feature]: support insert data by sql #1011

stone1100 opened this issue Jan 17, 2024 · 2 comments
Labels
feature New feature

Comments

@stone1100
Copy link
Member

Is your feature request related to a problem? Please describe.
if schema is predefined, data can be inserted by inserting statement.

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@stone1100 stone1100 added the feature New feature label Jan 17, 2024
@joyant
Copy link
Contributor

joyant commented Jan 23, 2024

What about:

INSERT INTO
    tb_name
        [TAGS (tag1_value, ...)]
        [(field1_name, ...)]
        VALUES (field1_value, ...) [(field1_value2, ...) ...]
  1. Insert one record with function now(), the timestamp is always in the first position.
INSERT INTO d1001 tags("sh", "1.1.1.1") VALUES (now(), 10.2, 219, 0.32);
  1. Insert multiple records with time, I think adding comma is better.
INSERT INTO d1001 VALUES
('2021-07-13 14:06:32.272', 10.2, 219, 0.32), 
(1626164208000, 10.15, 217, 0.33),
(now()-1s, 1, 2, 3);
  1. Specify column names when inserting data.
-- ts or timestamp ?
INSERT INTO d1001 (ts, current, phase) VALUES (now(), 10.27, 0.31);
  1. Allow table creation during insertion ?

ref tdengine

@stone1100
Copy link
Member Author

I think it is difficult to define the type of fields in insert statement. So not allow table creation during insertion.

Steps:

  1. create table([feature]: create table #1010 )
create table if not exist cpu 
(
    host tag,
    ip tag,
    load last,
    temperature max
);
  1. insert data
-- single
INSERT INTO cpu (timestamp, host, ip, load) VALUES (now(), "sh","1.1.1.1",4);
-- batch
INSERT INTO cpu (timestamp, host, ip, load) 
VALUES 
(now(), "sh","1.1.1.1",4),
(now(), "sh","1.1.1.2",5),
(now(), "sh","1.1.1.3",4),
;

also depend(#1015 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

No branches or pull requests

2 participants