Friday, May 5, 2017

Perintah Membuat Tabel

  No comments

Perintah Membuat Tabel

Membuat tabel di dalam sebuah database
Buatlah tabel Mahasiswa diatas
use contoh_nim 
create table MHS1

(Nim char(10) NOT NULL,

Nama varchar (10) not null,

Alamat varchar (40) NULL,

Telepon Varchar (15),
primary key (nim));

Melihat struktur tabel
DESC nama_tabel;
Atau
DESCRIBE nama_tabel;

Atau
SHOW COLUMNS FROM namatabel; 
Menghapus sebuah Tabel
DROP TABLE nama_tabel; 
Contoh Tabel
Sintaks :
create table Pengajar
(NIP char(10) NOT NULL,
Nama varchar (20) not null,

Tgllhr date null,

Tmplhr varchar (20),

Alamat varchar (30),

Kota varchar (15),

primary key (NIP)); 
Sintaks :
create table Matakuliah
(KdMk Varchar(10) NOT NULL,

Nama_MK Varchar (20) not null,

SKS char (1),

primary key (KdMk)); 
create table Kuliah
(NIP Char(10) NOT NULL,

KdMk Varchar (10) not null,

Ruang Varchar (3),

Jml_Mhs Int (4),

Primary Key (NIP,KdMk),


pengajar (nip),

Foreign Key (kdmk) references

matakuliah (kdmk); 

No comments :

Post a Comment