Reputation: 33
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
Reputation:
There are two major problems with your CREATE TABLE
statement:
None of your columns have types. You must declare a type for each column in the table, e.g. price DECIMAL(5,2)
.
You have misspelled AUTO_INCREMENT
as AUTO INCREMENT
.
Upvotes: 1
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