H2 數據庫導入CSV文件實現原理簡析
更新時間:2012年11月24日 15:37:30 作者:
在開發(fā)應用中經常會碰到一些數據庫方面的問題,例如:csv文件導入數據庫,本文將以此問題進行深入介紹,需要的朋友可以參考下
1.啟動H2數據庫不打開瀏覽器窗口(默認是打開的)
2.數據庫創(chuàng)建SQL增加了支持BigDecimal類型,h2數據庫默認是不支持bigdecimal類型的:
Sql代碼
create table test(id int(11),charge BigDecimal(12))
Sql代碼
create table test(id int(11),charge BigDecimal(12))
3.通過傳參數方式導入數據庫腳本
new Console().runTool();
new RunScript().runCustomTool("jdbc:h2:~/test", "sa","", "c:/schema.sql");
H2 數據庫導入CSV文件
insert into prescription ( select * from csvread('c:/JV/Demo/prescription2012-05-10 22-26-37.csv')) ;
2.數據庫創(chuàng)建SQL增加了支持BigDecimal類型,h2數據庫默認是不支持bigdecimal類型的:
Sql代碼
復制代碼 代碼如下:
create table test(id int(11),charge BigDecimal(12))
Sql代碼
復制代碼 代碼如下:
create table test(id int(11),charge BigDecimal(12))
3.通過傳參數方式導入數據庫腳本
復制代碼 代碼如下:
new Console().runTool();
new RunScript().runCustomTool("jdbc:h2:~/test", "sa","", "c:/schema.sql");
H2 數據庫導入CSV文件
復制代碼 代碼如下:
insert into prescription ( select * from csvread('c:/JV/Demo/prescription2012-05-10 22-26-37.csv')) ;
相關文章
Linux環(huán)境安裝SQL?Server數據庫以及使用方法詳解
很多朋友在安裝SQL Server的過程中會碰到一些小狀況,下面這篇文章主要給大家介紹了關于Linux環(huán)境安裝SQL?Server數據庫以及使用方法的相關資料,需要的朋友可以參考下2024-02-02