Kursus dan belajar komputer ms office, digital marketing, web programming, jaringan, linux, windows server, php, vb.net, mysql, mikrotik, seo, web desain, wordpress, cysco, database, oracle di cileungsi


Postingan Terbaru

Info Kursus Komputer YMII Cileungsi : 0858 8188 5768 (Mas Tris)

Selasa, 04 Juni 2024

Syntak dan E-book MySQL Dasar Part 1 - Rumah Belajar Komputer YMII & Universitas Safin Pati

 Bismillah..

Berikut Syntak dan E-book MySQL Dasar Part 1 - Rumah Belajar Komputer YMII & Universitas Safin Pati

Catatan Sintak:


Masuk ke mysql melalui cmd:


C:\Users\user>cd c://

c:\>cd xampp

c:\xampp>cd mysql

c:\xampp\mysql>cd bin

c:\xampp\mysql\bin>mysql -u root


melihat isi database:

show databases;


membuat database:

CREATE DATABASE latihansaya;


masuk kedalam database:

use latihansaya;


membuat tabel:

 CREATE TABLE mahasiswa (

    NIM CHAR(9),

    Nama VARCHAR(30),

    Password VARCHAR(30));


Melihat data ditabel mahasiswa:


DESC mahasiswa;

+----------+-------------+------+-----+---------+-------+

| Field    | Type        | Null | Key | Default | Extra |

+----------+-------------+------+-----+---------+-------+

| NIM      | char(9)     | YES  |     | NULL    |       |

| Nama     | varchar(30) | YES  |     | NULL    |       |

| Password | varchar(30) | YES  |     | NULL    |       |

+----------+-------------+------+-----+---------+-------+


INSERT INTO mahasiswa VALUES ('101','Sutrisno','1234');

Query OK, 1 row affected (0.063 sec)


MariaDB [latihansaya]> select * from mahasiswa;

+------+----------+----------+

| NIM  | Nama     | Password |

+------+----------+----------+

| 101  | Sutrisno | 1234     |

+------+----------+----------+

1 row in set (0.001 sec)


MariaDB [latihansaya]> INSERT INTO mahasiswa VALUES ('102','nn','1234'),('103','kk','1234');

Query OK, 2 rows affected (0.003 sec)

Records: 2  Duplicates: 0  Warnings: 0


MariaDB [latihansaya]> select * from mahasiswa;

+------+----------+----------+

| NIM  | Nama     | Password |

+------+----------+----------+

| 101  | Sutrisno | 1234     |

| 102  | nn       | 1234     |

| 103  | kk       | 1234     |

+------+----------+----------+

3 rows in set (0.001 sec)


MariaDB [latihansaya]> UPDATE mahasiswa SET Nama='Ronaldo' WHERE Nama='nn';

Query OK, 1 row affected (0.003 sec)

Rows matched: 1  Changed: 1  Warnings: 0


MariaDB [latihansaya]> select * from mahasiswa;

+------+----------+----------+

| NIM  | Nama     | Password |

+------+----------+----------+

| 101  | Sutrisno | 1234     |

| 102  | Ronaldo  | 1234     |

| 103  | kk       | 1234     |

+------+----------+----------+

3 rows in set (0.001 sec)


MariaDB [latihansaya]> UPDATE mahasiswa SET Nama='Kaka' WHERE Nama='kk';

Query OK, 1 row affected (0.002 sec)

Rows matched: 1  Changed: 1  Warnings: 0


MariaDB [latihansaya]> select * from mahasiswa;

+------+----------+----------+

| NIM  | Nama     | Password |

+------+----------+----------+

| 101  | Sutrisno | 1234     |

| 102  | Ronaldo  | 1234     |

| 103  | Kaka     | 1234     |

+------+----------+----------+

3 rows in set (0.001 sec)


MariaDB [latihansaya]> DELETE FROM mahasiswa WHERE Nama='Kaka';

Query OK, 1 row affected (0.004 sec)


MariaDB [latihansaya]> select * from mahasiswa;

+------+----------+----------+

| NIM  | Nama     | Password |

+------+----------+----------+

| 101  | Sutrisno | 1234     |

| 102  | Ronaldo  | 1234     |

+------+----------+----------+

2 rows in set (0.000 sec)


MariaDB [latihansaya]> TRUNCATE TABLE mahasiswa;

Query OK, 0 rows affected (0.038 sec)


MariaDB [latihansaya]> select * from mahasiswa;

Empty set (0.004 sec)


MariaDB [latihansaya]> DESC mahasiswa;

+----------+-------------+------+-----+---------+-------+

| Field    | Type        | Null | Key | Default | Extra |

+----------+-------------+------+-----+---------+-------+

| NIM      | char(9)     | YES  |     | NULL    |       |

| Nama     | varchar(30) | YES  |     | NULL    |       |

| Password | varchar(30) | YES  |     | NULL    |       |

+----------+-------------+------+-----+---------+-------+

3 rows in set (0.011 sec)


MariaDB [latihansaya]> DROP TABLE mahasiswa;

Query OK, 0 rows affected (0.008 sec)


MariaDB [latihansaya]> DESC mahasiswa;

ERROR 1146 (42S02): Table 'latihansaya.mahasiswa' doesn't exist

MariaDB [latihansaya]> DROP DATABASE latihansaya;

Query OK, 0 rows affected (0.027 sec)



E-Book belajar MySQL Part 1 bisa di download disini


kursus belajar basis data


Tidak ada komentar:

Posting Komentar