8 Replies - 2242 Views - Last Post: 24 May 2014 - 06:54 PM

#1 SomeMan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 01-April 14

How to modify my .sql program to be working in MySQL Workbench?

Posted 22 May 2014 - 05:17 PM


MySQL Workbench does not import program (code is in the text) .sql
How to modify my program to be imported and working in MySQL Workbench?
Thanks.



CREATE TABLE OrderMain
(
OrderMainID int NOT NULL AUTO_INCREMENT PRIMARY KEY
) ;

CREATE TABLE OrderSub
(
OrderSubID int NOT NULL AUTO_INCREMENT PRIMARY KEY,
OrderMainID int,
ISBN varchar(20),
number int,
FOREIGN KEY (ISBN) References Titles(ISBN),
FOREIGN KEY (OrderMainID) References OrderMain(OrderMainID)
) ;


Is This A Good Question/Topic? 0
  • +

Replies To: How to modify my .sql program to be working in MySQL Workbench?

#2 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6505
  • View blog
  • Posts: 14,362
  • Joined: 02-June 10

Re: How to modify my .sql program to be working in MySQL Workbench?

Posted 22 May 2014 - 05:24 PM

You don't.

You'll have to write an SQL script that performs the same functions.
Was This Post Helpful? 0
  • +
  • -

#3 SomeMan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 01-April 14

Re: How to modify my .sql program to be working in MySQL Workbench?

Posted 22 May 2014 - 05:49 PM

This is for connection with a Java program, but I do not know how to do it.
Was This Post Helpful? 0
  • +
  • -

#4 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6505
  • View blog
  • Posts: 14,362
  • Joined: 02-June 10

Re: How to modify my .sql program to be working in MySQL Workbench?

Posted 23 May 2014 - 05:51 AM

Nobody knows how to do anything until they read and try and learn.

Have you tried anything beyond copy/paste someone else's code then giving up and asking for help?

You can't just come here saying "I don't know how, do it for me". We won't do your research and homework for you.

WHY does this script not work? What errors do you get? Have you tried to re-write the lines that produce errors and fix them? Have you read any of the ABUNDANT mySQL documentation as part of your efforts?

So let's start fresh...

What line produces what error, and show use the variations you've tried to fix it.
Was This Post Helpful? 1
  • +
  • -

#5 SomeMan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 01-April 14

Re: How to modify my .sql program to be working in MySQL Workbench?

Posted 23 May 2014 - 07:21 AM

This is the error. But the file for database Books.sql (in attachment) was uploaded separately.


09:12:24 Restoring C:\Users\Documents\NetBeansProjects\additional.sql

Running: mysql.exe --defaults-extra-file="c:\users\2bc54\appdata\local\temp\tmpkgaxgx.cnf" --host=localhost --user=root --port=3306 --default-character-set=utf8 --comments < "C:\\Users\\Documents\\NetBeansProjects\\additional.sql"

ERROR 1046 (3D000) at line 6: No database selected


Operation failed with exitcode 1

09:12:25 Import of C:\Users\2bc54\Documents\NetBeansProjects\additional.sql has finished with 1 errors
Was This Post Helpful? 0
  • +
  • -

#6 SomeMan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 01-April 14

Re: How to modify my .sql program to be working in MySQL Workbench?

Posted 23 May 2014 - 07:37 AM

This is the database file Books.sql was uploaded separately.
How to connect these files?



DROP DATABASE IF EXISTS books;

CREATE DATABASE books;

USE books;

CREATE TABLE Authors
(
   AuthorID int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   FirstName varchar(30) NOT NULL,
   LastName varchar(30) NOT NULL
)                 ;
CREATE TABLE Titles
(
   ISBN varchar(20) NOT NULL PRIMARY KEY,
   Title varchar(100) NOT NULL,
   EditionNumber int NOT NULL,
   Copyright varchar(4) NOT NULL
)             ;

