100% found this document useful (2 votes)
16 views

Download full Foundation Db2 and Python: Access Db2 with Module-Based API Examples Using Python 1st Edition W. David Ashley ebook all chapters

API

Uploaded by

mbuwircamana45
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
16 views

Download full Foundation Db2 and Python: Access Db2 with Module-Based API Examples Using Python 1st Edition W. David Ashley ebook all chapters

API

Uploaded by

mbuwircamana45
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Download Full Version ebook - Visit ebookmeta.

com

Foundation Db2 and Python: Access Db2 with Module-


Based API Examples Using Python 1st Edition W.
David Ashley

https://ebookmeta.com/product/foundation-db2-and-python-
access-db2-with-module-based-api-examples-using-python-1st-
edition-w-david-ashley/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmeta.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Start reading on any device today!

Foundation Db2 and Python: Access Db2 with Module-Based


API Examples Using Python 1st Edition W. David Ashley

https://ebookmeta.com/product/foundation-db2-and-python-access-
db2-with-module-based-api-examples-using-python-1st-edition-w-david-
ashley-2/
ebookmeta.com

Practical Explainable AI Using Python: Artificial


Intelligence Model Explanations Using Python-based
Libraries, Extensions, and Frameworks Pradeepta Mishra
https://ebookmeta.com/product/practical-explainable-ai-using-python-
artificial-intelligence-model-explanations-using-python-based-
libraries-extensions-and-frameworks-pradeepta-mishra/
ebookmeta.com

Learn OpenCV with Python by Examples 2nd Edition James


Chen

https://ebookmeta.com/product/learn-opencv-with-python-by-
examples-2nd-edition-james-chen/

ebookmeta.com

Dead Skip 1st Edition Joe Gores

https://ebookmeta.com/product/dead-skip-1st-edition-joe-gores/

ebookmeta.com
Mack s Witness Elle James

https://ebookmeta.com/product/mack-s-witness-elle-james/

ebookmeta.com

physics volume 1 2023 2023rd Edition Sl Arora

https://ebookmeta.com/product/physics-volume-1-2023-2023rd-edition-sl-
arora/

ebookmeta.com

Supervised Machine Learning for Text Analysis in R 1st


Edition Emil Hvitfeldt Julia Silge

https://ebookmeta.com/product/supervised-machine-learning-for-text-
analysis-in-r-1st-edition-emil-hvitfeldt-julia-silge/

ebookmeta.com

Entropy Beyond the Second Law. Thermodynamics and


statistical mechanics for equilibrium, non-equilibrium,
classical, and quantum systems 2nd Edition Phil Attard
https://ebookmeta.com/product/entropy-beyond-the-second-law-
thermodynamics-and-statistical-mechanics-for-equilibrium-non-
equilibrium-classical-and-quantum-systems-2nd-edition-phil-attard/
ebookmeta.com

Lone Star Playboy Saddle Creek TX The Crawfords Book 4 1st


Edition Kat Baxter

https://ebookmeta.com/product/lone-star-playboy-saddle-creek-tx-the-
crawfords-book-4-1st-edition-kat-baxter-2/

ebookmeta.com
The Rover Boys MEGAPACK 26 Boys Adventure Novels Edward
Stratemeyer

https://ebookmeta.com/product/the-rover-boys-megapack-26-boys-
adventure-novels-edward-stratemeyer/

ebookmeta.com
Foundation
Db2 and Python
Access Db2 with Module-Based API
Examples Using Python

W. David Ashley
Foundation Db2
and Python
Access Db2 with Module-Based API
Examples Using Python

W. David Ashley
Foundation Db2 and Python
W. David Ashley
Austin, TX, USA

ISBN-13 (pbk): 978-1-4842-6941-1 ISBN-13 (electronic): 978-1-4842-6942-8


https://doi.org/10.1007/978-1-4842-6942-8

