Posts

Showing posts from September, 2019

How to Run Reorg,Reorgcheck,Runstats & Granting privileges on all tables in a database

Reorg Command on all Tables in a Database   db2 -x "select 'reorg table',rtrim(tabschema)||'.'|| rtrim(tabname)from syscat.tables where type = 'T' and TABSCHEMA = 'ABC'" > reorg_out.sql   db2 -tvf reorg_out.sql   Runstats Command on all tables in a database   db2 -x "select 'runstats on table',rtrim(tabschema)||'.'|| rtrim(tabname)from syscat.tables where type = 'T' and TABSCHEMA = 'ABC'" > runstat_out.sql   db2 -tvf runstat_out.sql   Granting Select Privileges on all Tables in a Database   db2 -x  "select 'Grant select on table ' || trim(tabschema) || '.' || trim(tabname)|| ' to user test_usr' from syscat.tables where tabschema = 'ABC'" >  grants.sql   Granting Execute Privileges on all Tables in a Database   db2 -x  "select 'Grant Execute on procedure ' || trim(procschema) || '.' || trim(procna...

How to catalog a database in DB2 LUW

In this post,I will show how to catalog and access remote databases on Linux/unix machine.   Below are the details of Instance,database name & port number   Remote Instance name : db2inst1 Remote Database name : Test Remote Instance port    : 50000 Local Instance name  : db2inst3 Local Database name : Abc   I will make an attempt to catalog Remote Database Test Residing in db2inst1 instance and will establish a connection to the remote database from my Local instance.   For cataloging the database,we need   1.Hostname for the Remote Server 2.Port number for the Remote Server 3.Database name for the Remote Server   The Syntax for cataloging the Database as  below Db2 catalog tcpip node <nodename> remote <hostname> server<portno>   Here Nodename is the local nickname(You can use anyname>)   Db2 catalog db <databasename> at node <...

What is Db2Batch in Db2

The Db2batch is known as benchmark tool. It will show the Estimated time of the queries which you have written in the file. Ex: I have a file called table.sql which is having the below statements. Table.sql ======================================================================== create table abc.data(id int,name varchar(100)); insert into abc.data values(1,'sql'),(2,'oracle'),(3,'sqlserver'),(4,'mysql'); update abc.data set name = 'mongodb' where id = 1; insert into abc.data values(10,'aaaaaaaaaaaaaavvcnekneknekdwlcnrflrbfl3rffo3jrr,dnfvdmcdjcbdkpoepmcd.ckdnmcwkeniwnekedoeml'); select * from abc.data;   ========================================================================   the command to execute the db2batch is    db2batch -d sample -f table.sql   here sample is my database_name & f is the filename    The below results will show the query & the execution time.   * SQL Statement Number 1...