建立关联表

--删除表格
drop table detailes_table cascade constraints;

drop table province_table cascade constraints;

drop table user_table cascade constraints;

drop table country_table cascade constraints;


--删除序列
drop sequence user1;
drop sequence deta1;
drop sequence coun1;
drop sequence prov1;
--创建用户序列
create sequence user1
start with 1
increment by 1;
--创建用户表
create table user_table(
id number(6),
name varchar(25),
password varchar(16),

constraint user_table_id_pk primary key(id)
);

--创建国家序列
create sequence coun1
start with 1
increment by 1;
--创建国家表
create table country_table(
id number(6),
name varchar(25),

constraint country_table_id_pk primary key(id)
);

--创建省份序列
create sequence prov1
start with 1
increment by 1;
--创建省份表
create table province_table(
id number(6),
name varchar(25),
country_id number(6),

constraint province_table_id_pk primary key(id),
constraint province_table_country_id_fk foreign key (country_id) references country_table(id)
);

--创建用户详情序列
create sequence deta1
start with 1
increment by 1;
--创建用户详情表格
create table detailes_table(
id number(6),
name varchar(25),
country_id number(6),
province_id number(6),

constraint detailes_table_id_pk primary key(id),
constraint detailes_table_country_id_fk foreign key(country_id) references country_table(id),
constraint detailes_table_province_id_fk foreign key(province_id) references province_table(id)
);
commit;
select * from detailes_table;
select * from user_table;
select * from country_table;
select * from province_table;

转载于:https://www.cnblogs.com/zhang12354/p/7833348.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值