19.19

contoh mysql1

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

C:\Documents and Settings\Sainstek>cd C:\

C:\>dir
Volume in drive C has no label.
Volume Serial Number is 8009-4AB2

Directory of C:\

03/29/2010 07:22 PM 11,055,640 $Persi0.sys
12/18/2008 05:15 AM 21,806,256 AdbeRdr813_en_US.exe
04/27/2009 09:19 AM 86,352 Animated-Wallpaper-Soft-Shines-3D_1.png
12/27/2009 10:38 AM 24 AUTOEXEC.BAT
04/28/2009 03:56 AM 0 CONFIG.SYS
02/02/2010 10:56 PM

Copy of MATLAB 7.01 CD 1
03/03/2009 02:30 PM 4,646,727 deeffreeze.exe
04/28/2009 04:25 AM 0 dfinstall.log
04/28/2009 04:03 AM Documents and Settings
01/28/2009 03:31 AM 7,430,216 Firefox Setup 3.0.5.exe
12/27/2009 10:40 AM IDAPI32
02/19/2009 08:33 AM 78,460,686 macromedia dreamweaver 8.02.zip
05/15/2009 08:27 PM 213,351 mat.dmp
10/21/2008 04:13 PM 338,483,583 office2003.zip
01/29/2010 10:04 PM oraclexe
01/29/2010 10:08 PM Program Files
02/04/2009 11:28 AM 205,758,254 vb6enterprise.rar
03/29/2010 07:45 PM WINDOWS
03/04/2009 08:13 PM 2,139,086 WRAR4.65.exe
04/28/2009 04:19 AM xampp
02/25/2009 08:44 PM 39,360,061 xampp1.6.8.rar
14 File(s) 709,440,236 bytes
7 Dir(s) 19,326,156,800 bytes free

C:\>xampp
'xampp' is not recognized as an internal or external command,
operable program or batch file.

C:\>cd xampp

C:\xampp>cd mysql

C:\xampp\mysql>cd bin

C:\xampp\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.0.67-community MySQL Community Edition (GPL)

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

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| mysql |
| phpmyadmin |
| test |
| webauth |
+--------------------+
6 rows in set (0.02 sec)

mysql> create database milanisti;
Query OK, 1 row affected (0.00 sec)

mysql> create database milanisti;
ERROR 1007 (HY000): Can't create database 'milanisti'; database exists
mysql> create database milanisti;
ERROR 1007 (HY000): Can't create database 'milanisti'; database exists
mysql> create database aink;
Query OK, 1 row affected (0.00 sec)

mysql> create database aink;
ERROR 1007 (HY000): Can't create database 'aink'; database exists
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| aink |
| cdcol |
| milanisti |
| mysql |
| phpmyadmin |
| test |
| webauth |
+--------------------+
8 rows in set (0.00 sec)

mysql> use aink;
Database changed
mysql> shiw tables;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'shiw
tables' at line 1
mysql> show tables;
Empty set (0.00 sec)

mysql> create table buku (
-> id chaR(5),
-> judul char(50),
-> pengarang char(50),
-> tahun date );
Query OK, 0 rows affected (0.08 sec)

mysql> show table;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
mysql> show tables;
+----------------+
| Tables_in_aink |
+----------------+
| buku |
+----------------+
1 row in set (0.00 sec)