Copyright © 2021 by W. David Ashley


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Celestin Suresh John
Development Editor: James Markham
Coordinating Editor: Divya Modi
Cover designed by eStudioCalamar
Cover image designed by Pixabay
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza,
Suite 4600, New York, NY 10004-1562, USA. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@
springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole
member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc
is a Delaware corporation.
For information on translations, please e-mail [email protected]; for reprint,
paperback, or audio rights, please e-mail [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/978-­1-­4842-­6941-­1. For more
detailed information, please visit http://www.apress.com/source-­code.
Printed on acid-free paper
This book is dedicated to teachers everywhere, but especially
all those who had me as a student.
Table of Contents
About the Author��������������������������������������������������������������������������������������������������� xiii

About the Technical Reviewer���������������������������������������������������������������������������������xv

Chapter 1: Introduction to Db2��������������������������������������������������������������������������������� 1


What Is a Relational Database?���������������������������������������������������������������������������������������������������� 3
The Relational Model��������������������������������������������������������������������������������������������������������������� 3
Domains���������������������������������������������������������������������������������������������������������������������������������� 4
Keys and Indexes��������������������������������������������������������������������������������������������������������������������� 4
Relationships��������������������������������������������������������������������������������������������������������������������������� 4
Transactions���������������������������������������������������������������������������������������������������������������������������� 5
Stored Procedures������������������������������������������������������������������������������������������������������������������� 5
Constraints������������������������������������������������������������������������������������������������������������������������������ 6
Normalization�������������������������������������������������������������������������������������������������������������������������� 6
SQL������������������������������������������������������������������������������������������������������������������������������������������������ 6
Data Definition Language (DDL)����������������������������������������������������������������������������������������������� 7
Data Query Language (DQL)���������������������������������������������������������������������������������������������������� 7
Data Control Language (DCL)��������������������������������������������������������������������������������������������������� 7
Data Manipulation Language (DML)���������������������������������������������������������������������������������������� 7
The ibm_db Project����������������������������������������������������������������������������������������������������������������������� 8
Summary�������������������������������������������������������������������������������������������������������������������������������������� 8

Chapter 2: Installing Db2������������������������������������������������������������������������������������������ 9


My Development Environment������������������������������������������������������������������������������������������������������ 9
Installation Prerequisites������������������������������������������������������������������������������������������������������������ 10
Planning the Db2 Install�������������������������������������������������������������������������������������������������������������� 11
Installing Db2������������������������������������������������������������������������������������������������������������������������������ 12

v
Table of Contents

Db2 Post-install Tasks����������������������������������������������������������������������������������������������������������������� 19


Installing the Db2 Sample Database������������������������������������������������������������������������������������������� 20
Summary������������������������������������������������������������������������������������������������������������������������������������ 21

Chapter 3: Db2 Management���������������������������������������������������������������������������������� 23


Db2 Instances����������������������������������������������������������������������������������������������������������������������������� 23
db2ilist����������������������������������������������������������������������������������������������������������������������������������� 25
Instance Environment Commands����������������������������������������������������������������������������������������� 25
Creating an Instance������������������������������������������������������������������������������������������������������������� 26
Arranging a Communication Port and Host for an Instance�������������������������������������������������� 26
Updating an Instance������������������������������������������������������������������������������������������������������������� 27
Upgrading an Instance���������������������������������������������������������������������������������������������������������� 28
Dropping an Instance������������������������������������������������������������������������������������������������������������ 29
Using Other Commands with an Instance����������������������������������������������������������������������������� 29
Databases����������������������������������������������������������������������������������������������������������������������������������� 30
Db2 Catalog Views����������������������������������������������������������������������������������������������������������������� 31
Locking Event Monitor����������������������������������������������������������������������������������������������������������� 31
Tablespace Information��������������������������������������������������������������������������������������������������������� 32
Storage Group Control Files��������������������������������������������������������������������������������������������������� 33
Global Configuration File������������������������������������������������������������������������������������������������������� 33
History Files��������������������������������������������������������������������������������������������������������������������������� 33
Logging Files������������������������������������������������������������������������������������������������������������������������� 33
Automated Storage Containers���������������������������������������������������������������������������������������������� 33
Creating a Database�������������������������������������������������������������������������������������������������������������� 34
Listing Databases������������������������������������������������������������������������������������������������������������������ 35
Activating a Database������������������������������������������������������������������������������������������������������������ 36
Deactivating a Database�������������������������������������������������������������������������������������������������������� 36
Connecting to a Database����������������������������������������������������������������������������������������������������� 36
Dropping a Database������������������������������������������������������������������������������������������������������������� 36
Tables������������������������������������������������������������������������������������������������������������������������������������������ 37
Table Types���������������������������������������������������������������������������������������������������������������������������� 39
Built-in Data Types���������������������������������������������������������������������������������������������������������������� 39

vi
Table of Contents

Creating a Table��������������������������������������������������������������������������������������������������������������������� 41
Alter a Table��������������������������������������������������������������������������������������������������������������������������� 43
Other Table SQL Statements�������������������������������������������������������������������������������������������������� 43
Dropping a Table�������������������������������������������������������������������������������������������������������������������� 44
Summary������������������������������������������������������������������������������������������������������������������������������������ 44

Chapter 4: Database Physical Design��������������������������������������������������������������������� 45


Phase 1: Data Gathering and Normalization������������������������������������������������������������������������������� 46
Data Gathering����������������������������������������������������������������������������������������������������������������������� 46
Data Normalization���������������������������������������������������������������������������������������������������������������� 48
Business Rules���������������������������������������������������������������������������������������������������������������������� 51
Phase 2: Physical Design of the Database���������������������������������������������������������������������������������� 51
Backups��������������������������������������������������������������������������������������������������������������������������������� 52
Summary������������������������������������������������������������������������������������������������������������������������������������ 53

Chapter 5: Db2 Utilities������������������������������������������������������������������������������������������� 55


Backup Command����������������������������������������������������������������������������������������������������������������������� 56
What Is a Backup?����������������������������������������������������������������������������������������������������������������� 56
Backup Verification���������������������������������������������������������������������������������������������������������������� 57
Advanced Backup Options����������������������������������������������������������������������������������������������������� 57
Backup Syntax����������������������������������������������������������������������������������������������������������������������� 57
Export Command������������������������������������������������������������������������������������������������������������������������� 59
Command syntax������������������������������������������������������������������������������������������������������������������� 60
Usage Notes�������������������������������������������������������������������������������������������������������������������������� 60
Import Command������������������������������������������������������������������������������������������������������������������������ 61
Command Syntax������������������������������������������������������������������������������������������������������������������ 61
Load Command��������������������������������������������������������������������������������������������������������������������������� 62
Command Syntax������������������������������������������������������������������������������������������������������������������ 62
Restore Command���������������������������������������������������������������������������������������������������������������������� 63
Command Syntax������������������������������������������������������������������������������������������������������������������ 64
Summary������������������������������������������������������������������������������������������������������������������������������������ 65

vii
Table of Contents

Chapter 6: Business Rules and Constraints������������������������������������������������������������ 67


NOT NULL Attribute��������������������������������������������������������������������������������������������������������������������� 67
Primary Key��������������������������������������������������������������������������������������������������������������������������������� 68
Indexes���������������������������������������������������������������������������������������������������������������������������������������� 69
Foreign Keys������������������������������������������������������������������������������������������������������������������������������� 70
CHECK and Unique Constraints��������������������������������������������������������������������������������������������������� 71
DEFAULT Constraint��������������������������������������������������������������������������������������������������������������������� 72
Triggers��������������������������������������������������������������������������������������������������������������������������������������� 72
Summary������������������������������������������������������������������������������������������������������������������������������������ 76

Chapter 7: Writing Good SQL for Db2���������������������������������������������������������������������� 77


Relational Theory������������������������������������������������������������������������������������������������������������������������ 77
Reduce Passes Through Data����������������������������������������������������������������������������������������������������� 78
Using Indexes to Increase Performance������������������������������������������������������������������������������������� 81
Sorting and Grouping������������������������������������������������������������������������������������������������������������������ 81
Programs Containing SQL����������������������������������������������������������������������������������������������������������� 82
Use Db2 Utilities Where Possible������������������������������������������������������������������������������������������������ 83
Db2 Functions����������������������������������������������������������������������������������������������������������������������������� 84
Multiple Ways to Code SQL��������������������������������������������������������������������������������������������������������� 86
Summary������������������������������������������������������������������������������������������������������������������������������������ 86

Chapter 8: Python and ibm_db������������������������������������������������������������������������������� 87


Your First Python ibm_db Program��������������������������������������������������������������������������������������������� 89
Using Parameter Markers������������������������������������������������������������������������������������������������������ 96
More on Parameter Markers�������������������������������������������������������������������������������������������������� 98
Producing Multiple Reports with Parameter Markers��������������������������������������������������������� 100
Using Parameter Markers Without Binding Variables���������������������������������������������������������� 103
Joining Tables���������������������������������������������������������������������������������������������������������������������� 106
Inserts, Updates, and Deletes���������������������������������������������������������������������������������������������� 109
Some Other ibm_db APIs����������������������������������������������������������������������������������������������������� 112
Creating Database Objects�������������������������������������������������������������������������������������������������� 116

viii
Table of Contents

Obtaining Attributes of an Existing Table����������������������������������������������������������������������������� 120


Obtaining Attributes of a Result Set������������������������������������������������������������������������������������ 126
ibm_db_dbi and Python������������������������������������������������������������������������������������������������������������ 130
Where Is the ibm_db Module Going?���������������������������������������������������������������������������������������� 133
The ibm_db_dbi Module������������������������������������������������������������������������������������������������������ 134
The Django Database Interface������������������������������������������������������������������������������������������� 134
The SQLAlchemy Adapter���������������������������������������������������������������������������������������������������� 135
The Alembic Adapter����������������������������������������������������������������������������������������������������������� 136
The Future��������������������������������������������������������������������������������������������������������������������������� 137
Summary���������������������������������������������������������������������������������������������������������������������������������� 137

Appendix A: Python ibm_db API��������������������������������������������������������������������������� 139


i bm_db APIs������������������������������������������������������������������������������������������������������������������������������ 139
ibm_db.active���������������������������������������������������������������������������������������������������������������������� 139
ibm_db.autocommit������������������������������������������������������������������������������������������������������������ 140
ibm_db.bind_param������������������������������������������������������������������������������������������������������������ 141
ibm_db.callproc������������������������������������������������������������������������������������������������������������������� 143
ibm_db.client_info��������������������������������������������������������������������������������������������������������������� 144
ibm_db.close����������������������������������������������������������������������������������������������������������������������� 146
ibm_db.column_privileges�������������������������������������������������������������������������������������������������� 147
ibm_db.columns������������������������������������������������������������������������������������������������������������������ 148
ibm_db.commit������������������������������������������������������������������������������������������������������������������� 151
ibm_db.conn_error�������������������������������������������������������������������������������������������������������������� 152
ibm_db.conn_errormsg������������������������������������������������������������������������������������������������������� 153
ibm_db.connect������������������������������������������������������������������������������������������������������������������� 154
ibm_db.createdb����������������������������������������������������������������������������������������������������������������� 157
ibm_db.createdbNX������������������������������������������������������������������������������������������������������������� 158
ibm_db.cursor_type������������������������������������������������������������������������������������������������������������ 159
ibm_db.dropdb�������������������������������������������������������������������������������������������������������������������� 160
ibm_db.exec_immediate����������������������������������������������������������������������������������������������������� 160
ibm_db.execute������������������������������������������������������������������������������������������������������������������� 162

ix
Table of Contents

ibm_db.execute_many�������������������������������������������������������������������������������������������������������� 163
ibm_db.fetch_tuple������������������������������������������������������������������������������������������������������������� 165
ibm_db.fetch_assoc������������������������������������������������������������������������������������������������������������ 166
ibm_db.fetch_both�������������������������������������������������������������������������������������������������������������� 167
ibm_db.fetch_row��������������������������������������������������������������������������������������������������������������� 168
ibm_db.field_display_size��������������������������������������������������������������������������������������������������� 169
ibm_db.field_name������������������������������������������������������������������������������������������������������������� 169
ibm_db.field_num��������������������������������������������������������������������������������������������������������������� 170
ibm_db.field_precision�������������������������������������������������������������������������������������������������������� 172
ibm_db.field_scale�������������������������������������������������������������������������������������������������������������� 173
ibm_db.field_type���������������������������������������������������������������������������������������������������������������� 174
ibm_db.field_width������������������������������������������������������������������������������������������������������������� 174
ibm_db.foreign_keys����������������������������������������������������������������������������������������������������������� 175
ibm_db.free_result�������������������������������������������������������������������������������������������������������������� 178
ibm_db.free_stmt���������������������������������������������������������������������������������������������������������������� 179
ibm_db.get_option�������������������������������������������������������������������������������������������������������������� 179
ibm_db.next_result������������������������������������������������������������������������������������������������������������� 181
ibm_db.num_fields�������������������������������������������������������������������������������������������������������������� 183
ibm_db.num_rows�������������������������������������������������������������������������������������������������������������� 184
ibm_db.pconnect����������������������������������������������������������������������������������������������������������������� 185
ibm_db.prepare������������������������������������������������������������������������������������������������������������������� 187
ibm_db.primary_keys���������������������������������������������������������������������������������������������������������� 188
ibm_db.procedure_columns������������������������������������������������������������������������������������������������ 190
ibm_db.procedures������������������������������������������������������������������������������������������������������������� 192
ibm_db.recreatedb�������������������������������������������������������������������������������������������������������������� 194
ibm_db.result���������������������������������������������������������������������������������������������������������������������� 194
ibm_db.rollback������������������������������������������������������������������������������������������������������������������� 195
bm_db.server_info�������������������������������������������������������������������������������������������������������������� 196
ibm_db.set_option��������������������������������������������������������������������������������������������������������������� 199
ibm_db.special_columns���������������������������������������������������������������������������������������������������� 201

x
Table of Contents

ibm_db.statistics����������������������������������������������������������������������������������������������������������������� 203
ibm_db.stmt_error�������������������������������������������������������������������������������������������������������������� 206
ibm_db.stmt_errormsg������������������������������������������������������������������������������������������������������� 206
ibm_db.table_privileges������������������������������������������������������������������������������������������������������ 207
ibm_db.tables���������������������������������������������������������������������������������������������������������������������� 209
Summary���������������������������������������������������������������������������������������������������������������������������������� 210

Index��������������������������������������������������������������������������������������������������������������������� 211

xi
About the Author
W. David Ashley is a technical writer for Skillsoft where he
specializes in open source, particularly Linux. As a member
of the Linux Fedora documentation team, he recently led
the Libvirt project documentation and wrote the Python
programs included with it. He has developed in 20 different
programming languages during his 30 years as a software
developer and IT consultant, including more than 18 years at
IBM and 12 years with American Airlines.

xiii
About the Technical Reviewer
Sourav Bhattacharjee is a senior technical member for
Oracle Cloud Infrastructure. As part of IBM Watson Health
Lab, he has developed many scalable systems, published a
few research papers, and applied some patents to USPTO. He
has an ample amount of hands-on experience in Python,
Java, machine learning, and many database systems. He
earned his master’s degree from the Indian Institute of
Technology, Kharagpur, India.

xv
CHAPTER 1

Introduction to Db2
Welcome to this introduction to Db2. Since you are here, you are likely looking for a
place to get started with Db2. Our hope is that this book will be that first step you are
looking for. This book is meant to be an introduction to the Db2 environment and to
the Python interface. The first half of the book will cover Db2 at a level that should be of
interest to both administrators and programmers. It will cover many aspects of Db2 that
you will make use of in either of the two roles. The last half of the book will concentrate
on using the Python programming language to interface to Db2. While mainly oriented
to programmers, administrators will find it useful as well for some of their everyday
tasks.
Db2 has a long history and is the first relational database implementation. It was
first proposed by Edgar Frank “Ted” Codd in a paper titled “A Relational Model of Data
for Large Shared Data Banks” in 1969 while working at the IBM’s San Jose Research
Laboratory in California. In the next four years, IBM researchers worked to create a
system based on the principles described in Codd’s paper (called System R). During
this time, it became obvious that a new language was needed to interact with the new
system. Codd wrote a new paper “A Data Base Sublanguage Founded on Relational
Calculus,” which became the basis for the new language called DSL/Alpha. This quickly
went through some name changes but eventually ended up being called SQL, short for
Structured Query Language.
Eventually there was an effort in the 1970s to port DSL/Alpha to the 370 mainframe
environment. It was renamed to Database 2 in 1982. The next year it was made available
to the public with another name change, DB2. This was a limited release but was highly
regarded by the customers that evaluated it. The customers actually pushed IBM to
deliver DB2 to a wider set of customers. IBM was somewhat reluctant because they were
trying to hold on to their IMS/DB market share. But eventually the customers won out,
and DB2 began to spread to other platforms including OS/2, AIX/RS6000, and Windows.

1
© W. David Ashley 2021
W. D. Ashley, Foundation Db2 and Python, https://doi.org/10.1007/978-1-4842-6942-8_1
Chapter 1 Introduction to Db2

Over the next two decades, the product went through a number of name changes
and several platform code bases. Recently with the release of version 11.1, IBM
rebranded the entire product line and brought the code bases into a small number of
code bases. The following set of products are now the standard offerings:

• Db2 (formerly DB2 LUW)

• Db2 for z/OS (formerly DB2 for z/OS)

• Db2 Hosted (formerly DB2 on Cloud)

• Db2 on Cloud (formerly dashDB for Transactions)

• Db2 Event Store (a new in-memory database for event-driven


transaction processing)

• Db2 Warehouse on Cloud (formerly dashDB)

• Db2 Warehouse (formerly dashDB Local)

• IBM Integrated Analytics System (a new system platform that


combines analytic performance and functionality of the IBM
PureData System with IBM Netezza)

The code bases for today’s Db2 offerings share a common code base that makes
porting the code to another hardware/software platform a relatively easy process. The
SQL code base has been standardized so that it is the same across all platforms, making
moving to another platform an easy task from a programming perspective.
There is also a current movement in programming applications with embedded
SQL. These types of applications are very hard to port from one platform to another
without major code modifications. Instead, IBM is moving (where possible) to an API
that can be called to process SQL statements and make use of programming language
variables for values to be added to the SQL statement. This is the methodology used for
Python that we will explore later in this book.
In the past, Db2 was considered to be too large for most applications. But as personal
computers have become a lot more powerful and then databases used by even a small
number of people have become extremely large, Db2 has become more attractive in the
management of this data. Also, the pricing model of Db2 on these platforms has become
more competitive. So if you need the performance and the ability to manage large
amounts of data, Db2 can be a very attractive product.

2
Chapter 1 Introduction to Db2

What Is a Relational Database?


A relational database is actually hard to define because no relational database system in
today’s market actually implements E. F. Codd’s 12 rules defining the relational model.
Instead, commercial relational databases implement only about seven to nine of those
rules. This is enough to make their products commercially useful without the burden of
implementing the other rules. In fact, the other rules would not be useful to most database
users, so it is questionable whether or not they will ever be implemented in a commercial
product. In fact, most commercial database vendors actually extend the relational model
by adding entities that are not really tables, such as BLOBs (which we will discuss later).

The Relational Model


Roughly, relational databases implement the concept of entities expressed as rows
and columns. A customer records table would have a single row representing a single
customer. The columns (or tuples) of the table would contain attributes of that customer.
Each column would contain a single attribute and would have a defined data type for
restricting the type of information it can contain. A typical customer address table might
be implemented as shown in Table 1-1.

Table 1-1. Sample Customer Table


CUSTNO FNAME LNAME STREET STATE ZIP

000000001 Bugs Bunny 1201 Looney Lane CA 77777


000000002 Marvin Martian 2342 Mars Avenue MA 30143
000000003 Daffy Duck 5462 Termite Terrace CA 77745
000000004 Elmer Fudd 23 Hunter Cove CA 77732

This table is a good example because it shows the kind of relationships that can
be expressed in a relational database. The CUSTNO column holds a unique customer
number for each customer (or row). The column is the primary key for this table. The
FNAME and LNAME identify the first and last names of the customer. The STREET is
the address to be used for billing the customer. The STATE column is the U.S. state the
address is located. The ZIP column identifies the mailing zip code.

3
Chapter 1 Introduction to Db2

D
 omains
Domains (or attributes) limit the data in a column to a particular type. For instance, the
data might be an integer of a particular type, a monetary value, a character string of fixed
or variable length, a date or time value, or some other domain that has been defined.

K
 eys and Indexes
The STATE column in Table 1-1 is a foreign key – that is, a primary key in another table.
A rule can be set up so that when you add a new row to the customer table, the system
checks that the value in your proposed STATE field is a valid entry in the state table. If it is
not, the record will not be inserted, and an error will be generated. Keys are also known
as indexes. When you create a primary key in a table, a special index table is created to
hold valid keys. This table is like any other table in the system; it can be queried, added
to, and deleted from. Thus, all the valid keys can be inserted into and maintained in the
table, and it can be maintained just like any other table. Only the special rules make the
index table special.

R
 elationships
All of this shows just some of the kinds of relationships that can be created (or derived)
to properly maintain a set of tables. There are probably other kinds of customer tables
that could be created like a table to maintain customer credit ratings, a customer
shipping address table, a customer contacts table, etc. All of these are specialized entities
that have relationships with the other customer tables. This is what a relational database
is all about. The idea is to express a relationship with data organized so the data is only
stored where needed and hopefully only one time.
Relationships allow the user to create customized reports that can express custom
views of the data from the database. At first glance these reports may look like they have
no relation to the data contained in the database, but they can give insights to the data
not easily possible by other means.

4
Chapter 1 Introduction to Db2

Transactions
Another aspect of relational databases is support for transactions. This means providing
a locking mechanism that can allow data to be modified while others are reading the
data or modifying other data at the same time. This is known as the ACID test, which is
an acronym for the following tests:

• Atomicity defines all the elements that make up a complete database


transaction. This might make up one or more SQL statements.
• Consistency defines the rules for maintaining data points in the
correct state after a transaction. This is usually done through an SQL
statement such as COMMIT or ROLLBACK.

• Isolation keeps the effect of a transaction invisible to others until


it is committed, to avoid confusion. This refers to the ability of the
database to keep multiple changes to a database from corrupting the
integrity of the database.

• Durability ensures that data changes become permanent once the


transaction is committed. This is done by ensuring that writes are
made to all modified tables prior to committing the transaction.

Stored Procedures
A relational database typically implements stored procedures. These are programs
stored in the database to implement special processing under several circumstances.
These procedures usually involve business logic that needs to be implemented the
same across all the database users. In many cases, only the stored procedure has the
proper permissions to modify, insert, delete, or access the data being manipulated. This
prevents users from making modifications to the data if they do not have the correct
permissions.

5
Chapter 1 Introduction to Db2

Constraints
Another property of relational databases are constraints. These make it possible to
further restrict an attribute. For instance, a column might be defined as an integer. But
the range of numbers might actually need to be constrained to a particular range. This is
what a constraint provides.
Constraints can come in many forms and are used for a number of purposes. They
are stored within the database and used when adding or modifying data.

Normalization
Normalization is another attribute of a relational database. This design process reduces
the number of nonatomic values and the duplication of data throughout the database,
thus preventing anomalies and loss of integrity. The process is known as normalization.
The process of normalization is performed by the administrator, usually during the
creation of the database. Users are not usually involved in this activity.

SQL
Within the first few years of creating the first relational database, it became very obvious
that something was needed to actually manipulate the data in a relational database. The
language was invented at IBM by Donald D. Chamberlin and Raymond F. Boyce in the
early 1970s. It was originally known as SEQUEL, but that name was trademarked and it
was changed to Structured Query Language (SQL). SQL was later standardized by ANSI,
but each relational database product extended it as needed to conform to their product
or hardware platform.
SQL is divided into four categories of statements:

• Data Definition Language (DDL)

• Data Query Language (DQL)

• Data Control Language (DCL)


• Data Manipulation Language (DML)

Most SQL books spend most of their resources on the DML part of SQL, but the other
parts are just as important, especially to the database administrator.

6
Chapter 1 Introduction to Db2

Data Definition Language (DDL)


The Data Definition Language subset consists of the CREATE, DROP, ALTER, and
TRUNCATE statements. These statements manipulate (or reorganize) the data in the
database.
The CREATE statement creates new entities in the database. This can include
tables, indexes, views, and procedures. Many database systems include character sets,
collations, transactions, and assertions as well.
The DROP statement removes entities from the database. These include all the
entities that can be created with the CREATE statement. Some databases include the
users as an entity that can be dropped.
The ALTER statement can alter an existing entity, such as adding a new column to a
table.
The TRUNCATE statement removes all data from a table or index. It is much faster
than the DELETE SQL statement.

Data Query Language (DQL)


The Data Query Language subset consists of only the SELECT statement. This is used for
all queries of information in the database. The syntax of the SELECT statement will be
covered later in Chapter 7.

Data Control Language (DCL)


The Data Control Language subset consists of the GRANT and REVOKE statements.
These statements grant and revoke privileges to and from users of the database.
The database system specifies the type of privileges that a user can be granted.
Some database systems, such as SQLite, depend on the operating system’s privilege
mechanism and thus do not support the GRANT and REVOKE statements.

Data Manipulation Language (DML)


The Data Manipulation Language subset consists of the INSERT, UPDATE, and DELETE
statements. Some systems also include the SELECT statement in this subset, but since
SELECT does not make changes to the data, this would seem an odd place to place the
SELECT statement.

7
Chapter 1 Introduction to Db2

The INSERT statement adds new rows into a table. This new data may also
automatically alter the content of a view of the table data.
The UPDATE statement alters one or more rows in an existing table (and any view
dependent on the table). The statement does not add new rows to a table, it only alters
existing data.
The DELETE statement removes rows from a table (and any view dependent on the
table).

The ibm_db Project


The ibm_db project was started sometime in 2007 with the first code commits to
GitHub on February 9, 2008. The project was a joint effort between IBM and the Python
community to create a programming interface to Db2 and Informix from Python.
Informix had been purchased by IBM around this same time, and this was part of the
project to integrate Informix into the Db2 line of products. Since then the project has
undergone steady progress with some recent major fixes.
By establishing the project on GitHub, it was thought that with community support
the project would not only improve with time but would benefit from community
participation. This has proven to be the case with many community volunteers
contributing to the project throughout the project lifetime.
Over time, the ibm_db_dbi module was added to the project, and new projects
were introduced based on the ibm_db module to support other Python projects. These
projects include ibm_db_django, ibm_db_alembic, and ibm_db_sa.
For more information, see Chapter 8.

S
 ummary
This chapter has presented some of the basic concepts that make up a relational
database and the SQL that supports it. This information is common to almost all
relational databases.

8
CHAPTER 2

Installing Db2
This chapter covers installing Db2 on Linux and Windows. Both environments use
the same installer to perform installation and creation of userids and permissions.
The installation process is pretty easy and straightforward, but there are a number of
questions you might have before you start the installation that are not answered by the
install program. We will try to cover those questions as we come to them.

My Development Environment


My development environment is not your typical Windows home system. It consists of
two Linux servers, one Windows client, and two Linux client workstations. The Linux
servers are not typical workstations but actual dedicated servers that are usually used in
small business settings. I will try to describe each system so you have some idea of what
my environment is like.
The first system is a Lenovo ThinkSystem ST250 server with four 2 TB drives
installed. It has 32 GB of memory and a six-core Xeon CPU. This is my main server and
hosts all my files. It is visible to the Internet through my firewall via the Apache Web
Server. The operating system is Fedora 32. It is also hosting my Windows files via Samba
as well as hosting a number of Virtual Machines (VMs) via libvirt. This is the system that
hosts my main Db2 databases.
The second system is Lenovo ThinkStation P320 with 256 GB of SSD and a 1 TB drive
with 32 GB of memory and a six-core/six-thread Xeon CPU. This is my development
server and actually changes configuration about twice a year. It currently runs CentOS
Linux 8.2. This machine also hosts my test Db2 environment.
The third machine is my Windows 10 workstation. It is connected to the first Linux
system via a shared drive (Samba) on the server. This is where I do most of my writing as
well as Windows development and testing.

9
© W. David Ashley 2021
W. D. Ashley, Foundation Db2 and Python, https://doi.org/10.1007/978-1-4842-6942-8_2
Chapter 2 Installing Db2

The fourth system is a Lenovo ThinkCentre M920 with 256 GB of SSD and a 1 TB
drive with 16 GB of memory. It has an i7 CPU. This is my development workstation
where I test all my Linux development and remote access to servers. The operating
system is Fedora 32.
The fifth system is a Lenovo ThinkPad T580 with 256 GB of SSD, 16 GB of memory,
and an i7 CPU. It runs Fedora 32 and usually serves as my travel machine but also as an
auxiliary test device.

I nstallation Prerequisites
Before you even start the Db2 install program, there are a number of prerequisites that
need to be met before you can successfully install everything. Our install environment
for this book is CentOS 8.2. The prerequisites for this OS should be the same for RHEL
8.2, but may be different for other Linux environments. Windows environments have
their own prerequisites, but they are similar to the Linux prerequisites.
The first thing we need is the Db2 install program and support files. To get the free
version of Db2, just go to

www.ibm.com/account/reg/us-en/signup?formid=urx-33669

This gets you to the account registration page. You can either log in with an existing
userid or create a new one. After you are logged in, the website will present you a
preferences page. Select your preferences and select the Continue button. On the
next web page, select the download you need. Unless you need them, just ignore the
pureScale support downloads. Once the download is complete, move the downloaded
file to a safe location and then unzip or untar it. This will create a new subdirectory in the
current directory with the install files exploded inside.

Caution! Do not move the downloaded file to the directory you intend to place
databases. You will have a mess of files on your hands when you create your first
database.

At the time this book was written, the version of Db2 that was available was version
11.5.4. Older free versions of Db2 are not made available when IBM introduces a new
version.

10
Chapter 2 Installing Db2

Now that you have your evaluation version of Db2, you are probably wondering what
its limitations are. The evaluation version does not ever expire. It has no limitation on
the number of databases. The one and only limitation is the total size of all databases,
currently limited to 100 GB. This is more than enough space to perform your own
evaluation of the software unless you are trying to test a very large system. If that is your
plan, IBM will be more than glad to help with a production version of Db2 and even
some engineers.
At this point, we are now ready to find out what our prerequisites are. To do this,
simply run the install program. This program is located in the untarred subdirectory
we previously created. The expanded directory is named server_dec. To run the install
program, just run the following commands:

$ cd server_dec
$ ./db2setup

If prerequisites are needed by Db2, the install program will list them and then exit.
Be sure to read everything output by the install program. On our CentOS 8.2 system, it
listed two prerequisites:

• libpam.so* (32-bit)

• libstdc++.so.6 (32-bit)

“Wait. Why does Db2 need 32-bit libraries?” you ask. Db2 is a collection of a bunch
of products, some of which have not changed in a decade or more. Rather than possibly
introducing new bugs into the system, IBM has chosen to keep the older version of
some of these products. Thus, these prerequisite libraries are needed to support those
products.
Use your system’s software installer to install the prerequisite packages. For Linux,
this will be either the dnf or yum programs for RPM-based packages. Once you have the
prerequisites installed, you are ready to proceed to really installing Db2. But before we
do that, we need to do a little planning.

Planning the Db2 Install


Before we get to the install, we need to understand what the result of the install will be so
we can plan ahead and avoid surprises afterward. There are two major points to cover in
this area.

11
Chapter 2 Installing Db2

The first result of the install is that you will have two new userids created on the
target machine. The default names of these IDs are db2inst1 and db2fenc1. The
db2inst1 ID will have some files stored in its home directory, and you need to make
sure there is enough space to accommodate them. There are a limited number of files,
but you should make sure you are prepared for them. The db2fenc1 ID only has a very
limited number of files stored in its home directory.
The second result is not really a result of the install. It is more a default that is set
as a result of the install. This item is the location where databases will be installed. The
default location for databases is in the db2inst1 home directory! THIS IS NOT WHERE
YOU WANT TO STORE DATABASES! You are probably going to store them on a different
drive/location. We will discuss this point again after we cover the install process and
before we create the sample database.
There are also a few minor points that are a result of the install, but we will cover
those as we get to them.

I nstalling Db2
We are now ready to install Db2. This process must be done by the root (on Linux)
or admin (on Windows) user, so start by becoming the root/admin user. On Windows
you will need to log out and log back in as the admin user. On Linux just perform the
following command:

$ su - root

After this you need to change to the directory where you placed the expanded files of
the Db2 download package. Then run the db2setup install package:

$ cd server_dec
$ ./db2setup

If you have installed all the prerequisites, this should show you the Welcome page
(Figure 2-1).

12
Chapter 2 Installing Db2

Figure 2-1. Db2 Install Welcome Page


After you click the New Install button, the next window appears to allow you to select
a product to install (Figure 2-2).

Figure 2-2. Db2 Install Choose a Product Page


13
Chapter 2 Installing Db2

This page has a number of products that you can select. The first product is Db2
Server, and this is the product we will install. The second product is Db2 with pureScale,
which we did not download. The third product is Db2 Connect Server, which is used
for distributed databases. The fourth product is Db2 Connect Client, which is used for
building compiled code that includes SQL statements. The last product is Db2 Runtime
Client, which is used for running compiled code from the Db2 Connect Client version.
At this point you should select the top item in the list, Db2 Server Editions. The
version number may be different if you downloaded a newer version of Db2. The other
selections are not important at this point in time. After clicking the Next button, the next
page will appear.

Figure 2-3. Db2 Install Configuration Page

14
Chapter 2 Installing Db2

The Configuration page allows you to select either a Typical or a Custom install. At
this point, select a Typical install. You must also check the box to agree to the IBM terms
before you proceed. When finished, click the Next button and the next page shown in
Figure 2-4 will appear.

Figure 2-4. Db2 Install Instance Owner Page

You can check out the Custom install option for some items you may want to change.
Most users just perform a Typical install.
The Instance Owner page allows you to create the account that will own the first
instance of Db2 and the group name of the new user. Just leave the db2inst1 information
as it appears and then enter the password and confirmation for the new account. This
is the account that will have new files installed in its home directory. When you have
entered in the new password and confirmed it for the account, click Next and the page
shown in Figure 2-5 will be displayed.

15
Chapter 2 Installing Db2

Figure 2-5. Db2 Install Fenced User Page

The db2fenc1 user will run user-defined functions and stored procedures outside the
address space of the Db2 database. Enter the db2fenc1 password and confirm it. When
finished, click Next which will dosplay the page in Figure 2-6.

16
Chapter 2 Installing Db2

Figure 2-6. Db2 Install Response File and Summary Page

The next page is the Response File and Summary page. The response file is a part of
the installation set of files, so it does not have to be created. Click the Finish button to
start the install of Db2 as shown in Figure 2-7.

17
Random documents with unrelated
content Scribd suggests to you:
{414}
The aggressor in the war between Chile and Peru was inspired
by the most purely selfish motives, and it remains to be seen
whether the just gods will not win in the long run, even
though the game of their antagonists be played with heavily
plated iron-clads. ... At the date last mentioned Chile was
suffering, like many other nations, from a general depression
in business pursuits. Its people were in no serious trouble,
but as a government it was in a bad way. ... The means to keep
up a sinking fund for the foreign debt had failed, and the
Chilean five per cents were quoted in London at sixty-four. 'A
political cloud also was darkening again in the north, in the
renewal of something like a confederation between Peru and
Bolivia.' In this state of things the governing oligarchy of
Chile decided, rather suddenly, Mr. Browne thinks, upon a
scheme which was sure to result either in splendid prosperity
or absolute ruin, and which contemplated nothing less than a
war of conquest against Peru and Bolivia, with a view to
seizing the most valuable territory of the former country.
There is a certain strip of land bordering upon the Pacific
and about 400 miles long, of which the northern three quarters
belonged to Peru and Bolivia, the remaining one quarter to
Chile. Upon this land a heavy rain never falls, and often
years pass in which the soil does not feel a shower. ... Its
money value is immense. 'From this region the world derives
almost its whole supply of nitrates--chiefly saltpetre--and
of iodine;' its mountains, also, are rich in metals, and great
deposits of guano are found in the highlands bordering the
sea. The nitrate-bearing country is a plain, from fifty to
eighty miles wide, the nitrate lying in layers just below a
thin sheet of impacted stones, gravel, and sand. The export of
saltpetre from this region was valued in 1882 at nearly
$30,000,000, and the worth of the Peruvian section, which is
much the largest and most productive, is estimated, for
government purposes, at a capital of $600,000,000. Chile was,
naturally, well aware of the wealth which lay so close to her
own doors, and to possess herself thereof, and thus to
rehabilitate her national fortunes, she addressed herself to
war. The occasion for war was easily found. Bolivia was first
attacked, a difficulty which arose at her port of Antofagasta,
with respect to her enforcement of a tax upon some nitrate
works carried on by a Chilean company, affording a good
pretext; and when Peru attempted intervention her envoy was
confronted with Chile's knowledge of a secret treaty between
Peru and Bolivia, and war was formally declared by Chile upon
Peru, April 5, 1879. This war lasted, with some breathing
spaces, for almost exactly five years. At the outset the two
belligerent powers--Bolivia being soon practically out of the
contest--seemed to be about equal in ships, soldiers, and
resources; but the supremacy which Chile soon gained upon the
seas substantially determined the war in her favor. Each
nation owned two powerful iron-clads, and six months were
employed in settling the question of naval superiority. ... On
the 21st of May, 1879, the Peruvian fleet attacked and almost
destroyed the Chilean wooden frigates which were blockading
Iquique; but in chasing a Chilean corvette the larger Peruvian
iron-clad--the Independencia--ran too near the shore, and was
fatally wrecked. 'So Peru lost one of her knights. The game
she played with the other--the Huascar--was admirable, but a
losing one;' and on the 8th of October of the same year the
Huascar was attacked by the Chilean fleet, which included two
iron-clads, and was finally captured' after a desperate
resistance.'... From this moment the Peruvian coast was at
Chile's mercy: the Chilean arms prevailed in every pitched
battle, at San Francisco [November 16, 1879], at Tacna [May
26, 1880], at Arica [June 7, 1880]; and finally, on the 17th
of January, 1881, after a series of actions which resembled in
some of their details the engagements that preceded our
capture of the city of Mexico [ending in what is known as the
Battle of Miraflores], the victorious army of Chile took
possession of Lima, the capital of Peru. ... The results of
the war have thus far exceeded the wildest hopes of Chile. She
has taken absolute possession of the whole nitrate region, has
cut Bolivia off from the sea, and achieved the permanent
dissolution of the Peru-Bolivian confederation. As a
consequence, her foreign trade has doubled, the revenue of her
government has been trebled, and the public debt greatly
reduced. The Chilean bonds, which were sold at 64 in London in
January, 1879, and fell to 60 in March of that year, at the
announcement of the war, were quoted at 95 in January, 1884."

The Growing Power of the Republic of Chile (Atlantic


Monthly, July, 1884).

ALSO IN:
H. Birkedal, The late War in South America (Overland Monthly,
January, February, and March, 1884).

C. R. Markham, The War between Peru and Chile.

R. N. Boyd, Chile, chapter 16-17.

Message of the President of the U. S., transmitting Papers


relating to the War in South America, January 26, 1882.

T. W. Knox, Decisive Battles since Waterloo; chapter 23.

See, also, PERU: A. D. 1826-1876.

CHILE: A. D. 1885-1891.
The presidency and dictatorship of Balmaceda.
His conflict with the Congress.
Civil war.

"Save in the one struggle in which the parties resorted to


arms, the political development of Chili was free from civil
disturbances, and the ruling class was distinguished among the
Spanish-American nations not only for wealth and education,
but for its talent for government and love of constitutional
liberty. The republic was called 'the England of South
America,' and it was a common boast that in Chili a
pronunciamiento or a revolution was impossible. The spirit of
modern Liberalism became more prevalent, ... As the Liberal
party became all-powerful it split into factions, divided by
questions of principle and by struggles for leadership and
office. ... The patronage of the Chilian President is
enormous, embracing not only the general civil service, but
local officials, except in the municipalities, and all
appointments in the army and navy and in the telegraph and
railroad services and the giving out of contracts. The
President has always been able to select his successor, and
has exercised this power, usually in harmony with the wishes
of influential statesmen, sometimes calling a conference of
party chiefs to decide on a candidate. In the course of time
the more advanced wing of the Liberals grew more numerous than
the Moderates. The most radical section had its nucleus in a
Reform Club in Santiago, composed of young university men, of
whom Balmaceda was the finest orator. Entering Congress in
1868, he took a leading part in debates. ...
{415}
In 1885 he was the most popular man in the country; but his
claim to the presidential succession was contested by various
other aspirants--older politicians and leaders of factions
striving for supremacy in Congress. He was elected by an
overwhelming majority, and as President enjoyed an unexampled
degree of popularity. For two or three years the politicians
who had been his party associates worked in harmony with his
ideas. ... At the flood of the democratic tide he was the most
popular man in South America. But when the old territorial
families saw the seats in Congress and the posts in the civil
service that had been their prerogative filled by new men, and
fortunes made by upstarts where all chances had been at their
disposal, then a reaction set in, corruption was scented, and
Moderate Liberals, joining hands with the Nationalists and the
reviving Conservative party, formed an opposition of
respectable strength. In the earlier part of his
administration Balmaceda had the co-operation of the
Nationalists, who were represented in the Cabinet. In the last
two years of his term, when the time drew near for selecting
his successor, defection and revolt and the rivalries of
aspirants for the succession threw the party into disorder and
angered its hitherto unquestioned leader. ... In January,
1890, the Opposition were strong enough to place their
candidate in the chair when the House of Representatives
organized. The ministry resigned, and a conflict between the
Executive and legislative branches of the Government was
openly begun when the President appointed a Cabinet of his own
selection. ... This ministry had to face an overwhelming
majority against the President, which treated him as a
dictator and began to pass hostile laws and resolutions that
were vetoed, and refused to consider the measures that he
recommended. The ministers were cited before the Chambers and
questioned about the manner of their appointment. They either
declined to answer, or answered in a way that increased the
animosity of Congress, which finally passed a vote of censure,
in obedience to which, as was usual, the Cabinet resigned.
Then Balmaceda appointed a ministry in open defiance of
Congress, with Sanfuentes at its head, the man who was already
spoken of as his selected candidate for the presidency. He
prepared for the struggle that he invited by removing the
chiefs of the administration of the departments and replacing
them with men devoted to himself and his policy, and making
changes in the police, the militia, and, to some extent, in
the army and navy commands. The press denounced him as a
dictator, and indignation meetings were held in every town.
Balmaceda and his supporters pretended to be not only the
champions of the people against the aristocracy, but of the
principle of Chili for the Chilians."

Appleton's Annual Cyclop., 1891, pages 123-124.

"The conflict between President Balmaceda and Congress ripened


into revolution. On January 1, 1891, the Opposition members of
the Senate and House of Deputies met, and signed an Act
declaring that the President was unworthy of his post, and
that he was no longer head of the State nor President of the
Republic, as he had violated the Constitution. On January 7
the navy declared in favour of the Legislature, and against
Balmaceda. The President denounced the navy as traitors,
abolished all the laws of the country, declared himself
Dictator, and proclaimed martial law. It was a reign of
terror. The Opposition recruited an army in the Island of
Santa Maria under General Urrutia and Commander Canto. On
February 14 a severe fight took place with the Government
troops in Iquique, and the Congressional army took possession
of Pisagua. In April, President Balmaceda ... delivered a long
message, denouncing the navy. ... The contest continued, and
April 7, Arica, in the province of Tarapaca, was taken by the
revolutionists. Some naval fights occurred later, and the
iron-clad Blanco Encalada was blown up by the Dictator's
torpedo cruisers. Finally, on August 21, General Canto landed
at Concon, ten miles north of Valparaiso. Balmaceda's forces
attacked immediately and were routed, losing 3,500 killed and
wounded. The Congress army lost 600. On the 28th a decisive
battle was fought at Placilla, near Valparaiso. The Dictator
had 12,000 troops, and the opposing army 10,000. Balmaceda's
forces were completely routed after five hours' hard fighting,
with a loss of 1,500 men. Santiago formally surrendered, and
the triumph of the Congress party was complete. A Junta,
headed by Señor Jorge Montt, took charge of affairs at
Valparaiso August 30. Balmaceda, who had taken refuge at the
Argentine Legation in Santiago, was not able to make his
escape, and to avoid capture, trial, and punishment, committed
suicide, September 20, by shooting himself. On the 19th
November Admiral Jorge Montt was chosen by the Electoral
College, at Santiago, President of Chili, and on December 26
he was installed with great ceremony and general rejoicings."

Annual Register, 1891, page 420.

CHILIARCHS.
Captains of thousands, in the army of the Vandals.

T. Hodgkin, Italy and her Invaders, book 3, chapter 2.

CHILLIANWALLAH, Battle of (1849).

See INDIA: A. D. 1845-1849.

CHILPERIC I.,

King of the Franks (Neustria), A. D. 561-584.

Chilperic II., King of the Franks, A. D. 715-720.

CHILTERN HUNDREDS,
Applying for the Stewardship of the.

A seat in the British House of Commons "cannot be resigned,


nor can a man who has once formally taken his seat for one
constituency throw it up and contest another. Either a
disqualification must be incurred, or the House must declare
the seat vacant." The necessary disqualification can be
incurred by accepting an office of profit under the
Crown,--within certain official categories. "Certain old
offices of nominal value in the gift of the Treasury are now
granted, as of course, to members who wish to resign their
seats in order to be quit of Parliamentary duties or to
contest another constituency. These offices are the
Stewardship of the Chiltern Hundreds [Crown property in
Buckinghamshire], of the manors of East Hendred, Northstead,
or Hempholme, and the escheatorship of Munster. The office is
resigned as soon as it has operated to vacate the seat and
sever the tie between the member and his constituents."

Sir W. R. Anson, Law and Custom of the Const.,


volume 1, page 84.
CHIMAKUAN FAMILY, The.

See AMERICAN ABORIGINES: CHIMAKUAN FAMILY.

CHIMARIKAN FAMILY, The.

See AMERICAN ABORIGINES: CHIMARIKAN FAMILY.

{416}

CHINA:
The names of the Country.

"That spacious seat of ancient civilization which we call


China has loomed always so large to western eyes, ... that, at
eras far apart, we find it to have been distinguished by
different appellations according as it was regarded as the
terminus of a southern sea-route coasting the great peninsulas
and islands of Asia, or as that of a northern land route
traversing the longitude of that continent. In the former
aspect the name applied has nearly always been some form of
the name Sin, Chin, Sinæ, China. In the latter point of view
the region in question was known to the ancients as the land
of the Seres; the middle ages as the Empire of Cathay. The
name of China has been supposed, like many another word and
name connected with trade and geography of the far east, to
have come to us through the Malays, and to have been applied
by them to the great eastern monarchy from the style of the
dynasty of Thsin, which a little more than two centuries
before our era enjoyed a brief but very vigorous existence.
... There are reasons however for believing that the name of
China must have been bestowed at a much earlier date, for it
occurs in the laws of Manu, which assert the Chinas to have
been degenerate Kshatryas, and in the Mahabharat, compositions
many centuries older than the imperial dynasty of Thsin. ...
This name may have yet possibly been connected with the Thsin,
or some monarchy of like dynastic title; for that dynasty had
reigned locally in Shensi from the 9th century before our era;
and when, at a still earlier date, the empire was partitioned
into many small kingdoms, we find among them the dynasties of
the Tcin and the Ching. ... Some at least of the circumstances
which have been collected ... render it the less improbable that
the Sinim of the prophet Isaiah ... should be truly
interpreted as indicating the Chinese. The name of China in
this form was late in reaching the Greeks and Romans, and to
them it probably came through people of Arabian speech, as the
Arabs, being without the sound of 'ch,' made the China of the
Hindus and Malays into Sin, and perhaps sometimes into Thin.
Hence the Thin of the author of the Periplus of the Erythraean
Sea, who appears to be the first extant author to employ the
name in this form; hence also the Sinæ and Thinæ of Ptolemy.
.. . . If we now turn to the Seres we find this name mentioned
by classic authors much more frequently and at an earlier date
by at least a century. The name is familiar enough to the
Latin poets of the Augustan age, but always in a vague way.
... The name of Seres is probably from its earliest use in the
west identified with the name of the silkworm and its produce,
and this association continued until the name ceased entirely
to be used as a geographical expression. ... It was in the
days of the Mongols ... that China first became really known
to Europe, and that by a name which, though especially applied
to the northern provinces, also came to bear a more general
application, Cathay. This name, Khitai, is that by which China
is styled to this day by all, or nearly all, the nations which
know it from an inland point of view, including the Russians,
the Persians, and the nations of Turkestan; and yet it
originally belonged to a people who were not Chinese at all.
The Khitans were a people of Manchu race, who inhabited for
centuries a country to the north-east of China." During a
period between the 10th and 12th centuries, the Khitans
acquired supremacy over their neighbours and established an
empire which embraced Northern China and the adjoining regions
of Tartary. "It must have been during this period, ending with
the overthrow of the dynasty [called the Leao or Iron Dynasty]
in 1123, and whilst this northern monarchy was the face which
the Celestial Empire turned to Inner Asia, that the name of
Khitan, Khitat, or Khitaï, became indissolubly associated with
China."
H. Yule, Cathay and the Way Thither: Preliminary
Essay.

CHINA:
The Origin of the People and their early History.

"The origin of the Chinese race is shrouded in some obscurity.


The first records we have of them represent them as a band of
immigrants settling in the north-eastern provinces of the
modern empire of China, and fight their way amongst the
aborigines, much as the Jews of old forced their way into
Canaan against the various tribes which they found in
possession of the land. It is probable that though they all
entered China by the same route, they separated into bands
almost on the threshold of the empire, one body, those who
have left us the records of their history in the ancient
Chinese books, apparently followed the course of the Yellow
River, and, turning south-ward with it from its northernmost
bend, settled themselves in the fertile districts of the
modern provinces of Shansi and Honan. But as we find also that
at about the same period a large settlement was made as far
south as Annam, of which there is no mention in the books of
the northern Chinese, we must assume that another body struck
directly southward through the southern provinces of China to
that country. The question then arises, where did these people
come from? and the answer which recent research [see BABYLONIA
PRIMITIVE] gives to this question is, from the south of the
Caspian Sea. ... In all probability, the outbreak in Susiana
of, possibly, some political disturbance, in about the 24th or
23rd century B. C., drove the Chinese from the land of their
adoption, and that they wandered eastward until they finally
settled in China and the countries south of it. ... It would
appear also that the Chinese came into China possessed of the
resources of Western Asian culture. They brought with them a
knowledge of writing and astronomy, as well as of the arts
which primarily minister to the wants and comfort of mankind.
The invention of these civilising influences is traditionally
attributed to the Emperor Hwang-te, who is said to have
reigned from B. C. 2697-2597. But the name of this sovereign
leads us to suppose that he never sat on the throne in China.
One of his names, we are told, was Nai, anciently Nak, and in
the Chinese paleographical collection he is described by a
character composed of a group of phonetics which read
Nak-kon-ti. The resemblance between this name and that of
Nak-hunte, who, according to the Susian texts, was the chief
of the gods, is sufficiently striking, and many of the
attributes belonging to him are such as to place him on an
equality with the Susian deity.
{417}
In exact accordance also with the system of Babylonian
chronology he established a cycle of twelve years, and fixed
the length of the year at 360 days composed of twelve months,
with an intercalary month to balance the surplus time. He
further, we are told, built a Ling tai, or observatory,
reminding us of the Babylonian Zigguratu, or house of
observation, 'from which to watch the movements of the
heavenly bodies.' The primitive Chinese, like the Babylonians,
recognised five planets besides the sun and moon, and, with
one exception, knew them by the same names. ... The various
phases of these planets were carefully watched, and portents
were derived from every real and imaginary change in their
relative positions and colours. A comparison between the
astrological tablets translated by Professor Sayce and the
astrological chapter (27th) in the She ke, the earliest of the
Dynastic Histories, shows a remarkable parallelism, not only
in the general style of the forecasts, but in particular
portents which are so contrary to Chinese prejudices, as a
nation, and the train of thought of the people that they would
be at once put down as of foreign origin, even if they were
not found in the Babylonian records. ... In the reign of Chwan
Hu (2513-2435 B. C.), we find according to the Chinese
records, that the year, as among the Chaldeans, began with the
third month of the solar year, and a comparison between the
ancient names of the months given in the Urh ya, the oldest
Chinese dictionary, with the Accadian equivalents, shows, in
some instances, an exact identity. ... These parallelisms,
together with a host of others which might be produced, all
point to the existence of an early relationship between
Chinese and Mesopotamian culture; and, armed with the
advantages thus possessed, the Chinese entered into the empire
over which they were ultimately to overspread themselves. But
they came among tribes who, though somewhat inferior to them
in general civilisation, were by no means destitute of
culture. ... Among such people, and others of a lower
civilisation, such as the Jungs of the west and the Teks, the
ancestors of the Tekke Turcomans, in the north, the Chinese
succeeded in establishing themselves. The Emperor Yaou
(2356-2255 B. C.) divided his kingdom into twelve portions,
presided over by as many Pastors, in exact imitation of the
duodenary feudal system of Susa with their twelve Pastor
Princes. To Yaou succeeded Shun, who carried on the work of
his predecessor of consolidating the Chinese power with energy
and success. In his reign the first mention is made of
religious worship. ... In Shun's reign occurred the great
flood which inundated most of the provinces of the existing
empire. The waters, we are told, rose to so great a height,
that the people had to betake themselves to the mountains to
escape death. The disaster arose, as many similar disasters,
though of a less magnitude, have since arisen, in consequence
of the Yellow River bursting its bounds, and the 'Great Yu'
was appointed to lead the waters back to their channel. With
unremitting energy he set about his task, and in nine years
succeeded in bringing the river under control. ... As a reward
for the services he had rendered to the empire, he was
invested with the principality of Hea, and after having
occupied the throne conjointly with Shun for some years, he
succeeded that sovereign on his death, in 2208 B. C. With Yu
began the dynasty of Hea, which gave place, in 1766 B. C., to
the Shang Dynasty. The last sovereign of the Hea line, Kieh
kwei, is said to have been a monster of iniquity, and to have
suffered the just punishment for his crimes at the hands of
T'ang, the prince of the State of Shang, who took his throne
from him. In like manner, 640 years later, Woo Wang, the
prince of Chow, overthrew Chow Sin, the last of the Shang
Dynasty, and established himself as the chief of the sovereign
state of the empire. By empire it must not be supposed that
the empire, as it exists at present, is meant. The China of
the Chow Dynasty lay between the 33rd and 38th parallels of
latitude, and the 106th and 119th of longitude only, and
extended over no more than portions of the provinces of Pih
chih-li, Shanse, Shense, Honan, Keang-se, and Shan-tung. This
territory was re-arranged by Woo Wang into the nine
principalities established by Yu. ... Woo is held up in
Chinese history as one of the model monarchs of antiquity. ...
Under the next ruler, K'ang (B. C. 1078-1053), the empire was
consolidated, and the feudal princes one and all acknowledged
their allegiance to the ruling house of Chow. ... From all
accounts there speedily occurred a marked degeneracy in the
characters of the Chow kings. ... Already a spirit of
lawlessness was spreading far and wide among the princes and
nobles, and wars and rumours of wars were creating misery and
unrest throughout the country. ... The hand of every man was
against his neighbour, and a constant state of internecine war
succeeded the peace and prosperity which had existed under the
rule of Woo-wang. ... As time went on and the disorder
increased, supernatural signs added their testimony to the
impending crisis. The brazen vessels upon which Yu had
engraved the nine divisions of the empire were observed to
shake and totter as though foreshadowing the approaching
change in the political position. Meanwhile Ts'in on the
northwest, Ts'oo on the south, and Tsin on the north, having
vanquished all the other states, engaged in the final struggle
for the mastery over the confederate principalities. The
ultimate victory rested with the state of Ts'in, and in 255 B.
C., Chaou-seang Wang became the acknowledged ruler over the
'black-haired' people. Only four years were given him to reign
supreme, and at the end of that time he was succeeded by his
son, Heaou-wan Wang, who died almost immediately on ascending
the throne. To him succeeded Chwang-seang Wang, who was
followed in 246 B. C. by Che Hwang-te, the first Emperor of
China. The abolition of feudalism, which was the first act of
Che Hwang-to raised much discontent among those to whom the
feudal system had brought power and emoluments, and the
countenance which had been given to the system by Confucius
and Mencius made it desirable--so thought the emperor--to
demolish once for all their testimony in favour of that
condition of affairs, which he had decreed should be among the
things of the past. With this object he ordered that the whole
existing literature, with the exception of books on medicine,
agriculture, and divination should be burned. The decree was
obeyed as faithfully as was possible in the case of so
sweeping an ordinance, and for many years a night of ignorance
rested on the country. The construction of one gigantic
work--the Great Wall of China--has made the name of this
monarch as famous as the destruction of the books has made it
infamous.
{418}
Finding the Heung-nu Tartars were making dangerous inroads
into the empire, he determined with characteristic
thoroughness to build a huge barrier which should protect the
northern frontier of the empire through all time. In 214 B. C.
the work was begun under his personal supervision, and though
every endeavor was made to hasten its completion he died (209)
leaving it unfinished. His death was the signal for an
outbreak among the dispossessed feudal princes, who, however,
after some years of disorder, were again reduced to the rank
of citizens by a successful leader, who adopted the title of
Kaou-te, and named his dynasty that of Han (206). From that
day to this, with occasional interregnums, the empire has been
ruled on the lines laid down by Che Hwang-te. Dynasty has
succeeded dynasty, but the political tradition has remained
unchanged, and though Mongols and Manchoos have at different
times wrested the throne from its legitimate heirs, they have
been engulfed in the homogeneous mass inhabiting the empire,
and instead of impressing their seal on the country have
become but the reflection of the vanquished. The dynasties
from the beginning of the earlier Han, founded, as stated
above, by Kaou-te, are as follows:

The earlier Han Dynasty B. C. 206-A. D. 25;


the late Han A. D. 25-220;
the Wei 220-280;
the western Tsin 265-317;
the eastern Tsin 317-420;
the Sung 420-479;
the Ts'e 479-502;
the Leang 502-557;
the Ch'in 557-589.
Simultaneously with these--
the northern Wei A. D. 386-534;
the western Wei 535-557;
the eastern Wei 534-550;
the northern Ts'e 550-577;
the northern Chow 557-589.
The Suy 589-618;
the T'ang 618-907;
the later Leang 907-923;
the later T'ang 923-936;
the later Tsin 936-947;
the later Han 947-951;
the later Chow 951-960,
the Sung 960-1127;
the southern Sung 1127-1280;
the Yuen 1280-1368;
the Ming 1368-1614;
the Ts'ing 1644.
Simultaneously with some of these--
the Leaou 907-1125;
the western Leaou 1125-1168;
the Kin 1115-1280.
R. K. Douglas, China, chapter 1.

ALSO IN
D.C. Boulger, History of China, volume 1-2.

CHINA:
The Religions of the People.
Confucianism.
Taouism.
Buddhism.

"The Chinese describe themselves as possessing three


religions, or more accurately, three sects, namely Joo keaou,
the sect of Scholars; Fuh keaou, the sect of Buddha; and Taou
keaou, the sect of Taou. Both as regards age and origin, the
sect of Scholars, or, as it is generally called, Confucianism,
represents pre-eminently the religion of China. It has its root
in the worship of Shang-te, a deity which is associated with
the earliest traditions of the Chinese race. Hwang-te (2697 B.
C.) erected a temple to his honour, and succeeding emperors
worshipped before his shrine. ... During the troublous times
which followed after the reign of the few first sovereigns of
the Chow Dynasty, the belief in a personal deity grew
indistinct and dim, until, when Confucius [born B. C. 551]
began his career, there appeared nothing strange in his
atheistic doctrines. He never in any way denied the existence
of Shang-te, but he ignored him. His concern was with man as a
member of society, and the object of his teaching was to lead
him into those paths of rectitude which might best contribute
to his own happiness, and to the well-being of that community
of which he formed part. Man, he held, was born good, and was
endowed with qualities which, when cultivated and improved by
watchfulness and self-restraint, might enable him to acquire
godlike wisdom and to become 'the equal of Heaven.' He divided
mankind into four classes, viz., those who are born with the
possession of knowledge; those who learn, and so readily get
possession of knowledge; those who are dull and stupid, and
yet succeed in learning; and, lastly, those who are dull and
stupid, and yet do not learn. To all these, except those of
the last class, the path to the climax reached by the 'Sage'
is open. Man has only to watch, listen to, understand, and
obey the moral sense implanted in him by Heaven, and the
highest perfection is within his reach. ... In this system
there is no place for a personal God. The impersonal Heaven,
according to Confucius, implants a pure nature in every being
at his birth, but, having done this, there is no further
supernatural interference with the thoughts and deeds of men.
It is in the power of each one to perfect his nature, and
there is no divine influence to restrain those who take the
downward course. Man has his destiny in his own hands, to make
or to mar. Neither had Confucius any inducement to offer to
encourage men in the practice of virtue, except virtue's self.
He was a matter-of-fact, unimaginative man, who was quite
content to occupy himself with the study of his fellow-men,
and was disinclined to grope into the future or to peer
upwards. No wonder that his system, as he enunciated it,
proved a failure. Eagerly he sought in the execution of his
official duties to effect the regeneration of the empire, but
beyond the circle of his personal disciples he found few
followers, and as soon as princes and statesmen had satisfied
their curiosity about him they turned their backs on his
precepts and would [have] none of his reproofs. Succeeding
ages, recognising the loftiness of his aims, eliminated all
that was impracticable and unreal in his system, and held fast
to that part of it that was true and good. They were content
to accept the logic of events, and to throw overboard the
ideal 'sage,' and to ignore the supposed potency of his
influence; but they clung to the doctrines of filial piety,
brotherly love, and virtuous living. It was admiration for the
emphasis which he laid on these and other virtues which has
drawn so many millions of men unto him; which has made his
tomb at Keo-foo heen to be the Mecca of Confucianism, and has
adorned every city of the empire with temples built in his
honour. ... Concurrently with the lapse of pure Confucianism,
and the adoption of those principles which find their earliest
expression in the pre-Confucian classics of China, there is
observable a return to the worship of Shang-te. The most
magnificent temple in the empire is the Temple of Heaven at
Peking, where the highest object of Chinese worship is adored
with the purest rites. ... What is popularly known in Europe
as Confucianism is, therefore, Confucianism with the
distinctive opinions of Confucius omitted. ... But this
worship of Shang-te is confined only to the emperor. The
people have no lot or heritage in the sacred acts of worship
at the Altar of Heaven. ... Side by side with the revival of
the Joo keaou, under the influence of Confucius, grew up a
system of a totally different nature, and which, when divested
of its esoteric doctrines, and reduced by the
practically-minded Chinamen to a code of morals, was destined
in future ages to become affiliated with the teachings of the Sage.
{419}
This was Taouism, which was founded by Laou-tsze, who was a
contemporary of Confucius. An air of mystery hangs over the
history of Laou-tsze. Of his parentage we know nothing, and
the historians, in their anxiety to conceal their ignorance of
his earlier years, shelter themselves behind the legend that
he was born an old man. ... The primary meaning of Taou is
'The way,' 'The path,' but in Laou-tsze's philosophy it was
more than the way, it was the way-goer as well. It was an
eternal road; along it all beings and things walked; it was
everything and nothing, and the cause and effect of all. All
things originated from Taou, conformed to Taou, and to Taou at
last returned. ... 'If, then, we had to express the meaning of
Taou, we should describe it as the Absolute; the totality of
Being and Things; the phenomenal world and its order; and the
ethical nature of the good man, 'and the principle of his
action.' It was absorption into this 'Mother of all things'
that Laou-tsze aimed at. And this end was to be attained to by
self-emptiness, and by giving free scope to the uncontaminated
nature which, like Confucius, he taught was given by Heaven to
all men. ... But these subtleties, like the more abstruse
speculations of Confucius, were suited only to the taste of
the schools. To the common people they were foolishness, and,
before long, the philosophical doctrine of Laou-tsze of the
identity of existence and non-existence, assumed in their eyes
a warrant for the old Epicurean motto, 'Let us eat and drink,
for to-morrow we die.' The pleasures of sense were substituted
for the delights of virtue, and the next step was to desire
prolongation of the time when those pleasures could be
enjoyed. Legend said that Laou-tsze had secured to himself
immunity from death by drinking the elixir of immortality, and
to enjoy the same 'privilege became the all-absorbing object
of his followers. The demand for elixirs and charms produced a
supply, and Taouism quickly degenerated into a system of
magic. ... The teachings of Laou-tsze having familiarised the
Chinese mind with philosophical doctrines, which, whatever
were their direct source, bore a marked resemblance to the
musings of Indian sages, served to prepare the way for the
introduction of Buddhism. The exact date at which the Chinese
first became acquainted with the doctrines of Buddha was,
according to an author quoted in K'ang-he's Imperial
Encyclopædia, the thirtieth year of the reign of She Hwang-te,
i. e., B. C. 216. The story this writer tells of the
difficulties which the first missionaries encountered is
curious, and singularly suggestive of the narrative of St.
Peter's imprisonment."

R. K. Douglas, China, chapter 17.

ALSO IN:
R. K. Douglas, Confucianism and Taouism.

"Buddhism ... penetrated to China along the fixed route from


India to that country, round the north-west corner of the
Himalayas and across Eastern Turkestan. Already in the 2nd
year B. C., an embassy, perhaps sent by Huvishka [who reigned
in Kabul and Kashmere] took Buddhist books to the then Emperor
of China, A-ili; and the Emperor Ming-ti, 62 A. D., guided by
a dream, is said to have sent to Tartary and Central India and
brought Buddhist books to China. From this time Buddhism
rapidly spread there. ... In the fourth century Buddhism
became the state religion."

T. W. Rhys Davids, Buddhism, chapter 9.

ALSO IN
J. Legge, The Religions of China.

J. Edkins, Religion in China.

J. Edkins, Chinese Buddhism.

S. Beals, Buddhism in China.

S. Johnson, Oriental Religions: China.

CHINA: A. D. 1205-1234.
Conquest by Jingis Khan and his son.

"The conquest of China was commenced by Chinghiz [or Jingis


Khan], although it was not completed for several generations.
Already in 1205 he had invaded Tangut, a kingdom occupying the
extreme northwest of China, and extending beyond Chinese
limits in the same direction, held by a dynasty of Tibetan
race, which was or had been a vassal to the Kin. This invasion
was repeated in succeeding years; and in 1211 his attacks
extended to the Empire of the Kin itself. In 1214 he ravaged
their provinces to the Yellow River, and in the following year
took Chungtu or Peking. In 1219 he turned his arms against
Western Asia; ... but a lieutenant whom he had left behind him
in the East continued to prosecute the subjection of Northern
China. Chinghiz himself on his return from his western
conquests renewed his attack on Tangut, and died on that
enterprise, 18th August. Okkodai, the son and successor of
Chinghiz, followed up the subjugation of China, extinguished
the Kin finally in 1234 and consolidated with his Empire all
the provinces north of the Great Kiang. The Southern provinces
remained for the present subject to the Chinese dynasty of the
Sung, reigning now at Kingssé or Hangcheu. This kingdom was
known to the Tartars as Nangkiass, and also by the
quasi-Chinese title of Mangi or Manzi, made so famous by Marco
Polo and the travellers of the following age."

