powershell 如何往oracle中导入数据,文件中数据格式如下
“20”,”14″,”1″,”0212″,”08 0940001001″,”20170309″
“20”,”14″,”1″,”0212″,”34 0940001001″,”20170519″
“20”,”14″,”1″,”0212″,”35 0940001001″,”20170523″
“20”,”14″,”1″,”0212″,”36 0940001001″,”20170523″
“20”,”14″,”1″,”0212″,”37 0940001001″,”20170523″
望大神解惑!!!
1 Answers
将csv文本转换成PowerShell对象:
Get-Content E:\test.txt | ConvertFrom-Csv
如何导进oracle有两个方案:
- 转换成SQL,直接在oracle中运行sQL脚本
这里分享一段我批量生成2000条假数据的脚本,你只需照猫画虎。$initDate = (Get-Date ).AddDays(-600) 2..2000 | foreach{ $s=@' INSERT INTO `out_apply_status` ( `out_apply_id`, `out_status_id`) VALUES ({1}, 1); INSERT INTO `out_storage_apply` (`number`, `storage_id`, `owner_id`, `product_type_id`, `apply_out_storage_date`, `in_apply_id`, `apply_date`, `is_need_car`, `consignee_name`, `consignee_phone`, `deliver_address`, `comment`) VALUES ('12', 1, 1, 1, '{0}', 1, '{0}', 'a', 'sdfsdf', 's', 'ds', 'sd'); '@ $s -f $initDate.AddMinutes($_),$_ | Out-File my.sql -Append }
- 连接ADO.NET, 参考PowerShell 连接SQL Server 数据库