mysql> desc buku;
+-----------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+-------+
| id | char(5) | YES | | NULL | |
| judul | char(50) | YES | | NULL | |
| pengarang | char(50) | YES | | NULL | |
| tahun | date | YES | | NULL | |
+-----------+----------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> alter table buku add penerbit char(50);
Query OK, 0 rows affected (0.13 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc buku;
+-----------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+-------+
| id | char(5) | YES | | NULL | |
| judul | char(50) | YES | | NULL | |
| pengarang | char(50) | YES | | NULL | |
| tahun | date | YES | | NULL | |
| penerbit | char(50) | YES | | NULL | |
+-----------+----------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> alter tabel buku change id id char(5) primary key;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tabel buku change id id char(5) primary key' at line 1
mysql> alter table buku change id id char(5) primary key;
Query OK, 0 rows affected (0.11 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc buku;
+-----------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+-------+
| id | char(5) | NO | PRI | NULL | |
| judul | char(50) | YES | | NULL | |
| pengarang | char(50) | YES | | NULL | |
| tahun | date | YES | | NULL | |
| penerbit | char(50) | YES | | NULL | |
+-----------+----------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> alter table buku drop tahun;
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc buku;
+-----------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+-------+
| id | char(5) | NO | PRI | NULL | |
| judul | char(50) | YES | | NULL | |
| pengarang | char(50) | YES | | NULL | |
| penerbit | char(50) | YES | | NULL | |
+-----------+----------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> drop database aink;
Query OK, 1 row affected (0.17 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| cdcol |
| milanisti |
| mysql |
| phpmyadmin |
| test |
| webauth |
+--------------------+
7 rows in set (0.00 sec)

mysql> create database perpustakaan;
Query OK, 1 row affected (0.00 sec)

mysql> use perpustakaan;
Database changed
mysql> create table anggota(
-> id char(5),
-> nama char(50),
-> alamat char(100),
-> JK char(1),
-> pekerjaan char(20));
Query OK, 0 rows affected (0.03 sec)

mysql> show table;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
mysql> show tables;
+------------------------+
| Tables_in_perpustakaan |
+------------------------+
| anggota |
+------------------------+
1 row in set (0.00 sec)

mysql> desc anggota;
+-----------+-----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-----------+------+-----+---------+-------+
| id | char(5) | YES | | NULL | |
| nama | char(50) | YES | | NULL | |
| alamat | char(100) | YES | | NULL | |
| JK | char(1) | YES | | NULL | |
| pekerjaan | char(20) | YES | | NULL | |
+-----------+-----------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> alter table anggota id id char(5) primary key;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id id char(5) primary key' at line 1
mysql> alter table anggota id id char(5) primary key;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id id char(5) primary key' at line 1
mysql>
mysql> alter table anggota change id id char(5) primary key;
Query OK, 0 rows affected (0.08 sec)
Records: 0 Duplicates: 0 Warnings: 0

mysql> desc anggota;
+-----------+-----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-----------+------+-----+---------+-------+
| id | char(5) | NO | PRI | NULL | |
| nama | char(50) | YES | | NULL | |
| alamat | char(100) | YES | | NULL | |
| JK | char(1) | YES | | NULL | |
| pekerjaan | char(20) | YES | | NULL | |
+-----------+-----------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> insert into anggota values('001','yusuf','ciguruwik','L','mahasiwa');
Query OK, 1 row affected (0.05 sec)

mysql> desc anggota;
+-----------+-----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-----------+------+-----+---------+-------+
| id | char(5) | NO | PRI | NULL | |
| nama | char(50) | YES | | NULL | |
| alamat | char(100) | YES | | NULL | |
| JK | char(1) | YES | | NULL | |
| pekerjaan | char(20) | YES | | NULL | |
+-----------+-----------+------+-----+---------+-------+
5 rows in set (0.00 sec)

mysql> show tables;
+------------------------+
| Tables_in_perpustakaan |
+------------------------+
| anggota |
+------------------------+
1 row in set (0.02 sec)

mysql> insert into anggota values('021','sena','PB','L','mahasiwa');
Query OK, 1 row affected (0.00 sec)

mysql> insert into anggota values('002','aink','suka senang','L','mahasiwa');
Query OK, 1 row affected (0.00 sec)

mysql> insert into anggota values('003','aku','suka senang','L','mahasiwa');
Query OK, 1 row affected (0.00 sec)

mysql> insert into anggota values('004','diriku','suka senang','L','mahasiwa');
Query OK, 1 row affected (0.00 sec)

mysql> insert into anggota values('005','the girl','suka senang','P','mahasiwa');
Query OK, 1 row affected (0.00 sec)

mysql> select*from anggota;
+-----+----------+-------------+------+-----------+
| id | nama | alamat | JK | pekerjaan |
+-----+----------+-------------+------+-----------+
| 001 | yusuf | ciguruwik | L | mahasiwa |
| 021 | sena | PB | L | mahasiwa |
| 002 | aink | suka senang | L | mahasiwa |
| 003 | aku | suka senang | L | mahasiwa |
| 004 | diriku | suka senang | L | mahasiwa |
| 005 | the girl | suka senang | P | mahasiwa |
+-----+----------+-------------+------+-----------+
6 rows in set (0.02 sec)

mysql> alter table anggota change jk gender char(20);
Query OK, 6 rows affected (0.05 sec)
Records: 6 Duplicates: 0 Warnings: 0

mysql> select*from anggota;
+-----+----------+-------------+--------+-----------+
| id | nama | alamat | gender | pekerjaan |
+-----+----------+-------------+--------+-----------+
| 001 | yusuf | ciguruwik | L | mahasiwa |
| 021 | sena | PB | L | mahasiwa |
| 002 | aink | suka senang | L | mahasiwa |
| 003 | aku | suka senang | L | mahasiwa |
| 004 | diriku | suka senang | L | mahasiwa |
| 005 | the girl | suka senang | P | mahasiwa |
+-----+----------+-------------+--------+-----------+
6 rows in set (0.00 sec)

mysql> select nama, alamat from anggota;
+----------+-------------+
| nama | alamat |
+----------+-------------+
| yusuf | ciguruwik |
| sena | PB |
| aink | suka senang |
| aku | suka senang |
| diriku | suka senang |
| the girl | suka senang |
+----------+-------------+
6 rows in set (0.02 sec)

mysql>

0 komentar:

Posting Komentar