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

  • 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)
主站蜘蛛池模板: 周至县| 旬邑县| 儋州市| 翁源县| 呼图壁县| 花莲市| 双鸭山市| 永吉县| 尉氏县| 库车县| 盐边县| 丰都县| 阿坝县| 马尔康县| 山东省| 奉新县| 岳阳市| 泉州市| 潼南县| 三河市| 大丰市| 三台县| 龙山县| 丰宁| 凌云县| 冀州市| 石柱| 建始县| 沈阳市| 博兴县| 洛扎县| 公安县| 盘锦市| 增城市| 介休市| 湖口县| 德令哈市| 丰台区| 安仁县| 聂荣县| 蒲城县|