開始移植工作的時候,嘗試了很多自動轉換工具,包括access通過odbc匯出,csv匯入等等,發現有一些問題: 例如得到字段型別轉換不能滿意,象boolean被變成char等等.後來開始自己寫轉換指令碼.
1 最簡單的使用sql插入.所有的表結構通過手工定義.
<%@ language = vbscript codepage = 936%>
<%
dim connstr,conn1,conn2,db
set conn1 = server.createobject("adodb.connection")
conn1.open connstr
dim sqldatabasename,sqlpassword,sqlusername,sqllocalname
sqlpassword = "test"
sqlusername = "system"
sqllocalname = "orcl"
connstr = "provider = oraoledb.oracle.1; persist security info=true; user id = " & sqlusername & "; password = " & sqlpassword & "; data source = " & sqllocalname & ";"
set conn2 = server.createobject("adodb.connection")
conn2.open connstr
sql="select * from xxlx"
set rs1 = server.createobject("adodb.recordset")
rs1.open sql, conn1, 1, 1
do while not rs1.eof
sql = "insert into xxlx (" _
& "xxlxid" & "," _
& "bumen" & "," _
& "xxlx" & ")" _
&"values('" _
& rs1("xxlxid") & "','" _
& rs1("bumen") & "','" _
& rs1("xxlx") & "')"
response.write sql & " "
conn2.execute(sql)
rs1.movenext
loop
rs1.close
set rs1 = nothing
conn1.close
set conn1=nothing
conn2.close
set conn2=nothing
使用sql方式時候,要注意將字串裡面的' " 轉換掉.
if rs1("filename") <> "" then
filename = replace(rs1("filename"),"'","''")
filename = replace(filename,"""","""""")
else
filename = ""
end if
2 對於有些text欄位很長,而oracle的sql只能4000字的限制.將所有包含lob的字段通過ado 對拷的方式進行.
<%@ language = vbscript codepage = 936%>
<%
dim connstr,conn1,conn2,db,rs1,rs2
set conn1 = server.createobject("adodb.connection")
conn1.open connstr
dim sqldatabasename,sqlpassword,sqlusername,sqllocalname
sqlpassword = "test"
sqlusername = "system"
sqllocalname = "orcl"
connstr = "provider = oraoledb.oracle; persist security info=true; user id = " & sqlusername & "; password = " & sqlpassword & "; data source = " & sqllocalname & ";"
set conn2 = server.createobject("adodb.connection")
conn2.open connstr
sql="select * from mrch order by id asc"
set rs1 = server.createobject("adodb.recordset")
rs1.open sql, conn1,1,1
sql="select username username,address address,filename filename,info_type info_type,""date"" ""date"",title title,keyword keyword,summary summary,domain domain,dept dept,sensitive sensitive,scbj scbj,time time,jhxxlx jhxxlx from mrch"
set rs2 = server.createobject("adodb.recordset")
rs2.open sql, conn2,1,4
dim i,tmp
i = 0
do while not rs1.eof
i= i+1
rs2.addnew
rs2("username")=rs1("username")
rs2("address")=rs1("address")
rs2("filename")=rs1("filename")
rs2("info_type")=rs1("info_type")
rs2("date")=rs1("date")
rs2("title")=rs1("title")
rs2("keyword")=rs1("keyword")
rs2("summary")=rs1("summary")
rs2("domain")=rs1("domain")
rs2("dept")=rs1("dept")
rs2("sensitive")=rs1("sensitive")
rs2("scbj")=rs1("scbj")
rs2("time")=rs1("time")
rs2("jhxxlx")=rs1("jhxxlx")
response.write i & rs1("summary") & rs1("time") &"
"rs1.movenext
loop
rs2.updatebatch
rs2.close
set rs2 = nothing
rs1.close
set rs1 = nothing
conn1.close
set conn1=nothing
conn2.close
set conn2=nothing
這裡有三點要說明
1 必須使用oracle自己的oledb,用ms的,有資料型別的問題
2 所有的字段必須顯示給出,否則oracle 會省略一些欄位名: 例如info_type變成in
3 ado記錄必須用1 4開啟,批處理模式
將Access資料庫移植到Oracle筆記
開始移植工作的時候,嘗試了很多自動轉換工具,包括access通過odbc匯出,csv匯入等等,發現有一些問題 例如得到字段型別轉換不能滿意,象boolean被變成char等等.後來開始自己寫轉換指令碼.1 最簡單的使用sql插入.所有的表結構通過手工定義.language vbscript code...
將Access資料庫移植到Oracle筆記
開始移植工作的時候,嘗試了很多自動轉換工具,包括access通過odbc匯出,csv匯入等等,發現有一些問題 例如得到字段型別轉換不能滿意,象boolean被變成char等等.後來開始自己寫轉換指令碼.1 最簡單的使用sql插入.所有的表結構通過手工定義.language vbscript code...
將Access資料庫移植到Oracle筆記
開始移植工作的時候,嘗試了很多自動轉換工具,包括access通過odbc匯出,csv匯入等等,發現有一些問題 例如得到字段型別轉換不能滿意,象boolean被變成char等等.後來開始自己寫轉換指令碼.1 最簡單的使用sql插入.所有的表結構通過手工定義.language vbscript code...