----- Original Message ----- From: "B Wiley Snyder" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, September 23, 2004 2:09 AM Subject: newbie green pea
> Hello everyone, I know Rhino gave me a link or something a month ago > but..... can anyone give me a link to a tutorial on how to > ...............basically I have been creating my databases one command > entry at a time. I just thought if someone knew of a site off the top of > there list that could help me create a file of a database and deploy it. > I've got a mysql "BIBLE", if anything educate me on the terminology so I > can look it up. > > Thanks for anyones generous and helpful response > I think the word you're looking for is 'script'. A script is a file that contains a series of commands that are supposed to be executed; you type one command to run the script and all the commands within the script are executed as a result. Of course, a script can get more complicated: it could have conditional logic so that some commands are only executed if a particular condition or combination of conditions are true. Here is an example of a script that does a few different things, some of them conditionally: ---------------------------------------------------------------------------- ---------- use NFL; drop table if exists Seasons; create table if not exists Seasons (season smallint not null, primary key(season), ) Type=InnoDB; drop table if exists Teams; create table if not exists Teams (team_code char(3) not null, team_name char(50) not null, team_conference char(3) not null, team_division char(5) not null, primary key(team_code), ) Type=InnoDB; insert into Seasons values(2002); insert into Seasons values(2003); insert into Seasons values(2004); select * from Seasons; load data infile '/home/rhino/MySQL/NFL/Teams.asc' replace into table Teams fields terminated by ';' optionally enclosed by '"' escaped by '\\' lines starting by '"' terminated by '\n'; select * from Teams; ---------------------------------------------------------------------------- ------------------ The script is in a file called Create_Teams.sql. The first statement, 'use NFL', tells the script that the database it is supposed to use is called NFL. The first Drop Table statement tells the script to drop an existing table named Seasons if it already exists; if it doesn't exist, the script doesn't drop anything and proceeds to the first Create Table statement. The first Create Table statement creates a table named 'Seasons' if it doesn't exist already; if the table does exist, the statement doesn't create anything and proceeds to the next statement. The second Drop Table statement works like the first Drop Table statement. The second Create Table statement works like the first Create Table statements. The three Insert statements each add a row to the Seasons table. 'select * from Seasons' displays the contents of the Seasons table. The 'load data' statement populates the Teams table from an external file named 'NFL.Teams.asc'. 'select * from Teams' displays the contents of the Teams table after the table has been loaded. To execute the script, you go to your command line and execute this command: mysql NFL -u yourid -p < Create_Teams.sql > Create_Teams.out Supply your password when you are prompted for it. The output from the script will be written to a file called 'Create_Teams.out'. If you imitate the techniques shown in this note, you should be in business. Rhino -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]