Oracle
 sql >> Teknologi Basis Data >  >> RDS >> Oracle

Apakah ada cara lain untuk membuat batasan selama pembuatan tabel SQL?

Anda dapat melakukannya dengan membuat skema pernyataan:

create schema authorization [schema name]
create table department 
(   code      varchar2(3) primary key,
    name      varchar2(40)  not null,
    chair     varchar2(11),
    constraint departmentChairFk foreign key(chair) references facultyStaff(staffId) on delete set null
)
create table facultyStaff 
(   staffID     varchar2(5) primary key,
    dob     date,
    firstName   varchar2(20),
    lastName    varchar2(20),
    rank        varchar2(10),
    deptCode    varchar2(3),
    constraint rankValue check (rank in ('Assistant', 'Associate', 'Full', 'Emeritus')),
    constraint facultyDeptFk foreign key (deptCode) references department (code)
)
create table student 
(   studentId   varchar2(5) primary key,
    dob     date ,
    firstName   varchar2(20),
    lastName    varchar2(20),
    status      varchar(10),
    major       varchar(3),
constraint statusValue check (status in ('Freshman', 'Sophomore', 'Junior', 'Senior',  'Graduate')),
    constraint studentMajorFk foreign key (major) references department (code)
);



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Bagaimana Cara Memasukkan File di Database Oracle?

  2. Fungsi NUMTODSINTERVAL() di Oracle

  3. Pengantar PL/SQL VARRAYs Di Oracle Database

  4. ORA-04091:tabel xx_xx bermutasi, pemicu/fungsi mungkin tidak melihatnya

  5. Format TANGGAL default Oracle