Jump to content


Photo

Confused My SQL Student


  • Please log in to reply
1 reply to this topic

#1 wednesdaypixie

wednesdaypixie
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 24 October 2006 - 12:51 PM

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~

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 24 October 2006 - 01:58 PM

What kind of errors? Try putting the SQL in a file and doing the following:

command line: cd directory_to_mysql_bin
command line: ./mysql -uusername -p database_name < path_to_sql_file.sql

Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users