You are on page 1of 2

Nama : Laura Laurenza

NIM : 2210511006

Microsoft Windows [Version 10.0.22000.978]


(c) Microsoft Corporation. All rights reserved.

C:\Users\ASUS>cd..

C:\Users>cd..

C:\>cd/xampp/mysql/bin

C:\xampp\mysql\bin>mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.24-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database pdb11;


Query OK, 1 row affected (0.006 sec)

MariaDB [(none)]> use pdb11;


Database changed
MariaDB [pdb11]> create table customers(
-> ID INT NOT NULL,
-> NAME VARCHAR(25) NOT NULL,
-> AGE INT NOT NULL,
-> ADDRESS CHAR(25),
-> SALARY DECIMAL(18,2),
-> PRIMARY KEY(ID)
-> );
Query OK, 0 rows affected (0.035 sec)

MariaDB [pdb11]> insert into customers


-> values(1, 'Ramesh', 32, 'Ahmedabad', '2000.00'),
-> (2, 'Khilan', 25, 'Delhi', '1500.00'),
-> (3, 'Kaushik', 23, 'Kota', '2000.00'),
-> (4, 'Chaitali', 25, 'Mumbai', '6500.00'),
-> (5, 'Hardik', 27, 'Bhopal', '8500.00'),
-> (6, 'Komal', 22, 'MP', '4500.00'),
-> (7, 'Muffy', 24, 'Indore', '10000.00');
Query OK, 7 rows affected (0.045 sec)
Records: 7 Duplicates: 0 Warnings: 0

MariaDB [pdb11]> Select *from customers;


+----+----------+-----+-----------+----------+
| ID | NAME | AGE | ADDRESS | SALARY |
+----+----------+-----+-----------+----------+
| 1 | Ramesh | 32 | Ahmedabad | 2000.00 |
| 2 | Khilan | 25 | Delhi | 1500.00 |
| 3 | Kaushik | 23 | Kota | 2000.00 |
| 4 | Chaitali | 25 | Mumbai | 6500.00 |
| 5 | Hardik | 27 | Bhopal | 8500.00 |
| 6 | Komal | 22 | MP | 4500.00 |
| 7 | Muffy | 24 | Indore | 10000.00 |
+----+----------+-----+-----------+----------+
7 rows in set (0.010 sec)

MariaDB [pdb11]> CREATE INDEX idx_AGE


-> ON CUSTOMERS(Age);
Query OK, 0 rows affected (0.021 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [pdb11]> show index from Customers;


+-----------+------------+----------+--------------+-------------+-----------
+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation |
Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-----------+------------+----------+--------------+-------------+-----------
+-------------+----------+--------+------+------------+---------+---------------+
| customers | 0 | PRIMARY | 1 | ID | A |
7 | NULL | NULL | | BTREE | | |
| customers | 1 | idx_AGE | 1 | AGE | A |
7 | NULL | NULL | | BTREE | | |
+-----------+------------+----------+--------------+-------------+-----------
+-------------+----------+--------+------+------------+---------+---------------+
2 rows in set (0.009 sec)

MariaDB [pdb11]> Select(AGE) from customers;


+-----+
| AGE |
+-----+
| 22 |
| 23 |
| 24 |
| 25 |
| 25 |
| 27 |
| 32 |
+-----+
7 rows in set (0.003 sec)

MariaDB [pdb11]> Alter table Customers drop Index idx_Age;


Query OK, 0 rows affected (0.010 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [pdb11]> select(AGE) from customers;


+-----+
| AGE |
+-----+
| 32 |
| 25 |
| 23 |
| 25 |
| 27 |
| 22 |
| 24 |
+-----+
7 rows in set (0.001 sec)

MariaDB [pdb11]>

You might also like