Home > Articles > Data > DB2

DB2 at a Glance: The Big Picture

  • Print
  • + Share This
  • 💬 Discuss
This chapter is from the book
This chapter provides an overview of the DB2 core concepts using a "big picture" approach. It introduces SQL statements and their classification in Data Definition Language (DDL), Data Manipulation Language (DML), and Data Control Language (DCL).

This chapter is like a book within a book: it covers a vast range of topics that will provide you not only with a good introduction to DB2 core concepts and components, but also with an understanding of how these components work together and where they fit in the "DB2 puzzle." After reading this chapter you should have a general knowledge of the DB2 architecture that will help you better understand the topics discussed in the next chapters. Subsequent chapters will revisit and expand what has been discussed here.

In this chapter you will learn about:

  • SQL statements and DB2 commands
  • DB2 tools
  • The DB2 environment
  • Federation
  • The database partitioning feature

You work with DB2 by issuing SQL statements and DB2 commands. To issue these statements and commands, you use DB2 tools. The DB2 tools interact with the DB2 environment by passing these statements and commands to the DB2 server for processing. This is shown in Figure 2.1.

02fig01.jpg

Figure 2.1 Overview of DB2

2.1 SQL Statements and DB2 Commands

SQL is the standard language used for retrieving and modifying data in a relational database. An SQL council formed by several industry leading companies determines the standard for these SQL statements, and the different relational database management systems (RDBMSs) follow these standards to make it easier for customers to use their databases. This section introduces the different categories of SQL statements and presents some examples.

DB2 commands are directives specific to DB2 that allow you to perform tasks against a DB2 server. There are two types of DB2 commands:

  • System commands
  • Command Line Processor (CLP) commands

2.1.1 SQL Statements

SQL statements allow you to work with the data stored in your database. The statements are applied against the database you are connected to, not against the entire DB2 environment. There are three different classes of SQL statements.

  • Data Definition Language (DDL) statements create, modify, or drop database objects. For example:
    
             CREATE INDEX ix1 ON t1 (salary)
    
             ALTER TABLE t1 ADD hiredate DATE
    
             DROP VIEW view1
    
          
  • Data Manipulation Language (DML) statements insert, update, delete, or select data from the database objects. For example:
    
             INSERT INTO t1 VALUES (10,'Johnson','Peter')
    
             UPDATE t1 SET lastname = 'Smith' WHERE firstname = 'Peter'
    
             DELETE FROM t1
    
             SELECT * FROM t1 WHERE salary > 45000
    
          
  • Data Control Language (DCL) statements grant or revoke privileges or authorities to perform database operations on the objects in your database. For example:
    
             GRANT  select ON employee TO peter
    
             REVOKE update ON employee FROM paul
    
          

2.1.2 DB2 System Commands

You use DB2 system commands for many purposes, including starting services or processes, invoking utilities, and configuring parameters. Most DB2 system commands do not require the instance&8212;the DB2 server engine process&8212;to be started (instances are discussed later in this chapter). DB2 system command names have the format


   db2
   
      x
   

where x represents one or more characters. For example:


   db2start

   db2set

   db2icrt

2.1.3 DB2 Command Line Processor (CLP) Commands

DB2 CLP commands are processed by the CLP tool (introduced in the next section). These commands typically require the instance to be started, and they can be used for database and instance monitoring and for parameter configuration. For example:


   list applications

   create database

   catalog tcpip node

You invoke the Command Line Processor by entering db2 at an operating system prompt. If you enter db2 and press the Enter key, you would be working with the CLP in interactive mode, and you can enter the CLP commands as shown above. On the other hand, if you don't want to work with the CLP in interactive mode, prefix each CLP command with db2 . For example:


   db2 list applications

   db2 create database

   db2 catalog tcpip node

Many books, including this one, display CLP commands as db2 CLP_command for this reason. Chapter 4, Using the DB2 Tools, explains the CLP in greater detail.

  • + Share This
  • 🔖 Save To Your Account

Discussions

comments powered by Disqus