Create a Database in Db2

IBM Db2 is one of the largest and most sophisticated enterprise DBMS packages ever created. Db2 is a product of IBM, the company that invented SQL. This topic is the third step in a five topic sequence showing a complete installation, and then utilization, of Db2 for Developers from the very beginning.  Please see Install Db2 topic for basic info on Db2.


Disclaimer: These topics were accurate when written, using the versions of installation software indicated.  Third party packages can and do change, so this topic may be out-of-date.  It is provided as an example of how such installations can be approached.


Installing Db2 and readying it for use in typical installations involves five steps:


Install Db2


Open a Firewall Port for Db2


Create a Database in Db2


Install Db2 Client


Connect to Db2


This is the third topic in the above sequence of steps.


So far, we have installed Db2 on our target machine.   We enabled use of Db2 through networks by opening a firewall port.  We now will create a database within Db2 called gisdb,  and we will test the database with a local connection.


We are using a 64-bit Windows 10 server system on which we have installed Db2, to which we have connected via Remote Desktop (RDP).  This entire topic was conducted on that machine via RDP.   Our Windows login used for RDP has Administrator rights.

Launch DB2 Command Line Processor

The easiest way to create a database within our new Db2 installation is to issue a few, short command line commands to Db2.   When we installed Db2 in the Install Db2 topic, we also installed the Db2 Command Line Processor utility.  We will now use that utility to issue a few commands to our Db2 installation.



In the Windows Start button system, we right-click on the DB2 Command Line Processor choice and choose Run as administrator (never hurts...) to launch the DB2 Command Line Processor (CLP) command line system.





Wow!  Something from the prior century.   Using the command line processor is like using a DOS command prompt window.  Enter a text command and then press Enter.  Easy!   CLP commands are actually very easy and convenient.   A handy list of CLP commands appears at





To create a database called gisdb (case does not matter) we enter







Db2 works for a bit, and when the database is created we must activate it.  We enter







We have now created and activated a database called gisdb.     To exit the command line processor, we enter







That does not close the command prompt window, but instead it simply drops us out of the command line processor and leaves us in the BIN folder of the Db2 installation folder within a standard Windows Command Prompt window.   That is convenient for what we must do next.

Enable Spatial Extender on the Database

We must now enable the Spatial Extender option on the new gisdb database we have created.




We enter




That uses the DB2SE command line utility to enable the Spatial Extender option on our gisdb database.





Done!  We can now close the command prompt window.

Test Database using a Local Connection

If we have Manifold installed on the server machine, we can try a local connection to Db2 to verify Db2 is working, the gisdb database has been created, and spatial capabilities have been enabled for the database.   If we do not have a Manifold license installed on the server machine, we can install the free Manifold Viewer and connect using that.


We do not need to install client software, because installing Db2 on the server machine also installs client software on that machine.



Launch Manifold, and then choose File - Create - New Data Source.  


In the dropdown menu we then choose More... to launch the New Data Source dialog.



Enter a descriptive name, Db2 GISDB, and choose Database: db2 as the type.  Click the browse [...] button to launch the Database Login dialog.



Enter localhost for the Server.  


Choose Use login and password and then enter db2admin as the login.  Enter the password we provided for the db2admin user in the Install Db2 topic.   


For the Database, enter GISDB.  Case is not significant, so we can enter the name of the database in upper or lower case.  


It is a good idea to check for errors by pressing the Test button.



 If that does not report a connection, we should fix any mistakes.  When we see Connection established we press OK.



Back in the Database Login dialog, press OK.


A risk element for security is the plain text use of passwords in connection strings.  We should not leave this project unattended where somebody else can right-click on the data source to see the Properties of it, which would reveal in plain text the password for db2admin in the JSON string that gives the connection string.    When other people might have access to our computer and our files, we should not save the project with the data source in it, since someone else might open that project to find the password string inside.


We can avoid such risks by using integrated security, where the Windows login through which a connection is made is mapped into user accounts within the DBMS, to which all the power and sophistication of roles and privileges can apply.  To keep the presentation as simple as possible, except for the SQL Server example, integrated security is not used in these case studies.



Back in the New Data Source dialog we press Create Data Source.



A new data source called Db2 GISDB appears in our Project pane.



We can expand it, and then within the System Data folder we can double-click the mfd_srid table to open it.   That displays the coordinate system SRIDs available within the gisdb database.  That shows Db2 is running, the gisdb database has been created, and it has been enabled for spatial work.



If we like, we can save the project, using a descriptive name as seen in the title bar of the illustration above.  We can then open the project and have a Db2 GISDB data source within the project.  


We now have a database created, activated, and enabled for spatial work within Db2.   Next, we configure client software on our client desktop machine.

Next Steps

Continue this case study on installing Db2 with the Install Db2 Client topic.


See the preceding topic: Open a Firewall Port for Db2


Jump to the beginning of the case study: Install Db2


See Also



DBMS Data Sources - Notes


Project Pane


File - Create - New Data Source


Command Window


Real and Virtual Components


Install MySQL


Install SQL Server


Install PostgreSQL


Install Oracle


Install Db2


Open a Firewall Port for Db2


Install Db2 Client


Connect to Db2


Big List of Formats and Data Sources


Example: Switching between Manifold and Native Query Engines