| Author |
Detect if table exists
|
Manish Hatwalne
Ranch Hand
Joined: Sep 22, 2001
Posts: 2573
|
|
This should be easy, but I am unable to find it now. How can I detect if a particular table exists or not in my DB (I am using MySQL). I cannot delete table, so I can't use drop if exists; but can I use count (*) if exists, or sth similar? I am not much of a DB person. Any pointers would be very useful. TIA, - Manish
|
 |
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
|
|
I think , you should be use some tool for manage MySQL DB such as MySQLFront, phpadmin ... This for help. MySQLFront PHP myadmin
|
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
|
 |
Manish Hatwalne
Ranch Hand
Joined: Sep 22, 2001
Posts: 2573
|
|
I didn't say I need to manage MySQL. I needed to detect in my code if te table existed. Anyway, I have found a way to do this with MetaData. - Manish
|
 |
Surasak Leenapongpanit
Ranch Hand
Joined: May 10, 2002
Posts: 341
|
|
How can I detect if a particular table exists or not in my DB (I am using MySQL).
mysql>show tables;
I cannot delete table, so I can't use drop if exists; but can I use count (*) if exists, or sth similar?
Check your access privilege on the database.
|
 |
Nicholas Cheung
Ranch Hand
Joined: Nov 07, 2003
Posts: 4982
|
|
I cannot delete table, so I can't use drop if exists; but can I use count (*) if exists, or sth similar? I am not much of a DB person.
If you want to see the data within a table, make sure that you have the *select* privilege. Nick
|
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
|
Moving this to the JDBC forum...
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
Julian Kennedy
Ranch Hand
Joined: Aug 02, 2004
Posts: 823
|
|
I think what Manish was after is something like: Manish, if so could you post the name of the useful MySQL data dictionary (metadata) table(s)? Thanks Jules
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Detect if table exists
|
|
|