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

Loading some sample data

To make this chapter a pleasant experience for you, we will compile some sample data that has been taken from the BP energy report, which can be found at 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

Like we did in the previous chapter, we can download the file before importing it. On some operating systems, curl is not present 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 2 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) 
主站蜘蛛池模板: 土默特左旗| 盈江县| 松江区| 安阳市| 烟台市| 平度市| 金华市| 东丽区| 馆陶县| 客服| 墨竹工卡县| 搜索| 原阳县| 文成县| 沙田区| 边坝县| 武定县| 东方市| 靖宇县| 高台县| 吉木乃县| 灵武市| 襄城县| 张掖市| 如皋市| 涿州市| 辉南县| 松溪县| 简阳市| 昌吉市| 崇仁县| 阳东县| 师宗县| 昌江| 安远县| 巴青县| 泾阳县| 城步| 九龙城区| 六枝特区| 繁峙县|