当前位置:网站首页>Oracle-数据完整性
Oracle-数据完整性
2022-07-01 00:32:00 【旷世奇才李先生】
工欲善其事必先利其器
文章持续更新,可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。

一、非空约束
not null
1、创建一个学生表,其中有两个字段,第一个字段为id是number类型,第二个字段是name是varchar2类型并且不允许为空。
create table student(
id number,
name varchar2 not null,
)
二、唯一约束
unique
1、创建一个学生表,其中有两个字段,第一个字段为id是number类型,第二个字段是name是varchar2类型并且不允许重复。
复制表其实就是用来备份表的
create table student(
id number,
name varchar2 unique,
)
三、主键约束
1、创建一个学生表,其中有两个字段,第一个字段为id是number类型并且为主键,第二个字段是name是varchar2类型并且不允许为空。
create table student(
id number,
name varchar2 not null,
constraint pk_id primary key(id);
四、复合主键约束
1、创建一个学生表,其中有两个字段,第一个字段为id是number类型,第二个字段是name是varchar2类型,并将两个字段设置成复合主键约束。
create table student(
id number,
name varchar2,
constraint pk_id primary key(id,name);
五、检查约束
1、创建一个学生表,其中有两个字段,第一个字段为id是number类型并且为主键,第二个字段是name是varchar2类型,第三个是age是number类型,并且age在0-100之间。
create table student(
id number,
name varchar2,
age number,
constraint pk_id primary key(id),
constraint ck_age check(age between 0 and 100);
六、外键约束
1、创建一个学生表,其中有一个字段,第一个字段为id是number类型并且为主键,再创建一个老师表,其中有两个字段,第一个字段为id是number类型,第二个字段为sid并且为学生表id的外键
create table student(
id number,
constraint pk_id primary key(id);
create table teacher(
id number,
sid number
constraint fk_sid foreign key(sid) references student(id);
七、修改约束
1、将学生表student增加主键id的约束
alter table student add constraint pk_id primary key(id);
2、将学生表student的name字段修改为非空约束
alter table student modify(name varchar2 not null);
八、总结
这里的相关内容还没有整理完毕,文章后面持续更新,建议收藏。
文章中涉及到的命令大家一定要像我一样每个都敲几遍,只有在敲的过程中才能发现自己对命令是否真正的掌握了。
可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
- Solving the weird problem that the query conditions affect the value of query fields in MySQL query
- 在指南针上买基金安全吗?
- 2022-2028 global herbal diet tea industry research and trend analysis report
- 网上开华泰证券的股票账户是否安全呢?
- The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
- Ybtoj exchange game [tree chain splitting, line segment tree merging]
- NATs cluster deployment
- CentOS installation starts redis
- How to specify the number of cycles in JSTL- How to loop over something a specified number of times in JSTL?
- 需求评审,测试人员应该发挥怎样的价值?两分钟让你不再懵逼
猜你喜欢

Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)

20220216 misc buuctf backdoor killing (d shield scanning) - clues in the packet (Base64 to image)

2022-2028 global single travel industry research and trend analysis report

Line number of Jenkins pipeline script execution exception

The full technology stack, full scene and full role cloud native series training was launched to help enterprises build a hard core cloud native technology team

Combining online and offline, VR panorama is a good way to transform furniture online!

Software supply chain security risk pointing North for enterprise digitalization and it executives

2022-2028 global ethylene oxide scrubber industry research and trend analysis report

Software engineering best practices - project requirements analysis

Analysis of 8253a register
随机推荐
2022-06-30:以下golang代码输出什么?A:0;B:2;C:运行错误。 package main import “fmt“ func main()
Vmware16 installing win11 virtual machine (the most complete step + stepping on the pit)
File reading and writing for rust file system processing - rust Practice Guide
[UML] UML class diagram
SSM integration process (integration configuration, function module development, interface test)
Wordpress blog uses volcano engine veimagex for static resource CDN acceleration (free)
Teach you how to use Hal library to get started -- become a lighting master
Rust book materials - yazhijia Library
2022-2028 global rotary transmission system industry research and trend analysis report
20220215-ctf-misc-buuctf-einstein-binwalk analyze picture-dd command separate zip file -- look for password in picture attribute
Tide - rust web framework based on async STD
ABAQUS 2022 latest edition - perfect realistic simulation solution
Bugku CTF daily one question dark cloud invitation code
left join左连接匹配数据为NULL时显示指定值
Matlab saves triangulation results as STL files
2022-2028 global ultra high purity electrolytic iron powder industry research and trend analysis report
Software engineering best practices - project requirements analysis
The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
What SQL statements are supported for data filtering
Kubernetes ---- pod configuration container start command