H. Yule, Cathay and the Way Thither.


Preliminary Essay, section 91-92.

See, also, MONGOLS: A. D. 1153-1227.

CHINA: A. D. 1259-1294.
The Empire of Kublai Khan.

Kublai, or Khubilai Khan, one of the grandsons of Jingis Khan,


who reigned as the Great Khan or Supreme lord of the Mongols
from 1259 until 1294, "was the sovereign of the largest empire
that was ever controlled by one man. China, Corea, Thibet,
Tung-King, Cochin China, a great portion of India beyond the
Ganges, the Turkish and Siberian realms from the Eastern Sea
to the Dnieper, obeyed his commands; and although the chief of
the Hordes of Jagatai and Ogatai refused to acknowledge him,
the Ilkhans of Persia ... were his feudatories. ... The
Supreme Khan had immediate authority only in Mongolia and
China. ... The capital of the Khakan, after the accession of
Khubilai, was a new city he built close to the ancient
metropolis of the Liao and Kin dynasties."

H. H. Howorth, History of the Mongols, volume 1,


pages 216-283.

"Khan-Bálig (Mong., 'The Khan's city'), the Cambalu of Marco,


Peking ... was captured by Chinghiz in 1215, and in 1264
Kublai made it his chief residence. In 1267 he built a new
city, three 'li' to the north-east of the old one, to which
was given the name of Ta-tu or 'Great Court,' called by the
Mongols Daïdu, the Taydo of Odoric and Taidu of Polo, who
gives a description of its dimensions, the number of its
gates, etc., similar to that in the text. The Chinese accounts
give only eleven gates. This city was abandoned as a royal
residence on the expulsion of the Mongol dynasty in 1368, but
re-occupied in 1421 by the third Ming Emperor, who built the
walls as they now exist, reducing their extent and the number
of the gates to nine. This is what is commonly called the
'Tartar city' of the present day (called also by the Chinese
Lau-Chhing or 'Old Town'), which therefore represents the
Taydo of Odoric."

