較有意思的表定義

2021-06-06 13:43:26 字數 3729 閱讀 8368

create table employees

( empno number(4) constraint e_pk primary key

constraint e_empno_chk check (empno > 7000)

, ename varchar2(8) constraint e_name_nn not null

, init varchar2(5) constraint e_init_nn not null

, job varchar2(8)

, mgr number(4) constraint e_mgr_fk references employees

, bdate date constraint e_bdat_nn not null

, msal number(6,2) constraint e_msal_nn not null

, comm number(6,2)

, deptno number(2) default 10

, constraint e_sales_chk check

(decode(job,'salesrep',0,1)

+ nvl2(comm, 1,0) = 1)

) ;

create table departments

( deptno number(2) constraint d_pk primary key

constraint d_deptno_chk check (mod(deptno,10) = 0)

, dname varchar2(10) constraint d_dname_nn not null

constraint d_dname_un unique

constraint d_dname_chk check (dname = upper(dname))

, location varchar2(8) constraint d_loc_nn not null

constraint d_loc_chk check (location = upper(location))

, mgr number(4) constraint d_mgr_fk references employees

) ;

alter table employees add

(constraint e_dept_fk foreign key (deptno) references departments);

listing 7-8. the salgrades table

create table salgrades

( grade number(2) constraint s_pk primary key

, lowerlimit number(6,2) constraint s_lower_nn not null

constraint s_lower_chk check (lowerlimit >= 0)

, upperlimit number(6,2) constraint s_upper_nn not null

, bonus number(6,2) constraint s_bonus_nn not null

, constraint s_lo_up_chk check

(lowerlimit <= upperlimit)

) ;

alter table employees add

(constraint e_dept_fk foreign key (deptno) references departments);

listing 7-8. the salgrades table

create table salgrades

( grade number(2) constraint s_pk primary key

, lowerlimit number(6,2) constraint s_lower_nn not null

constraint s_lower_chk check (lowerlimit >= 0)

, upperlimit number(6,2) constraint s_upper_nn not null

, bonus number(6,2) constraint s_bonus_nn not null

, constraint s_lo_up_chk check

(lowerlimit <= upperlimit)

) ;

create table offerings

( course varchar2(6) constraint o_course_nn not null

constraint o_course_fk references courses

, begindate date constraint o_begin_nn not null

, trainer number(4) constraint o_train_fk references employees

, location varchar2(8)

, constraint o_pk primary key

(course,begindate)

) ;

create table registrations

( attendee number(4) constraint r_att_nn not null

constraint r_att_fk references employees

, course varchar2(6) constraint r_course_nn not null

, begindate date constraint r_begin_nn not null

, evaluation number(1) constraint r_eval_chk check (evaluation in (1,2,3,4,5))

, constraint r_pk primary key

(attendee,course,begindate)

, constraint r_off_fk foreign key (course,begindate)

references offerings

) ;

create table history

( empno number(4) constraint h_empno_nn not null

constraint h_empno_fk references employees

on delete cascade

, beginyear number(4) constraint h_byear_nn not null

, begindate date constraint h_bdate_nn not null

, enddate date

, deptno number(2) constraint h_dept_nn not null

constraint h_dept_fk references departments

, msal number(6,2) constraint h_msal_nn not null

, comments varchar2(60)

, constraint h_pk primary key (empno,begindate)

, constraint h_beg_end check (begindate < enddate)

) ;

函式呼叫棧比較有意思

昨天和海洋一塊研究了下函式呼叫棧,順便寫兩句。不足或錯誤之處請包涵!理解呼叫棧最重要的兩點是 棧的結構,ebp暫存器的作用。首先要認識到這樣兩個事實 2 幾乎所有本地編譯器都會在每個函式體之前插入類似如下指令 push ebp mov ebp esp 棧底方向,高位位址 引數3 引數2 引數1 返回...

函式呼叫棧比較有意思

理解呼叫棧最重要的兩點是 棧的結構,ebp暫存器的作用。首先要認識到這樣兩個事實 2 幾乎所有本地編譯器都會在每個函式體之前插入類似如下指令 push ebp mov ebp esp 棧底方向,高位位址 引數3 引數2 引數1 返回位址 上一層 ebp ebp push ebp mov ebp es...

函式呼叫棧比較有意思

昨天和海洋一塊研究了下函式呼叫棧,順便寫兩句。不足或錯誤之處請包涵!理解呼叫棧最重要的兩點是 棧的結構,ebp暫存器的作用。首先要認識到這樣兩個事實 2 幾乎所有本地編譯器都會在每個函式體之前插入類似如下指令 push ebp mov ebp esp 棧底方向,高位位址 引數3 引數2 引數1 返回...