Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Question!

Status
Not open for further replies.

johnmak

Programmer
Apr 7, 2003
51
GB
I have a file named exampledb.dump which is in the apache\mysql\bin folder and i cant get it to insert the table data into my exampledb database.

I keep getting an error2 message.

in the mysql command i go: use exampledb;

then source C:\apache\mysql\bin\exampledb.dump;

I keep getting an error and i have checked my actual text file 3 times but i will post it below just incase.

CREATE TABLE clients ( id int NOT NULL AUTO_INCREMENT, firstname text, lastname text, userid text, password text, PRIMARY KEY (id), UNIQUE id (id));
INSERT INTO clients VALUES
(1,'Liz','Hall','lhall','sweatpea');
INSERT INTO clients VALUES
(2,'William','Lee','wlee','tulip');
INSERT INTO clients VALUES
(3,'Kevin','Hinds','khinds','daisy');

Any ideas???
 
You should use CHAR(n) for your text fields, or VARCHAR(n) if you want to save space but sacrifice speed. The TEXT type is designed for very large variable-length fields.
 
I'd change this line:

CREATE TABLE clients ( id int NOT NULL AUTO_INCREMENT, firstname text, lastname text, userid text, password text, PRIMARY KEY (id), UNIQUE id (id));

to read:

CREATE TABLE clients ( id int NOT NULL AUTO_INCREMENT [red]PRIMARY KEY[/red], firstname text, lastname text, userid text, [red]passwd[/red] text);


"password" is a MySQL reserved word.

Also, saying that a column is both a primary key column and a unique column is redundant in MySQL. A primary key in MySQL must be unique.


Also, as a general piece of table-constructing advice, I'd use varchar() columns for firstname, lastname, userid, and password. The values in these columns aren't going to be 2GB long, are they?

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top