H. Yule,
Cathay and the Way Thither, volume 1, page 127, footnote.

ALSO IN
Marco Polo, Travels, with Notes by Sir H. Yule, book 2.

See, also, MONGOLS: A. D. 1229-1294,


and POLO, MARCO.

{420}

CHINA: A. D. 1294-1882.
Dissolution of the Empire of Kublai Khan.
The Ming dynasty and its fall.
The enthronement of the present Manchu Tartar Dynasty, of the
Tsings or Ch'ings.
The appearance of the Portuguese and the Jesuit Missionaries.

"The immediate successors of Kublai, brought up in the


luxuries of the imperial palace, the most gorgeous at that
time in the world, relied upon the prestige with which the
glory of the late emperor invested them, and never dreamed
that change could touch a dominion so vast and so solid. Some
devoted themselves to elegant literature and the improvement
of the people; later princes to the mysteries of Buddhism,
which became, in some degree, the state religion; and as the
cycle went round, the dregs of the dynasty abandoned
themselves, as usual, to priests, women, and eunuchs. ... The
distant provinces threw off their subjection; robbers ravaged
the land, and pirates the sea; a minority and a famine came at
the same moment; and in less than ninety years after its
commencement, the fall of the dynasty was only illumined by
some few flashes of dying heroism, and every armed Tartar, who
could obtain a horse to aid his flight, spurred back to his
native deserts. Some of them, of the royal race, turning to
the west, took refuge with the Manchows, and in process of
time, marrying with the families of the chiefs, intermingled
the blood of the two great tribes. The proximate cause of this
catastrophe was a Chinese of low birth, who, in the midst of
the troubles of the time, found means to raise himself by his
genius from a servile station to the leadership of a body of
the malcontents, and thence to step into the imperial throne.
The new dynasty [the Ming] began their reign with great
brilliance. The emperor carried the Tartar war into their own
country, and at home made unrelenting war upon the abuses of
his palace. He committed the mistake, however, of granting
separate principalities to the members of his house, which in
the next reign caused a civil war, and the usurpation of the
throne by an uncle of the then emperor. The usurper found it
necessary to transfer the capital to Peking, as a post of
defence against the eastern Tartars, who now made their
appearance again on this eventful stage. He was successful,
however, in his wars in the desert, and he added Tonquin and
Cochin China to the Chinese dominions. After him the fortunes
of the dynasty began to wane. The government became weaker,
the Tartars stronger, some princes attached themselves to
literature, some to Buddhism or Taoism: Cochin China revolted,
and was lost to the empire, Japan ravaged the coasts with her
privateers; famine came to add to the horrors of misrule."

Leitch Ritchie, History of the Oriental Nations,


book 7, chapter 1 (volume 2).

"From without, the Mings were constantly harassed by the


encroachments of the Tartars; from within, the ceaseless
intriguing of the eunuchs (resulting in one case in the
temporary deposition of an Emperor) was a fertile cause of
trouble. Towards the close of the 16th century the Portuguese
appeared upon the scene, and from their 'concession' at Macao,
some time the residence of Camoens, opened commercial
relations between China and the West. They brought the
Chinese, among other things, opium, which had previously been
imported overland from India. They possibly taught them how to
make gunpowder, to the invention of which the Chinese do not
seem, upon striking a balance of evidence, to possess an
independent claim. About the same time [1580] Rome contributed
the first instalment of those wonderful Jesuit fathers, whose
names may truly be said to have filled the empire 'with sounds
that echo still,' the memory of their scientific labours and
the benefits they thus conferred upon China having long
survived the wreck and discredit of the faith to which they
devoted their lives. And at this distance of time it does not
appear to be a wild statement to assert that had the Jesuits,
the Franciscans, and the Dominicans, been able to resist
quarrelling among themselves, and had they rather united to
persuade Papal infallibility to permit the incorporation of
ancestor worship with the rites and ceremonies of the Romish
church--China would at this moment be a Catholic country, and
Buddhism, Taoism, and Confucianism would long since have
receded into the past. Of all these Jesuit missionaries, the
name of Matteo Ricci [who died in 1610] stands by common
consent first upon the long list. ... The overthrow of the
Mings [A. D. 1644], was brought about by a combination of
events, of the utmost importance to those who would understand
the present position of the Tartars as rulers of China. A
sudden rebellion had resulted in the capture of Peking by the
insurgents, and in the suicide of the Emperor who was fated to
be the last of his line. The Imperial Commander-in-chief, Wu
San-kuei, at that time away on the frontiers of Manchuria,
engaged in resisting the incursions of the Manchu Tartars, now
for a long time in a state of ferment, immediately hurried
back to the capital, but was totally defeated by the insurgent
leader, and once more made his way, this time as a fugitive
and a suppliant, towards the Tartar camp. Here he obtained
promises of assistance, chiefly on condition that he would
shave his head and grow a tail in accordance with Manchu
custom, and again set off with his new auxiliaries towards
Peking, being reinforced on the way by a body of Mongol
volunteers. As things turned out Wu San-kuei arrived at Peking
in advance of these allies, and actually succeeded, with the
remnant of his own scattered forces, in routing the troops of
the rebel leader before the Tartars and the Mongols came up.
He then started in pursuit of the flying foe. Meanwhile the
Tartar contingent arrived; and on entering the capital, the
young Manchu prince in command was invited by the people of
Peking to ascend the vacant throne. So that by the time Wu
San-kuei re-appeared he found a new dynasty [the Ch'ing or
Tsing dynasty of the present day] already established, and his
late Manchu ally at the head of affairs. His first intention
had doubtless been to continue the Ming line of Emperors; but
he seems to have readily fallen in with the arrangement
already made, and to have tendered his formal allegiance on
the four following conditions:

