Constraint table in database

Hal yang sepele tapi kadang membingungkan….. mungkin seperti hal tentang constrain tabel ini…. bagi yang belum kenal mungkin bingung arti dari kata itu apa,,tapi sebenarnya kita sering menggunakannya,. berikut ini sekilas penjelasan tentang constrain…. semoga bermanfaat…

Constraint adalah batasan atau aturan yang ada pada table. Constraint mencegah penghapusan data dari suatu table yang mempunyai keterkaitan dengan table yang lain.

Macam-macam constraint :

  • NOT NULL :

Suatu kolom yang didefinisikan dengan constraint NOT NULL tidak boleh berisi nilai NULL.

  • UNIQUE :

Constraint UNIQUE mendefinisikan suatu kolom menjadi bersifat unik.


Constraint PRIMARY KEY membentuk key yang unik untuk suatu table.


FOREIGN KEY constraint didefinisikan pada suatu kolom yang ada pada suatu table, dimana kolom tersebut juga dimiliki oleh table yang lain sebagai suatu PRIMARY KEY.

  • CHECK :

Constraint CHECK digunakan untuk mendefinisikan suatu kondisi yang harus dipenuhi oleh tiap baris data dalam table.

Untuk Menghapus constraint perintah yang dapat digunakan yaitu “DROP ” :


DROP CONSTRAINT type (column);

Untuk Mengaktifkan constraint perintah yang dapat digunakan yaitu “ENABLE” :


ENABLE CONSTRAINT type (column);

Untuk Mematikan constraint perintah yang dapat digunakan yaitu “DISABLE ” :


DISABLE CONSTRAINT type (column );


12 thoughts on “Constraint table in database

  1. when u become an ordinary people,, that prov that u love yourself, not hate your self..
    human has a unique caracters by their self…. hehehehe 🙂 PeAce..!!!

  2. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You definitely know what youre talking about, why throw away your intelligence on just posting videos to your weblog when you could be giving us something enlightening to read?

  3. Hi, I think your site might be having browser compatibility issues. When I look at your blog site in Ie, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, terrific blog!

  4. Woah! I’m really loving the template/theme of this site. It’s simple, yet effective. A lot of times it’s tough to get that “perfect balance” between usability and visual appearance. I must say that you’ve done a excellent job with this. In addition, the blog loads very fast for me on Internet explorer. Superb Blog!

  5. Greetings from Florida! I’m bored at work so I decided to browse your website on my iphone during lunch break. I enjoy the knowledge you provide here and can’t wait to take a look when I get home. I’m amazed at how fast your blog loaded on my cell phone .. I’m not even using WIFI, just 3G .. Anyhow, good blog!

  6. Greetings! I’ve been following your weblog for some time now and finally got the bravery to go ahead and give you a shout out from Austin Texas! Just wanted to mention keep up the fantastic job!

  7. The very heart of your writing whilst sounding agreeable initially, did not really sit well with me personally after some time. Somewhere within the sentences you managed to make me a believer but just for a very short while. I nevertheless have a problem with your leaps in logic and one might do well to help fill in all those breaks. In the event that you actually can accomplish that, I would surely end up being impressed.

Leave a Reply

Your email address will not be published. Required fields are marked *