oracle中从一个表查询数据并插入到另一张表里

查询1个表里的数据并插入到另一个表内对应的列,表的id应该是根据序列自动生成:

INSERT INTO ZXNEW.TB_INNER_OPERATOR_PRICE ( id, INNER_IFACE_ID, CARRIEROPERATOR, PRICE ) ( SELECT SEQ_OPERATOR_PRICE.nextval, id, CARRIEROPERATOR, PRICE FROM ZXNEW1.TB_INNER_IFACE )

查询到的数据和不属于查找的数据一起插入表内,实现如下:

INSERT INTO TB_INNER_OPERATOR_PRICE ( id, INNER_IFACE_ID, CARRIEROPERATOR, PRICE ) ( SELECT SEQ_OPERATOR_PRICE.nextval, INNER_IFACE_ID, '2', 0 FROM ZXNEW.TB_INNER_OPERATOR_PRICE WHERE CARRIEROPERATOR = '1,2,3' )

参考博文:https://blog.csdn.net/lindiwo/article/details/73863489

你可能感兴趣的:(☆2.数据库,2.3Oracle)