{421}

(1.) That no Chinese woman should be taken into the Imperial


seraglio.

(2.) That the first place at the great triennial examination


for the highest literary degrees should never be given to a
Tartar.

(3.) That the people should adopt the national costume of the
Tartars in their everyday life; but that they should be
allowed to bury their corpses in the dress of the late
dynasty.

(4.) That this condition of costume should not apply to the


women of China, who were not to be compelled either to wear
the hair in a tail before marriage (as the Tartar girls do) or
to abandon the custom of compressing' their feet.

The great Ming dynasty was now at an end, though not destined
wholly to pass away. A large part of it may be said to remain
in the literary monuments which were executed during its three
centuries of existence. The dress of the period survives upon
the modern Chinese stage; and when occasionally the present
alien yoke is found to gall, seditious whispers of
'restoration' are not altogether unheard. ... The age of the
Ch'ings is the age in which we live; but it is not so familiar
to some persons as it ought to be, that a Tartar, and not a
Chinese sovereign, is now seated upon the throne of China. For
some time after the accession of the first Manchu Emperor
there was considerable friction between the two races, due,
among other natural causes, to the enforced adoption of the
peculiar coiffure in vogue among the Manchus--i. e., the tail,
or plaited queue of hair, which now hangs down every
Chinaman's back. This fashion was for a long time vigorously
resisted by the inhabitants of southern China, though now
regarded by all alike as one of the most sacred
characteristics of the 'black-haired people.' ... The
subjugation of the empire by the Manchus was followed by a
military occupation of the country, which has survived the
original necessity, and is part of the system of government at
the present day. Garrisons of Tartar troops were stationed at
various important centres of population. ... Those Tartar
garrisons still occupy the same positions; and the descendants
of the first battalions, with occasional reinforcements from
Peking, live side by side and in perfect harmony with the
strictly Chinese populations. These Bannermen, as they are
called, may be known by their square, heavy faces, which
contrast strongly with the sharper and more astute
physiognomies of the Chinese. They speak the dialect of
Peking, now recognised as the official language par
excellence. They do not use their family or surnames--which
belong rather to the clan than to the individual--but in order
to conform to the requirements of Chinese life, the personal
name is substituted. Their women do not compress their feet,
and the female coiffure and dress are wholly Tartar in
character. Intermarriage between the two races is not
considered desirable, though instances are not unknown. In
other respects, it is the old story of 'vida victrix;' the
conquering Tartars have been themselves conquered by the
people over whom they set themselves to rule. They have
adopted the language, written and colloquial, of China. ...
Manchu, the language of the conquerors, is still kept alive at
the Court of Peking. By a State fiction, it is supposed to be
the language of the sovereign. ... Eight emperors of this line
have already occupied the throne, and 'become guests on high;'
the ninth is yet [in 1882] a boy less than ten years of age.
Of these eight, the second in every way fills the largest
space in Chinese history. K'ang Hsi (or Kang Hi) reigned for
sixty-one years. ... Under the third Manchu Emperor, Yung
Cheng [A. D. 1723-1736], began that violent persecution of the
Catholics which has continued almost to the present day. The
various sects--Jesuits, Dominicans, Franciscans--had been
unable to agree about the Chinese equivalent for God, and the
matter had been finally referred to the Pope. Another
difficulty had arisen as to the toleration of ancestral
worship by Chinese converts professing the Catholic faith. ...
As the Pope refused to permit the embodiment of this ancient
custom with the ceremonies of the Catholic church, the new
religion ceased to advance, and by-and-by fell into
disrepute."

