postgresql 从一张表中查询出记录然后批量插入到另一张表中

 有个业务从 appuser 表中 把uid 查出来所有uid 数据,然后批量插入 app_user_sdk 表中


insert into app_user_sdk ((select uid,'MY' from appuser); 

 又要重复插入,又把新添加的用户,他曾经插入过的,就要筛掉原来插入的

insert into app_user_sdk ((select uid,'MY' from appuser where uid not in(select uid from app_user_sdk))); 

猜你喜欢

转载自blog.csdn.net/private66/article/details/83579218