Perintah dasar mysql

Kita ketemu lagi di blog semukan.
kali ini blog semukan aka shere mengenai Perintah dasar mysql, tutorial kali ini hanya di peruntukkan bagi teman-teman yang beru belajar membuat database menggunakan mysql. yang dimana dalam tutorial kali ini blog semukan hanya memberikan beberapa perintah dasar yang sering diguanakan bagi pemula di dunia mysql. (lihat: pengertian mysql)

MySQL adalah sebuah perangkat lunak manajemen database open source yang membantu pengguna menyimpan, mengatur, dan mengambil data.  (lihat: Tipe data pada database mysql)
Perintah dasar mysql
 Dalam bahasa SQL pada umumnya informasi tersimpan dalam tabel-tabel yang secara logik merupakan struktur dua dimensi terdiri dari baris (row atau record) dan kolom(column atau field). Sedangkan dalam sebuah database dapat terdiri dari beberapa table. (lihat: Perintah DDL, DML dan DCL pada Mysql)

Adapun printah dasar mysql yaitu:
1. Masuk ke server MySQL
mysql -u root -p

2. Membuat database
Berikut ini contoh perintah untuk membuat database baru dengan nama “semukan_db”
CREATE DATABASE semukan_db;

3. Menampilakn database
Untuk melihat database yang baru saja dibuat atau yang sudah ada, dapat menggunakan perintah sebagai berikut:
SHOW DATABASES;
haslinya seperti di bawah ini:
mysql> SHOW DATABASES
+--------------------+
|     Database       |
+--------------------+
| semuka_db          |
| Penjualan          |
| Latihan            |
+--------------------+
3 rows in set (0.00 sec)

4. Membuka atau masuk ke dalam database
Sebelum melakukan manipulasi tabel dan record yang berada di dalamnya, kita harus membuka atau mengaktifkan databasenya terlebih dahulu. Untuk membuka database “semukan_db”, berikut ini querynya :
use semukan_db;

5. Menghapus database
Berikut ini contoh perintah untuk menghapus database dengan nama “semukan_db” :
DROP DATABASE semukan_db;

6. Membuat tabel baru
Bentuk umum SQL untuk membuat suatu table secara sederhana sebagai berikut :
CREATE TABLE nama_tabel(field1 tipe(panjang), field2 tipe(panjang));

7. Menampilkan tabel
Perintah di bawah akan menampilkan seluruh tabel yang sudah ada dalam suatu database.
SHOW TABLES;

8. Melihat struktur tabel
DESC merupakan singkatan dari DESCRIBE (dalam query bisa ditulis lengkap atau hanya 4 karakter pertama) dan  nama tabel yang akan dilihat strukturnya. Dari perintah di atas, akan ditampilkan struktur nama_tabel sebagai berikut :
 DESC nama_tabel

9. Mengahpus tabel dengan
Untuk menghapus sebuah tabel, bentuk umum dari perintah SQL adalah sebagai berikut :
DROP TABLE nama_tabel

10. Mengubah nama tabel
Untuk mengubah nama suatu tabel, dapat menggunakan perintah SQL sbb :
RENAME TABLE nama_tabel TO nama_tabel_baru;
ALTER TABLE nama_tabel RENAME to nama_tabel_baru;

11. Menambahkan field ke dalam tabel
ALTER TABLE nama_tabel ADD nama_field_baru tipe;

12. Menambahkan Primary key pada suatu tabel
ALTER TABLE nama_tabel ADD PRIMARY KEY(nama_field);

13. Mengubah tipe field
ALTER TABLE nama_tabel MODIFY nama_field tipe(panjang);

14. Menghapus field
ALTER TABLE nama_tabel DROP nama_field;

15. Mengubah nama tabel
ALTER TABLE nama_tabel ADD nama_field_baru tipe;

Untuk artikel kali ini blog semukan hanya shere 15 perintah dasar mysql, untuk selebihnya teman-teman bisah lihat di artikel selanjutnya..
semogah artikel ini memberikan manfaat bagi teman-teman.

Ditulis Oleh : Unknown

Terimakasi atas kunjungan teman-teman...
Bila artikel ini sangat bermanfaat, sobat dapat bagikan ke teman-teman yang lain melalui jejaring sosila yang ada di bawah ini!!
Jangan lupa tinggalkan komentarnya...
Berbagi di :

BACA JUGA :

3 comments:

  1. makaih ya gan smoga ilmu anda bermfaat bagi bangsa Indonesia

    ReplyDelete
  2. I just gone to the particular courthouse to grab a professional duplicate of my own, personal Divorce Decree there would have been a pair in that room looking a wedding Document, but because his / her divorce, eight in the past wasn't registered appropriately, they were getting all sorts of problems!! Hiring a good attorney is a huge phase therefore it may certainly be a terrifying "no switching back" phase, but when you're positive in which divorce is at your own potential go ahead of time and take the decisive activity to rent the correct divorce attorney.
    virginia divorce attorney
    The idea of finishing one part of their own our life is discouraging, causing considerably hardship and also distress. The very last thing the folks need to handle is the find a divorce attorney. Those who're experiencing the divorce will usually discover that they're dealing with an incredibly tough along with mental situation. Thinking about concluding one particular portion of their life's discouraging, creating significantly hardship along with distress.

    ReplyDelete
  3. Therefore, the 1st step when hiring an Or divorce attorney would be to determine the sort of circumstance you have. Once you complete that, discover individuals that already went through what you will be going through. Considering that the fee where all of us divorce within the Oughout.Azines.A. is about one-half , then chances are you realize several other people who have undergone a divorce match. Question them about their circumstance, how they utilized the Oregon divorce attorney, and the way their own attorney worked out for them.
    divorce lawyers
    Both parties normally need a clear break along with a possibility to go forward from the hurt and frustration. A great attorney will keep the problem professional which help care for crucial issues like custody agreements, resources as well as credit card debt tasks. The actual divorce attorney takes treatment essential paper-work and may carry out their best to give the client a reasonable battle. If you're on a fixed price range, you could still locate an successful attorney.

    ReplyDelete