从Oracle数据库中读取数据,自动生成INSERT语句

创建表
-- Create table
create table TB_ACCIDENT_TYPE
(
  ID         NUMBER(20) not null,
  NAME       VARCHAR2(50),
  PATH       VARCHAR2(20),
  PARENTPATH VARCHAR2(20),
  URL        VARCHAR2(20),
  TYPE       VARCHAR2(2),
  DESCR      VARCHAR2(50)
)

显示表中的数据
select 'INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES(' || '''' || ID ||'''' || ','
|| '''' || NAME || '''' || ','
|| '''' || PATH || '''' || ','
|| '''' || PARENTPATH || '''' || ','
|| '''' || URL || '''' || ','
|| '''' || TYPE || '''' || ','
|| '''' || DESCR || '''' || ');'
 From tb_accident_type order by ID

显示结果

INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('1','事故类型关联 ','1','0','','0','');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('2','危险源类型关联','2','0','','','');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('3','危险品类型关联','3','0','','','');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('4','生产企业类型关联','4','0','','','');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('5','区域关联','5','0','','0','');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('568','物体打击','1.1','1','','1','物体打击');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('569','车辆伤害','1.2','1','','1','车辆伤害');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('570','机器伤害','1.3','1','','1','机器伤害');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('571','起重伤害','1.4','1','','1','起重伤害');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('572','触电','1.5','1','','1','触电');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('573','淹溺','1.6','1','','1','淹溺');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('574','灼烫','1.7','1','','1','灼烫');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('575','火灾','1.8','1','','1','火灾');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('576','高处坠落','1.9','1','','1','高处坠落');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('577','坍塌','1.10','1','','1','坍塌');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('578','冒顶片帮','1.11','1','','1','冒顶片帮');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('580','透水','1.12','1','','1','透水');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('581','波炮','1.13','1','','1','波炮');
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('582','火药爆炸','1.14','1','','1','火药爆炸')
INSERT INTO tb_accident_type (ID,NAME,PATH,PARENTPATH,URL,TYPE,DESCR)
 VALUES('583','瓦斯爆炸','1.15','1','','1','瓦斯爆炸');

 

你可能感兴趣的:(oracle学习)