Managing databases
Creating databases
Changing number of concurrent databases
If you receive and error like this:
Run following command:
Starting and stopping DB2
Before restarting any IBM DB2 server, I would recommend to display all applications and users that are connected to the specific database that you want to stop. To ensure that no vital or critical applications are running.
Following command list all applications
If you change any configuration parameter, you will probably need to restart, so, stop database server with:
Now, for starting IBM DB2 again, run following command:
Working with schemas
Creating a new schema
Obtaining users
If you want to list schema users, just run following command:
As you can see part of the information about schemas and users is stored in syscat.schemata.
Grant privileges
Getting information about databases and tables
Connect to the database
List information about tables
List all tables:
To list all tables in selected schema, use:
To describe a table, type:
List information about databases
List databases:
If you just want the database names, without the titles, use:
HANDLING ISSUES WHEN LOAD COMMAND IS IN PENDING STATE
[db2inst1@host1 ~]$ touch test.del
[db2inst1@host1 ~]$ LOAD from 'test.del' OF DEL TERMINATE INTO db2inst1.reporter_status
-bash: LOAD: command not found
[db2inst1@host1 ~]$ db2 LOAD from 'test.del' OF DEL TERMINATE INTO db2inst1.reporter_status
SQL3501W The table space(s) in which the table resides will not be placed in
backup pending state since forward recovery is disabled for the database.
SQL3110N The utility has completed processing. "0" rows were read from the
input file.
Number of rows read = 0
Number of rows skipped = 0
Number of rows loaded = 0
Number of rows rejected = 0
Number of rows deleted = 0
Number of rows committed = 0
[db2inst1@host1 ~]$ db2 set integrity for db2inst1.reporter_status immediate checked
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL3600N The IMMEDIATE CHECKED option of the SET INTEGRITY statement is not
valid since the table "DB2INST1.REPORTER_STATUS" is a user maintained
materialized query table or is not in the Set Integrity Pending state.
SQLSTATE=51027
[db2inst1@host1 ~]$ db2 "select count(*) from reporter_status"
1
-----------
243724
1 record(s) selected.
db2 LOAD FROM "/tmp/0812.out" OF DEL MODIFIED BY identityignore generatedignore rowchangetimestampignore timestampformat=\"YYYY-MM-DD hh:mm:ss\" implieddecimal INSERT INTO DB2INST1.REPORTER_STATUS
No comments:
Post a Comment