Reply to How do I run an sql file?

Your name:

Reply:


Posted by Tony Peardon on 10/13/10 11:39

I was looking througn the manual, trying to make sence out of all this sql
stuff, when I discovered that I could define my tables in a text file,
rather than typing them at the mysql> prompt. line by line, only to see if
fail because of a simple typo; So I wrote a file. Below is the contents of
my file, included only because I desire comments and corrections. I am
totally new at this, and I don't know if I'm doing it right. The database
the file creates is meant to keep track of people, places, and things. Does
it make any sence to you? Does anything not make sence? Please remember that
I'm still virtually clueless, so don't think twice about stating the ovious,
but thats not really my question. My question is,....

"How do I 'run' this file?"

Now that I've written the file, I can't find where I saw how to run it, and
I can't remember either. I do remember thinking "Oh, Thats so simple", but
that does me no good whatsoever. Please help.

heres my file............

Create Table Person
(
id integer unsigned not null auto_increment,
name integer unsigned not null,
sex enum('Male',Female','Other') not null,
home integer unsigned not null,
location integer unsigned not null,
index(id,home,location),
primary key(id),
foreign key(name) references name(id),
foreign key(home) references place(id),
foreign key(location) references place(id),
on update cascade on delete cascade
);

Create Table Place
(
id integer unsigned not null auto_increment,
name varchar not null,
display boolean default true,
within integer unsigned not null,
index(id,within),
primary key(id),
secondary key(within) references Place(id),
on delete cascade on update cascade
);

Create Table Thing
(
id integer unsigned not null auto_increment,
name varchar not null,
owner integer unsigned null,
location integer unsigned not null,
index(id,owner,location),
primary key(id),
secondary key (owner) references person(id),
secondary key (location) references place(id),
on update cascade on delete cascade
);

Create Table Name
(
id integer unsigned not null auto_increment,
prefix varchar(5) null default '',
first varchar(20) not null,
middle varchar(30) null default '',
last varchar(20) null default '',
suffix varchar(5) null default '',
index(id),
primary key (id)
);

..... end of file.


Thanks in advance,

Tony.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация