Download full Foundation Db2 and Python: Access Db2 with Module-Based API Examples Using Python 1st Edition W. David Ashley ebook all chapters
Download full Foundation Db2 and Python: Access Db2 with Module-Based API Examples Using Python 1st Edition W. David Ashley ebook all chapters
com
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
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
https://ebookmeta.com/product/learn-opencv-with-python-by-
examples-2nd-edition-james-chen/
ebookmeta.com
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
https://ebookmeta.com/product/physics-volume-1-2023-2023rd-edition-sl-
arora/
ebookmeta.com
https://ebookmeta.com/product/supervised-machine-learning-for-text-
analysis-in-r-1st-edition-emil-hvitfeldt-julia-silge/
ebookmeta.com
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
v
Table of Contents
vi
Table of Contents
Creating a Table��������������������������������������������������������������������������������������������������������������������� 41
Alter a Table��������������������������������������������������������������������������������������������������������������������������� 43
Other Table SQL Statements�������������������������������������������������������������������������������������������������� 43
Dropping a Table�������������������������������������������������������������������������������������������������������������������� 44
Summary������������������������������������������������������������������������������������������������������������������������������������ 44
vii
Table of Contents
viii
Table of Contents
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:
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
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:
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:
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
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).
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.
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.
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
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.
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.
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
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
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."
ALSO IN:
H. Birkedal, The late War in South America (Overland Monthly,
January, February, and March, 1884).
CHILE: A. D. 1885-1891.
The presidency and dictatorship of Balmaceda.
His conflict with the Congress.
Civil war.
CHILIARCHS.
Captains of thousands, in the army of the Vandals.
CHILPERIC I.,
CHILTERN HUNDREDS,
Applying for the Stewardship of the.
{416}
CHINA:
The names of the Country.
CHINA:
The Origin of the People and their early History.
ALSO IN
D.C. Boulger, History of China, volume 1-2.
CHINA:
The Religions of the People.
Confucianism.
Taouism.
Buddhism.
ALSO IN:
R. K. Douglas, Confucianism and Taouism.
ALSO IN
J. Legge, The Religions of China.
CHINA: A. D. 1205-1234.
Conquest by Jingis Khan and his son.
CHINA: A. D. 1259-1294.
The Empire of Kublai Khan.
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.
{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.
{421}
(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.
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."
ALSO IN
S. W. Williams, The Middle Kingdom,
chapter 17, and 19-20 (volume 2).
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