create table product(
Product_id varchar2(10) not null,
Product_name varchar2(20),
ProductPrice number(8,2),
Quantity number(10),
Category varchar2(10),
Desperation varchar2(1000),
Origin varchar2(10)
);
drop table product;
alter table product
add remark varchar2(200);--增加列remark
alter table product
modify remark number(10,2);--修改列remark datatype
select *from product
alter table product drop column remark;--删除列remark
alter table product add constraints pk_product primary key(Product_id);--主键是由一个列组成
alter table product add constraints pk_product primary key(Product_id,product_name);--主键是由两个列组成
create table categoryinfo(
CategoryId varchar2(10),
CategoryName varchar2(30),
primary key(CategoryId)
);
drop table categoryinfo
alter table product
Drop constraint pk_product
create table productinfo1(
Product_id varchar2(10) not null,
Product_name varchar2(20),
ProductPrice number(8,2),
Quantity number(10),
Category varchar2(10),
Desperation varchar2(1000),
Origin varchar2(10),
primary key(Category),
constraint fk_pro foreign key(category)
references categoryinfo(CategoryId)
);
alter table productinfo1
add Constraint fk_pro foreign key(category)
References categoryinfo(CategoryId);