Hey guys,
Basically we've all been set some crappy databases coursework, where we have to use mysql and jdbc to do some stuff... I've just downloaded mysql 4.1, but im having trouble creating a database and making a table with some stuff in it.
This is an example of a .sql file given on the course website:
Ive saved this as c:\comp2004\library.sql... if i load up the mysql terminal, whack in my password and type:Code:CREATE DATABASE library; USE library; CREATE TABLE T_Reader ( ID INTEGER NOT NULL PRIMARY KEY, LastName VARCHAR ( 20 ) , FirstName VARCHAR ( 20 ) ); CREATE TABLE T_Book ( LibID INTEGER NOT NULL PRIMARY KEY, Title VARCHAR ( 255 ) NOT NULL, Author VARCHAR ( 255 ) NOT NULL, Borrower INTEGER, Out DATE, FOREIGN KEY (Borrower) REFERENCES T_Reader ); CREATE TABLE T_ReadingList ( Date DATE NOT NULL, LibID INTEGER NOT NULL, ID INTEGER NOT NULL, PRIMARY KEY (LibID, ID, Date), FOREIGN KEY (LibID) REFERENCES T_Book, FOREIGN KEY (ID) REFERENCES T_Reader ); INSERT INTO T_BOOK (LibID,Title,Author) VALUES (1, 'Noddy', 'Bylton'); INSERT INTO T_BOOK (LibID,Title,Author) VALUES (2, 'Harry Potter', 'Rowling'); INSERT INTO T_BOOK (LibID,Title,Author) VALUES (3, 'Databases', 'Connolly'); INSERT INTO T_BOOK (LibID,Title,Author) VALUES (4, 'The Mousetrap', 'Christie');
It appears to make the t_reader table, but not the others. WHY!? I cant understand why it doesnt work... is it something to do with using 'windows' end of line characters rather than unix ones (ie because i wrote the file in notepad rather than vim or something?)Code:mysql> source c:\comp2004\library.sql Query OK, 1 row affected (0.00 sec) Database changed Query OK, 0 rows affected (0.00 sec) ERROR 1005 (HY000): Can't create table '.\library\t_book.frm' (errno: 150) ERROR 1005 (HY000): Can't create table '.\library\t_readinglist.frm' (errno: 150 ) ERROR 1146 (42S02): Table 'library.t_book' doesn't exist ERROR 1146 (42S02): Table 'library.t_book' doesn't exist ERROR 1146 (42S02): Table 'library.t_book' doesn't exist ERROR 1146 (42S02): Table 'library.t_book' doesn't exist
help![]()


LinkBack URL
About LinkBacks
Reply With Quote

