Wednesday, November 28, 2012

Create Oracle


· create user belajar identified by oracle;
· grant DBA to belajar;
· connect belajar/oracle;
·  create table GURU(
2  NIG VARCHAR2(32)not null,
3  NAMA VARCHAR2(64)not null,
4  JENIS_KELAMIN CHAR not null,
5  TGL_MASUK DATE,
6  STATUS_PEG CHAR not null,
7  constraint PK_GURU primary key (NIG));
·  create table KELAS(
2  KELAS_ID VARCHAR2(32)not null,
3  KETERANGAN VARCHAR2(64),
4  constraint PK_KELAS primary key(KELAS_ID));
·  create table MATA_PELAJARAN(
2  KODE_MP VARCHAR2(32)not null,
3  NAMA_MP VARCHAR2(64)not null,
4  CREDIT NUMBER not null,
5  constraint PK_MATA_PELAJARAN primary key (KODE_MP));
· SQL> create table MURID(
2  NIS VARCHAR2(32)not null,
3  KELAS_ID VARCHAR2(32)not null,
4  NAMA VARCHAR2(64)not null,
5  TGL_LAHIR DATE not null,
6  JENIS_KELAMIN CHAR not null,
7  ALAMAT VARCHAR2(128)not null,
8  NAMA_ORTU VARCHAR2(64),
9  constraint PK_MURID primary key (NIS),
10  constraint AK_MURID unique (KELAS_ID, NIS),
11  constraint MURID#KELAS_FK foreign key (KELAS_ID)
 12  references KELAS (KELAS_ID));
· SQL> create table ULANGAN (
2  NIS VARCHAR2(32)not null,
3  KODE_MP VARCHAR2(32)not null,
4  UJIAN_KE NUMBER not null,
5  TGL_UJIAN DATE not null,
6  NILAI NUMBER,
7  constraint PK_ULANGAN primary key (NIS, KODE_MP, UJIAN_KE),
 8  constraint ULANGAN#MURID_FK foreign key (NIS)
 9  references MURID (NIS),
 10  constraint ULANGAN#MATA_PELAJARAN_FK foreign key (KODE_MP)
11  references MATA_PELAJARAN (KODE_MP));
· 

No comments: