Oracle、Mysql、SqlServer中插入多条数据

 

(1) Oracle中:
insert into product
  (id,names, price, code)
 select 100,'a',1,1 from dual
 union
 select 101,'b',2,2 from dual;
这里最好用一次insert,不然效率不高,用多个select.

 (2)Mysql中:
insert into 表名(id,name)
values(1,'A'),(2,'B'),(3,'C')

(3)SqlServer中:

INSERT
INTO table_name(col_one,col_two)
SELECT 'col1','col2'
UNION
SELECT 'col11','col22'

SELECT *
FROM table_name;

GO

UNION 不能省(若省,只插入了(col1,col2));

 

 

你可能感兴趣的:(java,MySQL,Oracle,Go,C,C++)