Dastur kodlari mysql> create database masulyatni taqsimlash


Download 24.83 Kb.
Pdf ko'rish
Sana14.11.2023
Hajmi24.83 Kb.
#1773216
Bog'liq
bazaa



dastur kodlari
mysql> create database masulyatni_taqsimlash;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+-----------------------+
| Database |
+-----------------------+
| information_schema |
| idora |
| kutubxona |
| lombard |
| masulyatni_taqsimlash |
| mysql |
| sayohat_kompaniyasi |
| test |
+-----------------------+
8 rows in set (0.00 sec)
mysql> use masulyatni_taqsimlash; 
Database changed mysql> create 
table xodimlar(
-> id int auto_increment primary key,
-> familyasi varchar(100),
-> ismi varchar(100),
-> otasining_ismi varchar(100),
-> ish_haqi int);


Query OK, 0 rows affected (0.02 sec)
mysql> create table ish_turlari(
-> id int auto_increment primary key,
-> tavsif text,
-> kuniga_tolov varchar(100));
Query OK, 0 rows affected (0.01 sec)
mysql> INSERT INTO xodimlar (familyasi, ismi, otasining_ismi, 
ish_haqi)
-> VALUES ('Smith', 'John', 'Michael', 50000);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO ish_turlari (tavsif, kuniga_tolov)
-> VALUES ('Job description for type A', 'Monthly');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO ish (boshlanish_sanasi, tugash_sanasi, ish_turlari_id)
-> VALUES ('2023-11-09', '2023-11-15', 1);
Query OK, 1 row affected (0.00 sec)
mysql> select*from xodimlar;
+----+-----------+------+----------------+----------+
| id | familyasi | ismi | otasining_ismi | ish_haqi |
+----+-----------+------+----------------+----------+
| 1 | Smith | John | Michael | 50000 |
+----+-----------+------+----------------+----------+
1 row in set (0.00 sec)


mysql> select*from ish_turlari;
+----+----------------------------+--------------+
| id | tavsif | kuniga_tolov |
+----+----------------------------+--------------+
| 1 | Job description for type A | Monthly |
+----+----------------------------+--------------+
1 row in set (0.00 sec)
mysql> select*from ish;
+----+-------------------+---------------+----------------+
| id | boshlanish_sanasi | tugash_sanasi | ish_turlari_id |
+----+-------------------+---------------+----------------+
| 1 | 2023-11-09 | 2023-11-15 | 1 |
+----+-------------------+---------------+----------------+
1 row in set (0.00 sec)
mysql> create table ish(
-> id int auto_increment primary key,
-> boshlanish_sanasi date,
-> tugash_sanasi date);
Query OK, 0 rows affected (0.01 sec)
mysql> alter table ish
-> add column ish_turlari_id int,
-> add foreign key (ish_turlari_id) references ish_turlari(id);
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> show tables;


+---------------------------------+
| Tables_in_masulyatni_taqsimlash |
+---------------------------------+
| ish |
| ish_turlari |
| xodimlar |
+---------------------------------+
3 rows in set (0.00 sec)
mysql> desc ish;
+-------------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| boshlanish_sanasi | date | YES | | NULL | |
| tugash_sanasi | date | YES | | NULL | |
| ish_turlari_id | int(11) | YES | MUL | NULL | |
+-------------------+---------+------+-----+---------+----------------+
4 rows in set (0.01 sec)
mysql> desc xodimlar;
+----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| familyasi | varchar(100) | YES | | NULL | |
| ismi | varchar(100) | YES | | NULL | |
| otasining_ismi | varchar(100) | YES | | NULL | |


| ish_haqi | int(11) | YES | | NULL | | +----------------+--------------+------+-----+---------+----
------------+
5 rows in set (0.01 sec)
mysql> desc ish_turlari;
+--------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| tavsif | text | YES | | NULL | |
| kuniga_tolov | varchar(100) | YES | | NULL | |
+--------------+--------------+------+-----+---------+----------------+
3 rows in set (0.01 sec)



Download 24.83 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling