473,320 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

does drop table command also drop indexes on it?

Hello,
I always assumed that dropping table will drop everything associated
with it like indexes, references etc.
I just noticed that after dropping table A and recreating it and then
creating index on it gave me error

DROP TABLE tmp
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0204N "TMP" is an undefined name. SQLSTATE=42704

CREATE TABLE tmp ( a INTEGER, b CHAR(2), c CHAR(2) )
DB20000I The SQL command completed successfully.

CREATE UNIQUE INDEX tmp_ix ON tmp (a)
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0601N The name of the object to be created is identical to the
existing
name "tmp_ix" of type "INDEX". SQLSTATE=42710

please explain ?

Feb 9 '07 #1
3 20269
db2admin wrote:
Hello,
I always assumed that dropping table will drop everything associated
with it like indexes, references etc.
I just noticed that after dropping table A and recreating it and then
creating index on it gave me error

DROP TABLE tmp
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0204N "TMP" is an undefined name. SQLSTATE=42704

CREATE TABLE tmp ( a INTEGER, b CHAR(2), c CHAR(2) )
DB20000I The SQL command completed successfully.

CREATE UNIQUE INDEX tmp_ix ON tmp (a)
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0601N The name of the object to be created is identical to the
existing
name "tmp_ix" of type "INDEX". SQLSTATE=42710

please explain ?
Check for that index. Maybe it belongs to another table and NOT the one
you just dropped.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Feb 9 '07 #2
db2admin wrote:
Hello,
I always assumed that dropping table will drop everything associated
with it like indexes, references etc.
Yes they are dropped.
I just noticed that after dropping table A and recreating it and then
creating index on it gave me error

DROP TABLE tmp
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0204N "TMP" is an undefined name. SQLSTATE=42704

CREATE TABLE tmp ( a INTEGER, b CHAR(2), c CHAR(2) )
DB20000I The SQL command completed successfully.

CREATE UNIQUE INDEX tmp_ix ON tmp (a)
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0601N The name of the object to be created is identical to the
existing
name "tmp_ix" of type "INDEX". SQLSTATE=42710
Index names have to be unique within a schema - not at the table level. So
I guess you have a TMP_IX index on some other table.
$ db2 "create table t ( a int, b int)"
DB20000I The SQL command completed successfully.
$ db2 "create unique index idx on t(a)"
DB20000I The SQL command completed successfully.
$ db2 "select count(*) from syscat.indexes where indname = 'IDX'"

1
-----------
1

1 record(s) selected.

$ db2 drop table t
DB20000I The SQL command completed successfully.
$ db2 "select count(*) from syscat.indexes where indname = 'IDX'"

1
-----------
0

1 record(s) selected.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Feb 9 '07 #3
On Feb 9, 9:50 am, Knut Stolze <sto...@de.ibm.comwrote:
db2admin wrote:
Hello,
I always assumed that dropping table will drop everything associated
with it like indexes, references etc.

Yes they are dropped.
I just noticed that after dropping table A and recreating it and then
creating index on it gave me error
DROP TABLE tmp
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0204N "TMP" is an undefined name. SQLSTATE=42704
CREATE TABLE tmp ( a INTEGER, b CHAR(2), c CHAR(2) )
DB20000I The SQL command completed successfully.
CREATE UNIQUE INDEX tmp_ix ON tmp (a)
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0601N The name of the object to be created is identical to the
existing
name "tmp_ix" of type "INDEX". SQLSTATE=42710

Index names have to be unique within a schema - not at the table level. So
I guess you have a TMP_IX index on some other table.

$ db2 "create table t ( a int, b int)"
DB20000I The SQL command completed successfully.
$ db2 "create unique index idx on t(a)"
DB20000I The SQL command completed successfully.
$ db2 "select count(*) from syscat.indexes where indname = 'IDX'"

1
-----------
1

1 record(s) selected.

$ db2 drop table t
DB20000I The SQL command completed successfully.
$ db2 "select count(*) from syscat.indexes where indname = 'IDX'"

1
-----------
0

1 record(s) selected.

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Yes
I was wrong
it was index on different table
thanks for help

Feb 9 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rod Davis | last post by:
Once a week, we run a script to drop all the indexes on tables in our db, followed by another to add those indexes back (we insert every day, so we do this to prevent index fragmenttation). The...
1
by: Jay | last post by:
Hi I have a huge table with over 100million records and on regular basis ineed to delete nearly a million records and insert a million records. Currently I delete indexes before going through the...
10
by: BuddhaBuddy | last post by:
Platform is DB2/NT 7.2.9 The table was created like this: CREATE TABLE MYTEST ( MYTESTOID bigint not null primary key, FK_OTHEROID bigint not null references other, FK_ANOTHEROID bigint not...
3
by: Rajesh Kumar Mallah | last post by:
Hi, Looks like alter table does not tells about the indexes it dropped PG version: 7.4.3 Regds mallah.
6
by: ruben | last post by:
Hi: I'm running a large database on PostgreSQL 7.1.3. 20 days ago the database failed with a threatening and not too descriptive error like: pg_exec() query failed: server closed the...
3
by: Challenge | last post by:
Hi, I have a table creation script that generated by ERWin. An index name is too long and has been truncated as "XPKsp_prj_stk_ord_". Now I want to drop and recreate it as another name. I got...
4
by: Gregor Kovač | last post by:
Hi! Is it possible do to something like this: DROP TABLE MY_TABLE ONLY IF EXISTS and the same for views, indexes, procedures, .... ? Best regards, Kovi --...
2
by: rcamarda | last post by:
Hi, I found this SQL in the news group to drop indexs in a table. I need a script that will drop all indexes in all user tables of a given database: DECLARE @indexName NVARCHAR(128) DECLARE...
1
by: dsdevonsomer | last post by:
Hello all, I am new to managing indexes on large tables and need some help. Hopefully, I am not repeating question here. I searched as much as I can, but not finding relatively best answer.. ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.