Jonathan Campbell
Jonathan Campbell

Reputation: 33

How do I create a table in mySQL workbench?

Below in the SQL I wrote in mySQL workbench it creates the database fine but will not create the table to hold my products.

DROP DATABASE bamazon_db;
CREATE DATABASE bamazon_db;
USE bamazon_db;
CREATE TABLE products (
item_id(10) AUTO INCREMENT,
product_name,
price,
stock_quantity,
);

Upvotes: 3

Views: 2359

Answers (2)

user149341
user149341

Reputation:

There are two major problems with your CREATE TABLE statement:

  1. None of your columns have types. You must declare a type for each column in the table, e.g. price DECIMAL(5,2).

  2. You have misspelled AUTO_INCREMENT as AUTO INCREMENT.

Upvotes: 1

Mureinik
Mureinik

Reputation: 310993

You're missing the column types:

CREATE TABLE products (
    item_id INT AUTO INCREMENT,
    product_name VARCHAR(100),
    price INT,
    stock_quantity INT
);

Upvotes: 4

Related Questions