Orly Orly
Orly Orly

Reputation: 367

truncate table. Error Msg = sqlcode -668 sqlerrmc=7

I am trying to run this DB2 query on DBEAVER:

TRUNCATE table departments immediate

but I got this error:

DB2 SQL Error: SQLCODE=-668, SQLSTATE=57016, SQLERRMC=7;DB2INST1.DEPARTMENTS, DRIVER=4.19.49

(it is happening just when I run it on DBEVAER (external channel) on local it's run well.

help someone?

Upvotes: 1

Views: 5993

Answers (1)

mao
mao

Reputation: 12267

The sqlcode -668 with sqlerrmc=7 (this 7 is the "reason code") means:

SQL0668N Operation not allowed for reason code "" on table "".

and the reason code 7 means:

The table is in the reorg pending state. This can occur after an ALTER TABLE statement containing a REORG-recommended operation.

If your userid has the correct permissions, then try:

reorg table db2inst1.departments 

if you have command-line access to Db2, or from jdbc application like DBeaver call admin_cmd ('reorg table db2inst1.departments').

But the reorg will fail if your account lacks permissions, or if the syntax is not allowed on your Db2-server version, and in that case you must ask a DBA to do the work for you, or a become user db2inst1 and run the reorg.

When the reorg completes without errors, retry the truncate table.

Upvotes: 3

Related Questions