当前位置:网站首页>7. Oracle table structure
7. Oracle table structure
2022-07-05 06:28:00 【Cold leaves elegant_】
- Press the list structure to use SQL Sentence creation class,student Two tables .
Class
| Name | data type | constraint | remarks |
|---|---|---|---|
| CNO | NUMBER(2) | Primary key | Class number |
| CNAME | VARCHAR(20) | Class name | |
| NUM | NUMBER(3) | The number of |
Student
| Name | data type | constraint | remarks |
|---|---|---|---|
| SNO | NUMBER(4) | Primary key | Student number |
| SNAME | VARCHAR(10) | only | full name |
| SAGE | NUMBER | Age | |
| SEX | CHAR(2) | Gender | |
| CNO | NUMBER(2) | Class number |
create table class(
cno number(2) primary key,
cname varchar(20),
num number(3)
)
create table student(
sno number(4) primary key,
sname varchar(10),
sage number,
sex char(2),
cno number(2),
unique(sname)
)


- by student Add a delayed foreign key constraint to the table , Its CNO Column reference class Tabular CNO Column .
alter table student
add constraint P_FK foreign key(cno) references class(cno) on delete cascade deferrable

- by student Add a delayed foreign key constraint to the table , Ensure that the value of this list is 0~100 Between .
alter table student
add check (sage between 0 and 100)

- by student Tabular SAGE Add a check constraint to the column , Ensure that the value is “M ” or “F”, And the default value is “M ”.
alter table student modify(sex char(2) default('m'));
alter table student add check(sex in(‘m’,’f’));

- Create a transaction level temporary table and a session level temporary table by using sub queries , Its structure and student The table structure is the same
create global temporary table tran_temp_student on commit delete rows as select * from student;
create global temporary table sess_temp_student on commit preserve rows as select * from student;

- Create a student_range surface ( Column 、 The type and student Columns of the table 、 The same type ), It is divided into three districts according to the age of students , lower than 20 Put the information of year-old students into part1 District , Stored in EXAMPLE Tablespace ;20-30 Years old on part2 District , Store in ORCLTBS1 Tablespace ; Other data are placed in part3 District , Store in ORCLTBS2 Tablespace
create tablespace ORCLTBS1 datafile 'D:\app\Snakewood\oradata\testdba\ORCLTBS1' size 20m;
create tablespace ORCLTBS2 datafile 'D:\app\Snakewood\oradata\testdba\ORCLTBS2' size 20m;
create tablespace EXAMPLE datafile 'D:\app\Snakewood\oradata\testdba\EXAMPLE' size 20m;
create table student_range partition by range(sage)(partition part1 values less than (20) tablespace example,partition part2 values less than(30) tablespace ORCLTBS1,partition part3 values less than(maxvalue) tablespace ORCLTBS2)as select * from student;


- Create a student_list surface ( Column 、 The type and student Columns of the table 、 The same type ), It is divided into two districts according to students' gender
create table student_list
partition by list(sex)
(
partition student_male values('M') tablespace ORCLTBS1,
partition student_female values('F') tablespace ORCLTBS2
) as
select * from student;

- Will save a student information .xls The file is converted to .txt file , according to .txt The structure of the data in the file creates an external table , Realize to .txt Read operation of

边栏推荐
- C Primer Plus Chapter 15 (bit operation)
- LeetCode-61
- NotImplementedError: Cannot convert a symbolic Tensor (yolo_boxes_0/meshgrid/Size_1:0) to a numpy ar
- Daily question 1189 Maximum number of "balloons"
- MySQL怎么运行的系列(八)14张图说明白MySQL事务原子性和undo日志原理
- 求组合数 AcWing 888. 求组合数 IV
- 20220213-CTF MISC-a_ good_ Idea (use of stegsolve tool) -2017_ Dating_ in_ Singapore
- Suppose a bank's ATM machine, which allows users to deposit and withdraw money. Now there is 200 yuan in an account, and both user a and user B have the right to deposit and withdraw money from this a
- MySQL advanced part 1: index
- Find the combination number acwing 887 Find combination number III
猜你喜欢

Day 2 document

Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022

LeetCode-54

MySQL advanced part 1: View

Idea debug failed

Quickly use Amazon memorydb and build your own redis memory database

高斯消元 AcWing 884. 高斯消元解异或線性方程組
![[moviepy] unable to find a solution for exe](/img/0a/4841f53cedc1333654b9443e406f4c.jpg)
[moviepy] unable to find a solution for exe

MPLS experiment

【LeetCode】Easy | 20. Valid parentheses
随机推荐
H5 模块悬浮拖动效果
LeetCode-61
Winter vacation water test 1 Summary
Vant Weapp SwipeCell设置多个按钮
Series of how MySQL works (VIII) 14 figures explain the atomicity of MySQL transactions and the principle of undo logging
Gauss Cancellation acwing 884. Solution d'un système d'équations Xor linéaires par élimination gaussienne
[Gaode map POI stepping pit] amap Placesearch cannot be used
vsCode创建自己的代码模板
C - XOR to all (binary topic)
TypeScript入门
中国剩余定理 AcWing 204. 表达整数的奇怪方式
Winter messenger 2
H5 module suspension drag effect
MQClientException: No route info of this topic: type_ topic
Idea debug failed
2022-5-the fourth week daily
区间问题 AcWing 906. 区间分组
MySQL advanced part 1: triggers
MPLS experiment
3. Oracle control file management