Re: SHOW CREATE TABLE on one line?

2003-10-13 Thread Paul DuBois
At 14:48 -0500 10/13/03, Adam Clauss wrote:
I'm currently writing a program that will make use of the SHOW CREATE TABLE
statement to verify that existing tables are correct (if not, it drops them
and recreates).  Why is it though that the SHOW CREATE TABLE statement
returns the answer on multiple lines?  Why not just one line?  And is it
possible to make it return the result on just one line?
The statement looks better if you print it.

Why does it matter to your program what it looks like, especially if
you're just executing the statement?  It's a single string, so it should
be a legal statement in any API.
Thanks,
Adam Clauss
[EMAIL PROTECTED]


--
Paul DuBois, Senior Technical Writer
Madison, Wisconsin, USA
MySQL AB, www.mysql.com
Are you MySQL certified?  http://www.mysql.com/certification/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


RE: SHOW CREATE TABLE on one line?

2003-10-13 Thread Adam Clauss
Well the issue wasn't so much with my program at runtime, but at design time
(now).  What I am doing is hardcoding the string that creates the table into
the program.  Program then calls SHOW CREATE TABLE and compares the two
strings to see if they are the same.  If not, it drops and recreates.

What I have to do everytime I add a table and want to hardcode it in, is run
SHOW CREATE TABLE myself when I know the table is correct and then copy that
string into my program.  That copying part is where I am having difficulty.
It is taking a while for me to figure out where linebreaks, spaces, etc. are
in it.  I spend way too much time trying to make everything line up
character per character.
On the other hand if it was all on one line it would be a simple matter of
copy/paste in.  This, to me, seems like it would be much better to see as
well.
If you can suggest another method to accomplish this, I'm definitely willin
to listen.  I previously was using DESCRIBE to figure out if the table was
correct... But the code to compare each field of each table was getting
rather messy -- MUCH messier than simply saying:

String create = some create string
String str = run SHOW CREATE TABLE
If (create != str)
recreate table


Adam Clauss
[EMAIL PROTECTED]


 -Original Message-
 From: Paul DuBois [mailto:[EMAIL PROTECTED] 
 Sent: Monday, October 13, 2003 3:15 PM
 To: Adam Clauss; [EMAIL PROTECTED]
 Subject: Re: SHOW CREATE TABLE on one line?
 
 
 At 14:48 -0500 10/13/03, Adam Clauss wrote:
 I'm currently writing a program that will make use of the 
 SHOW CREATE TABLE
 statement to verify that existing tables are correct (if 
 not, it drops them
 and recreates).  Why is it though that the SHOW CREATE TABLE 
 statement
 returns the answer on multiple lines?  Why not just one 
 line?  And is it
 possible to make it return the result on just one line?
 
 The statement looks better if you print it.
 
 Why does it matter to your program what it looks like, especially if
 you're just executing the statement?  It's a single string, 
 so it should
 be a legal statement in any API.
 
 
 Thanks,
 Adam Clauss
 [EMAIL PROTECTED]
 
 
 -- 
 Paul DuBois, Senior Technical Writer
 Madison, Wisconsin, USA
 MySQL AB, www.mysql.com
 
 Are you MySQL certified?  http://www.mysql.com/certification/
 
 
 -- 
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:
 http://lists.mysql.com/mysql? [EMAIL PROTECTED]
 


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: SHOW CREATE TABLE on one line?

2003-10-13 Thread Keith C. Ivey
On 13 Oct 2003 at 16:59, Adam Clauss wrote:

 Well the issue wasn't so much with my program at runtime, but at
 design time (now).  What I am doing is hardcoding the string that
 creates the table into the program.  Program then calls SHOW CREATE
 TABLE and compares the two strings to see if they are the same.  If
 not, it drops and recreates.
 
 What I have to do everytime I add a table and want to hardcode it in,
 is run SHOW CREATE TABLE myself when I know the table is correct and
 then copy that string into my program.  That copying part is where I
 am having difficulty. It is taking a while for me to figure out where
 linebreaks, spaces, etc. are in it. [...]

You can hardly expect MySQL to change its behavior to accommodate
your particular situation.  How many other people do you are think
are doing what you're doing?  Far fewer than would be annoyed by
having the CREATE TABLE statement scrunched into one long line,
I'd bet.

How about saving the SHOW CREATE TABLE output to a file and keeping 
that around?  Then your program can read the file, check the existing 
table structure against that, and if it's changed issue a warning 
message and re-create the file with the new output.  Seems a lot 
better than hand-coding.

-- 
Keith C. Ivey [EMAIL PROTECTED]
Tobacco Documents Online
http://tobaccodocuments.org


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]