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

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) 
主站蜘蛛池模板: 峡江县| 和硕县| 晋宁县| 安顺市| 娄底市| 定兴县| 郁南县| 镇坪县| 微山县| 普格县| 启东市| 怀集县| 张掖市| 肃宁县| 东山县| 大关县| 元江| 葫芦岛市| 福泉市| 景洪市| 江孜县| 五台县| 阳高县| 湘西| 顺义区| 凌海市| 穆棱市| 永嘉县| 深水埗区| 温宿县| 新丰县| 浏阳市| 黄大仙区| 丰宁| 雷州市| 辽宁省| 高阳县| 凯里市| 玛曲县| 清远市| 漳浦县|