官术网_书友最值得收藏!

Loading some sample data

To make this chapter a pleasant experience for you, I have compiled some sample data, which has been taken from the BP energy report: http://www.bp.com/en/global/corporate/energy-economics/statistical-review-of-world-energy/downloads.html.

Here is the data structure that will be used:

test=# CREATE TABLE t_oil ( 
region text,
country text,
year int,
production int,
consumption int
);
CREATE TABLE

The test data can be downloaded from our website using curl directly:

test=# COPY t_oil FROM PROGRAM ' 
curl https://www.cybertec-postgresql.com/secret/oil_ext.txt ';

COPY 644

As in the previous chapter, you can download the file before importing it. On some operating systems, curl is not there by default or has not been installed, so downloading the file before might be an easier option for many people.

There is data for between 1965 and 2010, for 14 nations in two regions of the world:

test=# SELECT region, avg(production) FROM  t_oil GROUP BY region; 
    region     |          avg           
---------------+----------------------- 
 Middle East   | 1992.6036866359447005 
 North America | 4541.3623188405797101 
(2 rows) 
主站蜘蛛池模板: 东阿县| 湘潭县| 仙桃市| 鸡东县| 崇礼县| 彩票| 福安市| 三明市| 诸城市| 彭泽县| 抚州市| 桦川县| 苗栗市| 石渠县| 醴陵市| 乌审旗| 会宁县| 龙山县| 明光市| 太康县| 维西| 团风县| 泰来县| 福贡县| 清丰县| 张北县| 凌云县| 霍邱县| 蒙山县| 大港区| 商城县| 叶城县| 玉环县| 休宁县| 稻城县| 大方县| 井研县| 蒲城县| 海淀区| 巴楚县| 恩施市|