Hi all:
Using script files is convenient because it allows storage of
frequently used queries, and facilitates editing long queries without
having to retype the whole thing.
Something that would make script files more convenient is to change
the directory from which SOURCE reads them.
My databases (probably everyone's?) are located in the directory:
/usr/local/mysql/
It is in this directory that SOURCE looks for script files. Thus the
command:
mysql> SOURCE home_runs.sql
looks for the script file:
/usr/local/mysql/home_runs.sql
But often script files are located elsewhere, e.g., when downloaded
from the web, or when created and stored elsewhere for organizational
purposes. For the SOURCE command to access such scripts, the absolute
path must be given, e.g.:
mysql> SOURCE /Users/jack/Desktop/Du_Bois_scripts/mortality.sql
It would be nice to re-set the "default" directory to
/Users/jack/Desktop/Du_Bois_scripts, so that one would have only to
type:
mysql> SOURCE mortality.sql
to run the mortality.sql script that is located in
/Users/jack/Desktop/Du_Bois_scripts.
Is that somehow possible? Or is there a common workaround?
I thought of putting a script in the default directory
(/usr/local/mysql/) that in turn calls the desired script. I.e., put a
script in /usr/local/mysql that contains only the line:
SOURCE /Users/jack/Desktop/Du_Bois_scripts/mortality.sql
But that requires fiddling with two scripts as one goes along, and I'm
wondering whether there is a more straightforward solution.
Also tried to use a user variable to supply the re-used portion of the
directory path, but that just produced an error:
mysql> set @thing="scripts" ;
mysql> source concat(@thing,"/jacks/hr.sql");
ERROR:
Failed to open file 'concat(@thing,"/jacks/hr.sql")', error: 2
Finally, if indeed it is not possible to re-set the "default"
directory, I'm wondering why? Is it a security thing? Just curious.
Thanks all.
Best,
Jack Connolly
Hanover, MA
+--------------------+
| version() |
+--------------------+
| 3.23.52-entropy.ch |
+--------------------+
..... running under Mac OS 10.2 (Jaguar).
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php