Uploaded by Jaskaran Singh

DDL assign 2

advertisement
create database coffee_store;
use coffee_store;
create table products (
productID int,
Name varchar(255),
Price int NOT NULL,
PRIMARY KEY (productID)
);
create table customers (
customerID int,
First_Name varchar(255),
Last_Name varchar(255),
Gender char,
ContactNumber int,
PRIMARY KEY (customerID),
CHECK (Gender = 'F' OR Gender = 'M')
);
create table orders(
orderID int,
productID int,
customerID int,
DATE_TIME DATETIME,
PRIMARY KEY (orderID),
FOREIGN KEY (productID) REFERENCES products(productID),
FOREIGN KEY (customerID) REFERENCES customers(customerID)
);
show tables; alter table products
add CoffeeOrigin varchar(255);
describe products;
alter table products
drop column CoffeeOrigin;
describe products;
alter table products
add CoffeeOrigin varchar(255);
describe products;
drop table products; #ERROR CODE : 3730
show tables;
alter table products
modify column Price FLOAT; #changing data type of Price
insert into products( productID , Name , Price, CoffeeOrigin)
values(1, 'Espresso', 2.50, 'Brazil');
insert into products( productID , Name , Price, CoffeeOrigin)
values(2, 'Cappuccino', 3.50, 'CostaRica');
select * from products;
delete from products where productID>0;
select * from products;
Download