t=table(`XOM`GS`FB as ticker, 100 80 120 as volume);
t;
ticker |
volume |
XOM |
100 |
GS |
80 |
FB |
120 |
insert into t values(`GOOG, 200);
t;
ticker |
volume |
XOM |
100 |
GS |
80 |
FB |
120 |
GOOG |
200 |
insert into t values(`AMZN`NFLX, 300 250);
t;
ticker |
volume |
XOM |
100 |
GS |
80 |
FB |
120 |
GOOG |
200 |
AMZN |
300 |
NFLX |
250 |
insert into t values(('AMD','NVDA'), (60 400));
t;
ticker |
volume |
XOM |
100 |
GS |
80 |
FB |
120 |
GOOG |
200 |
AMZN |
300 |
NFLX |
250 |
AMD |
60 |
NVDA |
400 |
上例还有另一种写法,即按照 SQL 标准写法,直接向表 t 传入多行数据。可得结果一致。
insert into t values ('AMD', 60), ('NVDA', 400);
t;
ticker |
volume |
XOM |
100 |
GS |
80 |
FB |
120 |
GOOG |
200 |
AMZN |
300 |
NFLX |
250 |
AMD |
60 |
NVDA |
400 |
只往部分列插入新的记录:
insert into t(ticker, volume) values(`UBER`LYFT, 0 0);
t;
ticker |
price |
volume |
XOM |
98.5 |
100 |
GS |
12.3 |
80 |
FB |
40.6 |
120 |
GOOG |
100.6 |
200 |
AMZN |
120 |
300 |
NFLX |
56.6 |
250 |
AMD |
78.6 |
60 |
NVDA |
33.1 |
400 |
UBER |
|
0 |
LYFT |
|
0 |