User Tools

Site Tools


databse:db2

under_construction.jpg

Create a smple database, test connection, and delete (drop):

[db2inst1@dev-tpc ~]$ db2sampl

  Creating database "SAMPLE"...
  Connecting to database "SAMPLE"...
  Creating tables and data in schema "DB2INST1"...
  Creating tables with XML columns and XML data in schema "DB2INST1"...

  'db2sampl' processing complete.
[db2inst1@dev-tpc ~]$ db2 connect to sample

   Database Connection Information

 Database server        = DB2/LINUXX8664 9.7.4
 SQL authorization ID   = DB2INST1
 Local database alias   = SAMPLE

[db2inst1@dev-tpc ~]$ db2 "select * from staff where dept = 20"

ID     NAME      DEPT   JOB   YEARS  SALARY    COMM     
------ --------- ------ ----- ------ --------- ---------
    10 Sanders       20 Mgr        7  98357.50         -
    20 Pernal        20 Sales      8  78171.25    612.45
    80 James         20 Clerk      -  43504.60    128.20
   190 Sneider       20 Clerk      8  34252.75    126.50

  4 record(s) selected.

[db2inst1@dev-tpc ~]$ db2 list database directory show detail 

 System Database Directory

 Number of entries in the directory = 1

Database 1 entry:

 Database alias                       = SAMPLE
 Database name                        = SAMPLE
 Local database directory             = /home/db2inst1
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

db2inst1@dev-tpc ~]$ db2 connect reset 
DB20000I  The SQL command completed successfully.
[db2inst1@dev-tpc ~]$ db2 drop database sample
DB20000I  The DROP DATABASE command completed successfully.

To verify that the TPCDB database

db2 list db directory

Are the tables and views present in the TPCDB database?
To verify that the tables and views are present, run the following DB2 commands:

db2 connect to TPCDB
db2 list tables for schema TPC
db2 disconnect TPCDB
databse/db2.txt · Last modified: 2021/01/01 21:24 (external edit)