CREATE TABLE AuthorISBN
(
   AuthorID int NOT NULL,
   ISBN varchar(20) NOT NULL,
   FOREIGN KEY (AuthorID) REFERENCES Authors(AuthorID),
   FOREIGN KEY (ISBN) References Titles(ISBN)
)            ;

INSERT INTO Authors (FirstName,LastName) VALUES ('Harvey','Deitel')           ;
INSERT INTO Authors (FirstName,LastName) VALUES ('Paul','Deitel')     ;
INSERT INTO Authors (FirstName,LastName) VALUES ('Andrew','Goldberg')    ;
INSERT INTO Authors (FirstName,LastName) VALUES ('David','Choffnes')     ;


INSERT INTO Titles (ISBN,Title,EditionNumber,Copyright) VALUES ('0131869000','Visual Basic 2005 How to Program',3,'2006')          ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (1,'0131869000')     ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (2,'0131869000') ;
INSERT INTO Titles (ISBN,Title,EditionNumber,Copyright) VALUES ('0131525239','Visual C# 2005 How to Program',2,'2006')  ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (1,'0131525239')      ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (2,'0131525239')      ;

INSERT INTO Titles (ISBN,Title,EditionNumber,Copyright) VALUES ('0132222205','Java How to Program',7,'2007')   ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (1,'0132222205')                                               ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (2,'0132222205')                                       ;

INSERT INTO Titles (ISBN,Title,EditionNumber,Copyright) VALUES ('0131857576','C++ How to Program',5,'2005')     ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (1,'0131857576')                                                  ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (2,'0131857576')                                                 ;

INSERT INTO Titles (ISBN,Title,EditionNumber,Copyright) VALUES ('0132404168','C How to Program',5,'2007')     ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (1,'0132404168')                                             ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (2,'0132404168')                                       ;

INSERT INTO Titles (ISBN,Title,EditionNumber,Copyright) VALUES ('0131450913','Internet & World Wide Web How to Program',3,'2004')    ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (1,'0131450913')                                                                 ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (2,'0131450913')                                            ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (3,'0131450913')                                   ;

INSERT INTO Titles (ISBN,Title,EditionNumber,Copyright) VALUES ('0131828274','Operating Systems',3,'2004')        ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (1,'0131828274')                                                    ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (2,'0131828274')                                                    ;
INSERT INTO AuthorISBN (AuthorID,ISBN) VALUES (4,'0131828274')                                                    ;



Was This Post Helpful? 0
  • +
  • -

#7 astonecipher  Icon User is offline

  • Too busy for this
  • member icon

Reputation: 2329
  • View blog
  • Posts: 9,359
  • Joined: 03-December 12

Re: How to modify my .sql program to be working in MySQL Workbench?

Posted 23 May 2014 - 10:10 AM

What do you mean connect the files? The file is what it is, what are you trying to do?
Was This Post Helpful? 0
  • +
  • -

#8 tlhIn`toq  Icon User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6505
  • View blog
  • Posts: 14,362
  • Joined: 02-June 10

Re: How to modify my .sql program to be working in MySQL Workbench?

Posted 24 May 2014 - 06:18 PM

Quote

ERROR 1046 (3D000) at line 6: No database selected

No database selected. I don't see how it can be any more clear than that. There are many error codes out there that are almost gibberish, but this isn't one of them.

We've yet to see any of your c# code. Frankly I just think you're wackinig on the keyboard trying to reverse engineer an understanding instead of taking the time to work through some books or tutorials. That never turns out well.

See FAQ # 32 below for a number of links to database tutorials.

TOP most asked:
What does this error message mean?
FAQ 2: How do I debug
FAQ 3: How do I make Class1/Form1 talk to Class2/Form2


FAQ (Frequently Asked Questions - Updated Feb 2014
Spoiler

Was This Post Helpful? 0
  • +
  • -

#9 SomeMan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 01-April 14

Re: How to modify my .sql program to be working in MySQL Workbench?

Posted 24 May 2014 - 06:54 PM

Thanks for the help, I solved this problem by simply inserting the code to Books.sql file.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1