bcp

Bulk-copy region entries to a file or bulk-copy file contents to region. The region & file path can be absolute or relative. Examples:

1. Import data from file.


gfsh:/Orders>bcp /Orders in data/bcp/in-orders.csv
	
bcp in complete
	       To (region): /Orders
	       From (file): /home/user/gfsh/data/bcp/in-orders.csv
        Row count: 6
   elapsed (msec): 29
	
gfsh:/Orders>select * from /Orders                
	
Row  Id  Time                          Quantity  ProductId  CustomerId  Discount
---  --  ----                          --------  ---------  ----------  --------
1    1   Mon Jun 30 11:22:03 IST 2008  10        HSHD303    CUST10401   0.5
2    4   Fri Jul 06 15:22:03 IST 2007  5         HSHD303    CUST13541   0.4
3    3   Fri Sep 04 10:22:03 IST 2009  7         ELEX302    CUST10401   0.1
4    5   Sat Aug 01 01:22:03 IST 2009  2         ELEX101    CUST34571   0.1
5    6   Thu Jan 13 21:22:03 IST 2011  53        ELEX304    CUST34571   5.0
6    2   Sat Jun 05 23:22:03 IST 2010  9         ELEX203    CUST34571   0.2
	
Class: data.Order
Fetch size: 50, Limit: 1000
	   Results: 6, Returned: 6/6
elapsed (msec): 59

2. Export data to file. For this example, first few files in the file (with comma separated values) should be as follows:

	
#%key data.OrderKey
#%value data.Order
#%date_format MMM dd HH:mm:ss zzz yyyy
#|CustProdId,Id,#|ProductId,CustomerId,Time,Id,Quantity,Discount
CUST96874_HSHD101,1,"HSHD101","CUST96874",Apr 10 00:00:00 IST 2009,1,10,0.5

gfsh:/>bcp /Orders out /home/user/orders-data.csv -k -v

bcp out complete
   From (region): /Orders
       To (file): /home/user/orders-data.csv
       Row count: 3
  elapsed (msec): 8

Execute "bcp -?" for more options

Note: If the region is a partitioned region then the 'out' option retrieves data only from the local dataset of the connected server due to the potentially large size of the partitioned region.