Bajardi: Tilakov J. Tekshirdi: Norov M. 2023-2024-yil Mavzu


Mavzu: SQL da INDEXlar yaratish. Ishdan maqsad



Yüklə 34,01 Kb.
səhifə2/3
tarix26.12.2023
ölçüsü34,01 Kb.
#197827
1   2   3
Ma\'lumotlar ba\'zasi 5-amaliy

Mavzu: SQL da INDEXlar yaratish.
Ishdan maqsad: SQL da INDEXlar yaratish bo`yicha ko`nikmaga ega bo`lish.

Masalani qo`yilishi: Berilgan predmet soha ma`lumotlar bazasidagi barcha ob`yektlarni ustida INDEXlar yaratish asosida amallarini bajarish.


Uslubiy ko`rsatmalar: CREATE INDEX ko'rsatmasi jadvallarda indekslarni yaratish uchun ishlatiladi. Indekslar ma'lumotlar bazasidan ma'lumotlarni tezda olish uchun ishlatiladi. Foydalanuvchilar indekslarni ko'ra olmaydilar, ular oddiygina qidirish / so'rovlarni tezlashtirish uchun ishlatiladi.
mysql> create index sam_ind on parvozlar(samalyot);

Query OK, 5 rows affected (0.27 sec)


Records: 5 Duplicates: 0 Warnings: 0
mysql> create index parvoz on parvozlar(samalyot, chiqish);

Query OK, 5 rows affected (0.25 sec)


Records: 5 Duplicates: 0 Warnings: 0
mysql> create index mar_index on parvozlar(marshrut);

Query OK, 5 rows affected (0.19 sec)


Records: 5 Duplicates: 0 Warnings: 0
mysql> show index from parvozlar;

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


| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| parvozlar | 1 | sam_ind | 1 | samalyot | A | 2 | NULL | NULL | YES | BTREE | |
| parvozlar | 1 | parvoz | 1 | samalyot | A | 2 | NULL | NULL | YES | BTREE | |
| parvozlar | 1 | parvoz | 2 | chiqish | A | 2 | NULL | NULL | YES | BTREE | |
| parvozlar | 1 | mar_index | 1 | marshrut | A | 2 | NULL | NULL | YES | BTREE | |
+-----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
4 rows in set (0.06 sec)
mysql> alter table parvozlar drop index sam_ind;

Query OK, 5 rows affected (0.27 sec)


Records: 5 Duplicates: 0 Warnings: 0
mysql> show index from parvozlar;

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


| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| parvozlar | 1 | parvoz | 1 | samalyot | A | 2 | NULL | NULL | YES | BTREE | |
| parvozlar | 1 | parvoz | 2 | chiqish | A | 2 | NULL | NULL | YES | BTREE | |
| parvozlar | 1 | mar_index | 1 | marshrut | A | 2 | NULL | NULL | YES | BTREE | |
+-----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
3 rows in set (0.00 sec)
mysql>

Yüklə 34,01 Kb.

Dostları ilə paylaş:
1   2   3




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin