用一条insert语句来插入多行数据详解数据库

MySQL数据库:

INSERT INTO STUDENT (SNAME, SSEX, SAGE, SDEPT) SELECT '武耀旭','男',24,'CS' UNION SELECT '张志鹏','男',24,'CS' UNION SELECT '朱文辉','男',24,'CS' 
INSERT DELAYED INTO `newsort` (`sort_id`, `sort_name`, `sort_bz`) VALUES 
(1, 'aas', 'sdsdfsdfsf'), 
(2, 'ffff', 'gggg'), 
(4, '生活类', '要懂得生活才好!'), 
(5, '股票行情', ''), 
(6, '政治类新闻', ''), 
(7, 'IT行业新闻', ''), 
(8, '宗教类新闻', '');

oracle数据库:

两种插入方式 
INSERT INTO sc(SID,cid,g) VALUES (2011001,001,90); 
INSERT INTO sc(SID,cid,g) VALUES (2011002,001,91); 
INSERT INTO sc(SID,cid,g) VALUES (2011003,001,92); 
INSERT INTO sc(SID,cid,g) VALUES (2011004,002,93); 
INSERT INTO sc(SID,cid,g) VALUES (2011005,002,94); 
INSERT INTO sc(SID,cid,g) VALUES (2011006,002,95); 
INSERT INTO sc(SID,cid,g) VALUES (2011007,003,96); 
INSERT INTO sc(SID,cid,g) VALUES (2011008,003,97); 
INSERT INTO sc(SID,cid,g) VALUES (2011009,004,98); 
INSERT INTO sc(SID,cid,g) VALUES (2011010,004,99); 
INSERT INTO sc(SID,cid,g) 
SELECT 2011001,001,90 FROM dual UNION ALL  
SELECT 2011002,001,91 FROM dual UNION ALL  
SELECT 2011003,001,92 FROM dual UNION ALL  
SELECT 2011004,002,93 FROM dual UNION ALL  
SELECT 2011005,002,94 FROM dual UNION ALL  
SELECT 2011006,002,95 FROM dual UNION ALL  
SELECT 2011007,003,96 FROM dual UNION ALL  
SELECT 2011008,003,97 FROM dual UNION ALL  
SELECT 2011009,004,98 FROM dual UNION ALL  
SELECT 2011010,004,99 FROM dual 

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/tech/database/4979.html

(0)
上一篇 2021年7月16日 23:23
下一篇 2021年7月16日 23:23

相关推荐

发表回复

登录后才能评论