Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table dissapeared from db

Status
Not open for further replies.

JOBARAM

Programmer
May 25, 2002
52
IL
Hi,
I'm using Innodb type tables in my db.
I'm running a routine that should drop a table and create it again.
running this routine several times caused the table not to be created again, so if you type ' Show tables' you don't see it, but after creating it again despite the fact that you see an error, if you use select * from tableX, U can see the inside of the table.

Doe's somebody understands what is going on?
Thanks
Yossi
 
Go back and have alook through your code, it sounds like the first table isn't being fropped properly, then the creation of the table is producing an error, then when you go to look at the table you see the old one that was never dropped.

Of course I could be wrong

Jo
 
Go back and have alook through your code, it sounds like the first table isn't being dropped properly, then the creation of the table is producing an error, then when you go to look at the table you see the old one that was never dropped.

Of course I could be wrong

Jo
 
Jo,
Thanks for your reply.
I use a simple drop table. many of the times it works but one time unexpectedly it faild and from that point I couldn't create\drop the table again.
Maybe its related to configuration of the db via My.ini file? or some thing else???
Thanks again
Yossi
 
Instead of dropping and creating the same table over and over, try the Truncate command. It is much quicker.

truncate table MY_TABLE;

If you need to drop and re-create the tables you can use the IF EXISTS syntax.

create table if not exists MY_TABLE (
colA int,
colB int
);

drop table if exists MY_TABLE;

Always check for errors after each query completes. This will prevent that from happening in the future.

abombss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top