Coding SQL on Mak

By Tristo, 21 March, 2020

Forum
macOS and Mac Apps

Hey does anyone know of any ways I could code SQL on Mak? I need to create a database for one of my assignments for my cource Bachelar of Information technology at JCU.
I have tried MYSQl, however it's not accessible.
Also, if the program could draw database models that would be great.
Any help would be appreciated.

Options

Comments

By mehgcap on Saturday, March 28, 2020 - 23:29

I don't know about GUIs on macOS for SQL, but I do know you can manage this with the command line. I suggest writing the queries in a text editor like Text Edit (with spellchecking disabled), then pasting them in. Once you install MySQL and set up a user and a database, you can run queries against it in Terminal. You can also save your text file as a script, then run that. To get the output, pipe it to a file. For example:

First, assuming your database is myDB, write this in a text editor:

use myDB;
create table if not exists newTable (
id int unsigned auto_increment primary key not null,
name varchar(25) not null
);

Save this as myScript.sql. Be sure to save it as a text file, not a rich text file.

Second, switch over to Terminal and type this:

mysql -u yourUser -p < /path/to/myScript.sql

You're prompted for your MySQL user account's password, and then your script will run.

By Donal on Saturday, March 28, 2020 - 23:29

Hi there, Firstly, I'm not clear what you mean when you say MySQL isn't accessible. If you want to clarify the issues you've been having we might be able to clarify those. Coding SQL can be done using a text-editor. Personally I use TextMate two for this type of thing. As the previous poster said, you can save this as a file and then use the terminal. another utility which you might find useful is Sequel Pro. You can take a look here: Sequel Pro Website Now when you mention database diagrams, what specifically do you mean? There are many many different types of these. Are you referring to ER diagrams or something else? Best of luck with the assignment.