Sabtu, 16 Januari 2010

Contoh bikin data base dengan SQL di MySql

Contoh perintah-perintah SQL di MySql :

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\hasmada>cd\

C:\>cd Appserv

C:\Appserv>cd mysql

C:\apache\mysql>cd bin  //Perintah Masuk Directori Utama

C:\apache\mysql\bin>mysql –u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 3.23.47-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases; // Perintah melihat databse yang ada di MySQL

 
mysql> CREATE DATABASE coba; // Perintah untuk menambah databse yang ada di MySQL

mysql> USE coba; // Perintah untuk mengaktifkan databse coba



 
mysql> CREATE TABLE teman (               // Perintah untuk menambah table pada databse coba
  • id INT(3),
  • nama CHAR(12),
  •     alamat CHAR(16),
  •     umur INT(2),
  •     );

mysql> Show tables;  // Perintah untuk Menampilkan table teman pada databse coba.

mysql> DESCRIBE teman;  // Perintah untuk Menampilkan atribut table teman pada databse coba.