Home > OS >  Mysql creating table issue
Mysql creating table issue

Time:03-09

I started learning SQL but just in my first query, failed, i was doing exactly the same as the mentor explaining in the course but somehow his code worked mine not. I also tried this query on PopSql it also did not work. What is wrong here?enter image description here

CodePudding user response:

You need to select the database you are running this query on.

To do this via MySQL Workbench:

Click on the 'Schemas' tab highlighted below:

enter image description here

Then double click on the name of the database you are trying to run the query on, the database name will be bolded once selected.

CodePudding user response:

You need to tell MySQL which database to use:

USE database_name;

before you create a table.

In case the database does not exist, you need to create it as:

CREATE DATABASE database_name;

followed by:

USE database_name;

  • Related