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

  • Mastering PostgreSQL 9.6
  • Hans Jurgen Schonig
  • 163字
  • 2021-07-09 19:57:24

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.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 www.cybertec.at/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 14 nations between 1965 and 2010, which are 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)
主站蜘蛛池模板: 渝中区| 旬邑县| 盐亭县| 巨鹿县| 搜索| 山丹县| 汉阴县| 江华| 毕节市| 平乐县| 孟津县| 樟树市| 南开区| 彭山县| 进贤县| 海门市| 云南省| 石阡县| 衢州市| 新野县| 顺昌县| 彝良县| 大厂| 奉贤区| 兴义市| 芒康县| 如东县| 乐安县| 康乐县| 武义县| 双牌县| 专栏| 勐海县| 饶河县| 西林县| 新建县| 天台县| 满城县| 广平县| 安达市| 砀山县|