本文主要是介绍Linux下执行bcp指令,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
先抛一个问题
[root@localhost AccountInspector]# bcp INSPECTOR_LOG.dbo.Table_NewVersionAvgDelay out t001.txt -c -U sa -P hundsun@1 -S 192.168.11.11
bash: bcp: 未找到命令...
Linux下不支持pcb,需要安装相应的工具包,安装教程如下
我的系统是CentOs7,按照Red Hat版本进行安装
1.进入超级用户模式
sudo su
2.下载配置文件
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
3.退出超级用户模式
Exit
4.如果之前安装过mssql-tools ,要将那些老版本的unixODBC卸载掉
sudo yum update
sudo yum remove unixODBC-utf16 unixODBC-utf16-devel
5.安装最新的unixODBC开发包
sudo yum update
sudo yum install mssql-tools unixODBC-devel
6.配置环境变量
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
7.为了能够在不登录会话或者是交互模式可以执行sqlcmd/bcp,需要在~/.bashrc文件中修改路径
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
再次执行指令发现可以使用pcb了
[root@localhost ~]# bcp INSPECTOR_LOG.dbo.Table_NewVersionAvgDelay out t001.txt -c -U sa -P hundsun@1 -S 192.168.11.11Starting copy...
1000 rows successfully bulk-copied to host-file. Total received: 1000
1000 rows successfully bulk-copied to host-file. Total received: 2000
1000 rows successfully bulk-copied to host-file. Total received: 3000
1000 rows successfully bulk-copied to host-file. Total received: 4000
1000 rows successfully bulk-copied to host-file. Total received: 5000
1000 rows successfully bulk-copied to host-file. Total received: 6000
1000 rows successfully bulk-copied to host-file. Total received: 7000
1000 rows successfully bulk-copied to host-file. Total received: 8000
1000 rows successfully bulk-copied to host-file. Total received: 90009703 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.) Total : 407 Average : (23840.3 rows per sec.)
相关链接:
linux下安装bcp(访问不了请自行翻墙)
bcp使用教程
这篇关于Linux下执行bcp指令的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!