Jump to content

Archived

This topic is now archived and is closed to further replies.

wednesdaypixie

Confused My SQL Student

Recommended Posts

Hi!  I am completely lost. I am taking a class in Database Fundamentals & we just started using MySQL a few weeks ago. The instructor isn't teaching us how to do the material.  She's just expecting us to learn from reading the textbooks.
For example,

ROP TABLE IF EXISTS `book`;
CREATE TABLE `book` (
  `BOOK_CODE` char(4) NOT NULL default '',
  `TITLE` char(40) default NULL,
  `PUBLISHER_CODE` char(3) default NULL,
  `TYPE` char(3) default NULL,
  `PRICE` decimal(4,2) default NULL,
  `PAPERBACK` char(1) default NULL,
  PRIMARY KEY  (`BOOK_CODE`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `henry`.`book`
--

/*!40000 ALTER TABLE `book` DISABLE KEYS */;
INSERT INTO `book` (`BOOK_CODE`,`TITLE`,`PUBLISHER_CODE`,`TYPE`,`PRICE`,`PAPERBACK`) VALUES
('0180','A Deepness in the Sky','TB','SFI','7.19','Y'),
('0189','Magic Terror','FA','HOR','7.99','Y'),
('0200','The Stranger','VB','FIC','8.00','Y'),
('0280','Rumpole for the Defence','PE','MYS','7.19','Y'),
('0378','Venice','SS','ART','24.50','N'),
('0389','Concepts of Database Management','CT','CMP','43.99','Y'),
('079X','Second Wind','PU','MYS','24.95','N'),
('0808','The Edge','JP','MYS','6.99','Y'),
('1351','Dreamcatcher: A Novel','SC','HOR','19.60','N'),
('1382','Treasure Chests','TA','ART','24.46','N'),
('138X','Beloved','PL','FIC','12.95','Y'),
('1456','Truman','SS','HIS','29.90','Y'),
('2226','Harry Potter and the Prisoner of Azkaban','ST','SFI','13.96','N'),
('2281','Van Gogh and Gauguin','WP','ART','21.00','N'),
('2766','Of Mice and Men','PE','FIC','6.95','Y'),
('2908','Electric Light','FS','POE','14.00','N'),
('3350','Group: Six People in Search of a Life','BP','PSY','10.40','Y'),
('3743','Nine Stories','LB','FIC','5.99','Y');
INSERT INTO `book` (`BOOK_CODE`,`TITLE`,`PUBLISHER_CODE`,`TYPE`,`PRICE`,`PAPERBACK`) VALUES
('3906','The Soul of a New Machine','BY','SCI','11.16','Y'),
('5163','Travels with Charley','PE','TRA','7.95','Y'),
('5790','Catch-22','SC','FIC','12.00','Y'),
('6128','Jazz','PL','FIC','12.95','Y'),
('6328','Band of Brothers','TO','HIS','9.60','Y'),
('669X','A Guide to SQL','CT','CMP','37.95','Y'),
('6908','Franny and Zooey','LB','FIC','5.99','Y'),
('7405','East of Eden','PE','FIC','12.95','Y'),
('7443','Harry Potter and the Goblet of Fire','ST','SFI','18.16','N'),
('7559','The Fall','VB','FIC','8.00','Y'),
('8092','Godel, Escher, Bach','BA','PHI','14.00','Y'),
('8720','When Rabbit Howls','JP','PSY','6.29','Y'),
('9611','Black House','RH','HOR','18.81','N'),
('9627','Song of Solomon','PL','FIC','14.00','Y'),
('9701','The Grapes of Wrath','PE','FIC','13.00','Y'),
('9882','Slay Ride','JP','MYS','6.99','Y'),
('9883','The Catcher in the Rye','LB','FIC','5.99','Y'),
('9931','To Kill a Mockingbird','HC','FIC','18.00','N');
/*!40000 ALTER TABLE `book` ENABLE KEYS */;

How do I enter this into MySQL, in the correct format? I tried entering it into the database, but returned errors instead. Any help is appreciated.  Please point me in the right direction.  Thank you~

Share this post


Link to post
Share on other sites
What kind of errors? Try putting the SQL in a file and doing the following:

[tt][b]command line:[/b] cd [i]directory_to_mysql_bin[/i]
[b]command line:[/b] ./mysql -u[i]username[/i] -p [i]database_name[/i] < [i]path_to_sql_file.sql[/i]
[/tt]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.