日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

oracle数据库从入门到精通之三

發布時間:2025/3/18 数据库 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle数据库从入门到精通之三 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

綜合案例
ddl&dml
有一個商品數據庫
1.數據表的創建?? ?ddl

先編寫數據庫腳本
--刪除數據表
drop table purcase purge;
drop table product purge;
drop table customer purge;
--創建數據表
create table product(
?? ?product_id varchar2(5),
?? ?product_name varchar2(30) not null,
?? ?unit_price number,
?? ?category varchar2(50),
?? ?provider varchar2(50),
?? ?constraint pk_product_id primary key(product_id),
?? ?constraint ck_unit_price check(unit_price>0)
);
create table customer(
?? ?customer_id varchar2(5),
?? ?customer_name varchar2(30) not null,
?? ?location varchar2(50),
?? ?constraint pk_customer_id primary key(customer_id)
);
create table purcase(
?? ?customer_id varchar2(5),
?? ?product_id varchar2(5),
?? ?quantity number,
?? ?constraint fk_customer_id foreign key(customer_id) references customer(customer_id) on delete cascade,
?? ?constraint fk_product_id foreign key(product_id) references product(product_id) on delete cascade,
?? ?constraint ck_quantity check(quantity)
);

--增加測試數據
--增加產品信息
insert into product(product_id,product_name,unit_price,category,provider)
values('M01','jjs',8.00,'yg','bj');
insert into product(product_id,product_name,unit_price,category,provider)
values('M02','glj',6.50,'yg','glj');
insert into product(product_id,product_name,unit_price,category,provider)
values('M03','jl',5.00,'yg','lhlh');
insert into product(product_id,product_name,unit_price,category,provider)
values('M04','sfj',3.00,'xz','bj');
insert into product(product_id,product_name,unit_price,category,provider)
values('M05','xsl',5.00,'xz','lhlh');
insert into product(product_id,product_name,unit_price,category,provider)
values('M06','dp',2.50,'xyf','nas');
insert into product(product_id,product_name,unit_price,category,provider)
values('M07','zh',3.50,'yg','lhlh');
insert into product(product_id,product_name,unit_price,category,provider)
values('M08','tz',3.00,'xyf','bj');
insert into product(product_id,product_name,unit_price,category,provider)
values('M09','bl',4.00,'xyf','bj');
--增加客戶信息
insert into customer(customer_id,customer_name,location)
values('C01','Dennis','hd');
insert into customer(customer_id,customer_name,location)
values('C02','John','cy');
insert into customer(customer_id,customer_name,location)
values('C03','Tom','dc');
insert into customer(customer_id,customer_name,location)
values('C04','Jenny','dc');
insert into customer(customer_id,customer_name,location)
values('C05','Rick','xc');
--增加購買記錄
insert into purcase(customer_id,product_id,quantity)
values('C01','M01',3);
insert into purcase(customer_id,product_id,quantity)
values('C01','M05',2);
insert into purcase(customer_id,product_id,quantity)
values('C01','M08',2);
insert into purcase(customer_id,product_id,quantity)
values('C02','M02',5);
insert into purcase(customer_id,product_id,quantity)
values('C02','M06',4);
insert into purcase(customer_id,product_id,quantity)
values('C03','M01',1);
insert into purcase(customer_id,product_id,quantity)
values('C03','M05',1);
insert into purcase(customer_id,product_id,quantity)
values('C03','M06',3);
insert into purcase(customer_id,product_id,quantity)
values('C03','M08',1);
insert into purcase(customer_id,product_id,quantity)
values('C04','M03',7);
insert into purcase(customer_id,product_id,quantity)
values('C04','M04',3);
insert into purcase(customer_id,product_id,quantity)
values('C05','M06',2);
insert into purcase(customer_id,product_id,quantity)
values('C05','M07',8);
commit;

轉載于:https://www.cnblogs.com/createyuan/p/6209192.html

總結

以上是生活随笔為你收集整理的oracle数据库从入门到精通之三的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。