List:General Discussion« Previous MessageNext Message »
From:Arthur Fuller Date:December 30 2002 1:58pm
Subject:RE: style question: "drop database" in an install script
View as plain text  
I don't know about anyone else, but for this sort of thing I love the
program called DeZign, which is a data-modeling tool. You can "draw" your
tables and their columns and set up relations and so on. DeZign will then
write your code for you.

Personally, I like to keep all my "drop" statements in one script, all my
"create" scripts in another, and all my "populate" scripts in yet another.

Arthur

-----Original Message-----
From: David T-G [mailto:davidtg-mysql@stripped]
Sent: Friday, December 27, 2002 8:15 PM
To: mysql users
Subject: style question: "drop database" in an install script


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi, all --

I'm working up the schema for my application and, as you can imagine,
starting over and reloading numerous times :-)  In fact, I intend for the
script to be an install script, run on a new installation of the software
to set things up.

The script starts out

  drop database if exist dbname ;
  create database dbname ; use dbname ;
  create table tablename
  (
    ...
  ) ;
  ...

to set things up and then continues

  insert into tablename (field,field,field)
    ( data , data , data ) ,
    ...
    ( data , data , data ) ;
  ...

to set up the predefined things (credit card types and so on).

To reload the database and try something new, all I have to do is

  mysql -udroot -p < script.sql

and what was there goes away and is rebuilt fresh.  That's mighty
convenient as I'm building up a table's design and trying it out.

Soooooo...  When you experienced folks write software that's meant to be
installed from a script or such, do you lead off with a 'drop database'
command, or is that just too dangerous to put in a script and you make
your users clean up any old installation by hand?  This will have to be
run by a root user, so we can figure that this user might have read the
docs and know that he's going to start [over] from scratch, but then,
again, users are users :-)

Meanwhile, is there if/then/else functionailty in SQL so that I can say

  if exist dbname exit "some error" ;
  create database dbname ;
  ...

and not try to create and populate a database on top of an existing one?
Or is there perhaps a "RENAME DATABASE" command (I saw RENAME TABLE) so
that I could rename the old one to get it out of the way but not toss it?


TIA & HAND

mysql query,
:-D
- --
David T-G                      * There is too much animal courage in
(play) davidtg@stripped * society and not sufficient moral courage.
(work) davidtgwork@stripped  -- Mary Baker Eddy, "Science and Health"
http://www.justpickone.org/davidtg/    Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)

iD8DBQE+DPsqGb7uCXufRwARAsp8AKC7BuVdyO7Dl5fkbvEM51o+i/BAEgCeI5iI
dI7HQb5oywLHuZIjLxXYZwY=
=QTHL
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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 <mysql-thread128514@stripped>
To unsubscribe, e-mail <mysql-unsubscribe-afuller=etsys.com@stripped>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Thread
style question: "drop database" in an install scriptDavid T-G28 Dec
  • ORDER dilemmaPag28 Dec
    • RE: ORDER dilemmaJohn Coder28 Dec
      • Re: ORDER dilemmaDan Nelson28 Dec
  • Re: style question: "drop database" in an install scriptiConnect \(Berlin\) Stefan Hinz28 Dec
  • RE: style question: "drop database" in an install scriptArthur Fuller30 Dec
    • Re: style question: "drop database" in an install scriptDavid T-G30 Dec
Re: style question: "drop database" in an install scriptDavid T-G28 Dec