At 23:34 -0800 11/21/03, Chris wrote:
Wouldn't this also work?:

mysql -u root -p -e "CREATE TABLE t$date(...)" yourdatabase

Sure.




-----Original Message-----
From: Paul DuBois [mailto:[EMAIL PROTECTED]
Sent: Friday, November 21, 2003 12:46 PM
To: Julian Zottl; Andy Eastham; Mysql List
Subject: RE: DB design question - shell scripting...


At 10:56 -0500 11/21/03, Julian Zottl wrote:
Andy,
Thanks for responding.  I think that I am going to go with the idea
of creating a tale for each day.  My thoughts were to write a shell
script to do this for me, but I am running into a problem:  I wrote
the following:
#!/bin/sh
date=`date "+%m%d%Y"`
export date
mysql -u root -p < createdb.sql

Then in createdb.sql
CONNECT Blah;
CREATE TABLE $date (
.....
) TYPE=MyISAM;

But it's not passing the $date variable to SQL :/  I've been looking
on the web for a way to do this, but have yet to find it.  any ideas?

You could use a here-document instead of createdb.sql


#!/bin/sh
date=`date "+%m%d%Y"`

mysql -u root -p <<EOF
CONNECT Blah;
CREATE TABLE t$date (
.....
) TYPE=MyISAM;
EOF

I put a "t" before $date -- you don't want to try creating a table
with a name that's all digits.  That makes it indistinguishable from
a number, so you'd have to quote it with backticks every time you refer
to it.


>Julian


--
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]



Reply via email to