H. A. Giles, Historic China, chapter 5-6.

ALSO IN
S. W. Williams, The Middle Kingdom,
chapter 17, and 19-20 (volume 2).

C. Gutzlaff, Sketch of Chinese History,


volume 1, chapter 16, volume 2.

J. Ross, The Manchus.

Abbé Hue, Christianity in China, volume 2-3.

CHINA: A. D. 1839-1842.
The Opium War with England.
Treaty of Nanking.
Opening of the Five Ports.

"The first Chinese war [of England] was in one sense directly
attributable to the altered position of the East India Company
after 1833. [See INDIA: A. D. 1823-1833.] Up to that year
trade between England and China had been conducted in both
countries on principles of strict monopoly. The Chinese trade
was secured to the East India Company, and the English trade
was confined to a company of merchants specially nominated for
the purpose by the Emperor. The change of thought which
produced the destruction of monopolies in England did not
penetrate to the conservative atmosphere of the Celestial
Empire, and, while the trade in one country was thrown open to
everyone, trade in the other was still exclusively confined to
the merchants nominated by the Chinese Government. These
merchants, Hong merchants as they were called, traded
separately, but were mutually liable for the dues to the
Chinese Government and for their debts to the foreigners. Such
conditions neither promoted the growth of trade nor the
solvency of the traders; and, out of the thirteen Hong
merchants in 1837, three or four were avowedly insolvent.
(State Papers, volume 27, page 1310.) Such were the general
conditions on which the trade was conducted. The most
important article of trade was opium. The importation of opium
into China had, indeed, been illegal since 1796. But the
Chinese Government had made no stringent efforts to prohibit
the trade, and a Select Committee of the House of Commons had
declared that it was inadvisable to abandon an important
source of revenue to the East India Company. (State Papers, volume
29, page 1020.) The opium trade consequently throve, and grew
from 4,100 chests in 1796 to 30,000 chests in 1837, and the
Chinese connived at or ignored the growing trade. (Ibid., p.
1019). ... In 1837 the Chinese Government adopted a fresh policy.
{422}
It decided on rigourously stopping the trade at which it had
previously tacitly connived. ... Whether the Chinese
Government was really shocked at the growing use of the drug
and the consequences of its use, or whether it was alarmed at
a drain of silver from China which disturbed what the
political arithmeticians of England a hundred years before
would have called the balance of trade, it undoubtedly
determined to check the traffic by every means at its
disposal. With this object it strengthened its force on the
coast and sent Lin, a man of great energy, to Canton [March,
1839] with supreme authority. (State Papers, volume 29, page
934, and Autobiography of Sir H. Taylor, volume 1, appendix,
page 343.) Before Lin's arrival cargoes of opium had been
seized by the Custom House authorities. On his arrival Lin
required both the Hong merchants and the Chinese merchants to
deliver up all the opium in their possession in order that it
might be destroyed. (State Papers, volume 29, page 936.) The
interests of England in China were at that time entrusted to
Charles Elliot. ... But Elliot occupied a very difficult
position in China. The Chinese placed on their communications
to him the Chinese word 'Yu,' and wished him to place on his
despatches to them the Chinese word 'Pin.' But Yu signifies a
command, and Pin a humble address, and a British
Plenipotentiary could not receive commands from, or humble
himself before, Chinese officials. (State Papers, volume 29,
pages 881, 886, 888.) And hence the communications between him
and the Chinese Government were unable to follow a direct

You might also like