INSERT语法 大批量的生成数据 plaintext teledb truncate table teledbpg1; TRUNCATE TABLE teledb insert into teledbpg1 select t,md5(random()::text) from generateseries(1,10000) as t; INSERT 0 10000 teledb select count(1) from teledbpg1; count 10000 (1 row) 返回插入数据,轻松获取插入记录的serial值 plaintext teledb create table teledbserial(id serial, nickname varchar); CREATE TABLE teledb insert into teledbserial(nickname) values('hello teledb') returning ; id nickname + 1 hello teledb (1 row) INSERT 0 1 指定返回的字段。 teledb insert into teledbserial(nickname) values('hello teledb') returning id; id 2 (1 row) INSERT 0 1 insert..update更新 使用on conflict plaintext teledb create table tupdate(id int unique, name varchar); CREATE TABLE teledb d+ tupdate Table "public.tupdate" Column Type Collation Nullable Default Storage Stats target Description +++++++ id integer plain name character varying extended Indexes: "tupdateidkey" UNIQUE CONSTRAINT, btree (id) Distribute By: SHARD(id) Location Nodes: ALL DATANODES teledb insert into tupdate values(1,'teledb'); INSERT 0 1 teledb insert into tupdate values(1,'teledb') on conflict(id) do update set name 'hello'; INSERT 0 1 teledb select from tupdate ; id name + 1 hello (1 row)