Guruh Talabasi: n o X



Download 67,34 Kb.
Pdf ko'rish
bet2/6
Sana24.01.2022
Hajmi67,34 Kb.
#408063
1   2   3   4   5   6
Bog'liq
Lab-2

Jadval 1: Kitoblar. 

CREATE   TABLE   Kitoblar

(A_ID int(10) not null primary

key, 


Nomi varchar(20), 


Muallif varchar(20), 

Nashr_nomi varchar(20), 

Nashr_yili year, 

Soni int(5),

Narxi Float(8.2)); 

Jadval 2: Xodimlar. 

CREATE TABLE Xodimlar

(X_ID int(8) not null primary key, 

Fam varchar(20),  

Ism varchar(20),  

Ota_ism varchar(20),  

Lavozimi char(20), 

Staj int(4),

Maoshi float);

Jadval 3: O’quvchilar. 

CREATE TABLE Oquvchilar

(X_ID int(8) not null primary key, 

Fam varchar(20),  

Ism varchar(20),  

Ota_ism varchar(20),  

Pass_Ma char(20), 

Manzili char (4),

Tel_nomeri char(12));

Jadval 4: Kitob_berish. 

CREATE TABLE 



Kitob_berish

 

(K_ID int(8) not null ,



X_id int(8) not null,  

O_id int(8) not null,  




Ber_sana date,

Muddat_Kun int(8),

Jarima float,

Foreign key (K_id) references kitoblar(K_id),

Foreign key (X_id) references Xodimlar(X_id),

Foreign key (O_id) references Oquvchilar(O_id));

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.1.51-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free

software,

and you are welcome to modify and redistribute it under the GPL v2 license

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

mysql> Create database Kutubxona;

Query OK, 1 row affected (0.03 sec)

mysql> show databases;

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

| Database           |

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

| information_schema |

| kutubxona          |



| mysql              |

| test               |

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

4 rows in set (0.00 sec)

mysql> use kutubxona;

Database changed

mysql> CREATE TABLE Kitoblar  (A_ID int(10) not null primary key,

    -> Nomi varchar(20),

    -> Muallif varchar(20),

    -> Nashr_nomi varchar(20),

    -> Nashr_yili year,

    -> Soni int(5),

    -> Narxi Float(8.2);

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 7


mysql> CREATE TABLE Kitoblar  (A_ID int(10) not null primary key,

    -> Nomi varchar(20),

    -> Muallif varchar(20),

    -> Nashr_nomi varchar(20),

    -> Nashr_yili year,

    -> Soni int(5),

    -> Narxi Float(8.2));

Query OK, 0 rows affected (0.11 sec)

mysql> desc kitoblar;



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

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

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

| A_ID       | int(10)     | NO   | PRI | NULL    |       |

| Nomi       | varchar(20) | YES  |     | NULL    |       |

| Muallif    | varchar(20) | YES  |     | NULL    |       |

| Nashr_nomi | varchar(20) | YES  |     | NULL    |       |

| Nashr_yili | year(4)     | YES  |     | NULL    |       |

| Soni       | int(5)      | YES  |     | NULL    |       |

| Narxi      | float       | YES  |     | NULL    |       |

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

7 rows in set (0.02 sec)

mysql>

mysql> CREATE TABLE Xodimlar



    -> (X_ID int(8) not null primary key,

    -> Fam varchar(20),

    -> Ism varchar(20),

    -> Ota_ism varchar(20),

    -> Lavozimi char(20),

    -> Staj int(4),

    -> Maoshi float);

Query OK, 0 rows affected (0.09 sec)

mysql> desc xodimlar;

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




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

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

| X_ID     | int(8)      | NO   | PRI | NULL    |       |

| Fam      | varchar(20) | YES  |     | NULL    |       |

| Ism      | varchar(20) | YES  |     | NULL    |       |

| Ota_ism  | varchar(20) | YES  |     | NULL    |       |

| Lavozimi | char(20)    | YES  |     | NULL    |       |

| Staj     | int(4)      | YES  |     | NULL    |       |

| Maoshi   | float       | YES  |     | NULL    |       |

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

7 rows in set (0.02 sec)

mysql> CREATE TABLE O’quvchilar

    '> (X_ID int(8) not null primary key,

    '> Fam varchar(20),

    '> Ism varchar(20),

    '> Ota_ism varchar(20),

    '> Pass_Ma char(20),

    '> Manzili char (4),

    '> Tel_nomeri char(12));

    '>


    '> ';

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

''quvchilar

(X_ID int(8) not null primary key,

Fam varchar(20),




Ism varchar(20' at line 1

mysql> CREATE TABLE Oquvchilar

    -> (X_ID int(8) not null primary key,

    -> Fam varchar(20),

    -> Ism varchar(20),

    -> Ota_ism varchar(20),

    -> Pass_Ma char(20),

    -> Manzili char (4),

    -> Tel_nomeri char(12));

Query OK, 0 rows affected (0.09 sec)

mysql> desc oquvchilar;

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

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

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

| X_ID       | int(8)      | NO   | PRI | NULL    |       |

| Fam        | varchar(20) | YES  |     | NULL    |       |

| Ism        | varchar(20) | YES  |     | NULL    |       |

| Ota_ism    | varchar(20) | YES  |     | NULL    |       |

| Pass_Ma    | char(20)    | YES  |     | NULL    |       |

| Manzili    | char(4)     | YES  |     | NULL    |       |

| Tel_nomeri | char(12)    | YES  |     | NULL    |       |

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

7 rows in set (0.02 sec)

mysql> CREATE TABLE Kitob_berish




    -> (K_ID int(8) not null ,

    -> X_id int(8) not null,

    -> O_id int(8) not null,

    -> Ber_sana date,

    -> Muddat_Kun int(8),

    -> Jarima float,

    -> Foreign key (K_id) references kitoblar(K_id),

    -> Foreign key (X_id) references Xodimlar(X_id),

    -> Foreign key (O_id) references Oquvchilar(O_id));

ERROR 1005 (HY000): Can't create table 'kutubxona.kitob_berish' (errno: 150)

mysql>

mysql> Foreign key (O_id) references Oquvchilar(O_id));



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

'Foreign key (O_id) references Oquvchilar(O_id))' at line 1

mysql> CREATE TABLE Kitob_berish

    -> (K_ID int(8) not null ,

    -> X_id int(8) not null,

    -> O_id int(8) not null,

    -> Ber_sana date,

    -> Muddat_Kun int(8),

    -> Jarima float,

    -> Foreign key (K_id) references kitoblar(K_id);

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 8


mysql> show tables;


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

| Tables_in_kutubxona |

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

| kitoblar            |

| oquvchilar          |

| xodimlar            |

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

3 rows in set (0.00 sec)

mysql> desc kitoblar;

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

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

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

| A_ID       | int(10)     | NO   | PRI | NULL    |       |

| Nomi       | varchar(20) | YES  |     | NULL    |       |

| Muallif    | varchar(20) | YES  |     | NULL    |       |

| Nashr_nomi | varchar(20) | YES  |     | NULL    |       |

| Nashr_yili | year(4)     | YES  |     | NULL    |       |

| Soni       | int(5)      | YES  |     | NULL    |       |

| Narxi      | float       | YES  |     | NULL    |       |

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

7 rows in set (0.01 sec)

mysql> alter table kitoblar change column a_id  K_id int(8) primary key;

ERROR 1068 (42000): Multiple primary key defined

mysql> alter table kitoblar change column a_id  K_id int(8) ;




Query OK, 0 rows affected (0.23 sec)

Records: 0  Duplicates: 0  Warnings: 0

mysql> desc kitoblar;

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

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

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

| K_id       | int(8)      | NO   | PRI | 0       |       |

| Nomi       | varchar(20) | YES  |     | NULL    |       |

| Muallif    | varchar(20) | YES  |     | NULL    |       |

| Nashr_nomi | varchar(20) | YES  |     | NULL    |       |

| Nashr_yili | year(4)     | YES  |     | NULL    |       |

| Soni       | int(5)      | YES  |     | NULL    |       |

| Narxi      | float       | YES  |     | NULL    |       |

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

7 rows in set (0.03 sec)

mysql> desc Xodimlar;

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

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

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

| X_ID     | int(8)      | NO   | PRI | NULL    |       |

| Fam      | varchar(20) | YES  |     | NULL    |       |

| Ism      | varchar(20) | YES  |     | NULL    |       |

| Ota_ism  | varchar(20) | YES  |     | NULL    |       |

| Lavozimi | char(20)    | YES  |     | NULL    |       |




| Staj     | int(4)      | YES  |     | NULL    |       |

| Maoshi   | float       | YES  |     | NULL    |       |

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

7 rows in set (0.02 sec)

mysql> desc Oquvchilar;

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

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

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

| X_ID       | int(8)      | NO   | PRI | NULL    |       |

| Fam        | varchar(20) | YES  |     | NULL    |       |

| Ism        | varchar(20) | YES  |     | NULL    |       |

| Ota_ism    | varchar(20) | YES  |     | NULL    |       |

| Pass_Ma    | char(20)    | YES  |     | NULL    |       |

| Manzili    | char(4)     | YES  |     | NULL    |       |

| Tel_nomeri | char(12)    | YES  |     | NULL    |       |

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

7 rows in set (0.02 sec)

mysql> alter table oquvchilar change column X_id  O_id int(8) ;

Query OK, 0 rows affected (0.25 sec)

Records: 0  Duplicates: 0  Warnings: 0

mysql> desc Oquvchilar;

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

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



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

| O_id       | int(8)      | NO   | PRI | 0       |       |

| Fam        | varchar(20) | YES  |     | NULL    |       |

| Ism        | varchar(20) | YES  |     | NULL    |       |

| Ota_ism    | varchar(20) | YES  |     | NULL    |       |

| Pass_Ma    | char(20)    | YES  |     | NULL    |       |

| Manzili    | char(4)     | YES  |     | NULL    |       |

| Tel_nomeri | char(12)    | YES  |     | NULL    |       |

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

7 rows in set (0.03 sec)

mysql> CREATE TABLE Kitob_berish

    -> (K_ID int(8) not null ,

    -> X_id int(8) not null,

    -> O_id int(8) not null,

    -> Ber_sana date,

    -> Muddat_Kun int(8),

    -> Jarima float,

    -> Foreign key (K_id) references kitoblar(K_id),

    -> Foreign key (X_id) references Xodimlar(X_id),

    -> Foreign key (O_id) references Oquvchilar(O_id));

Query OK, 0 rows affected (0.22 sec)

mysql> desc kitob_berish;

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

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




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

| K_ID       | int(8) | NO   | MUL | NULL    |       |

| X_id       | int(8) | NO   | MUL | NULL    |       |

| O_id       | int(8) | NO   | MUL | NULL    |       |

| Ber_sana   | date   | YES  |     | NULL    |       |

| Muddat_Kun | int(8) | YES  |     | NULL    |       |

| Jarima     | float  | YES  |     | NULL    |       |

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

6 rows in set (0.03 sec)

mysql> drop table Kitob_berish;

Query OK, 0 rows affected (0.06 sec)

mysql> show tables;

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

| Tables_in_kutubxona |

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

| kitoblar            |

| oquvchilar          |

| xodimlar            |

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

3 rows in set (0.00 sec)

mysql> CREATE TABLE Kitob_berish

    -> (K_ID int(8) not null ,

    -> X_id int(8) not null,



    -> O_id int(8) not null,

    -> Ber_sana date,

    -> Muddat_Kun int(8),

    -> Jarima float,

    -> Foreign key (K_id) references kitoblar(K_id),

    -> Foreign key (X_id) references Xodimlar(X_id),

    -> Foreign key (O_id) references Oquvchilar(O_id));

Query OK, 0 rows affected (0.19 sec)

mysql> show tables;

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

| Tables_in_kutubxona |

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

| kitob_berish        |

| kitoblar            |

| oquvchilar          |

| xodimlar            |

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

4 rows in set (0.02 sec)

mysql> alter table oquvchilar rename to kitobxonlar;

Query OK, 0 rows affected (0.05 sec)

mysql> show tables;

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

| Tables_in_kutubxona |



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

| kitob_berish        |

| kitoblar            |

| kitobxonlar         |

| xodimlar            |

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

4 rows in set (0.00 sec)

mysql>


mysql> desc kitoblar;

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

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

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

| K_id       | int(8)      | NO   | PRI | 0       |       |

| Nomi       | varchar(20) | YES  |     | NULL    |       |

| Muallif    | varchar(20) | YES  |     | NULL    |       |

| Nashr_nomi | varchar(20) | YES  |     | NULL    |       |

| Nashr_yili | year(4)     | YES  |     | NULL    |       |

| Soni       | int(5)      | YES  |     | NULL    |       |

| Narxi      | float       | YES  |     | NULL    |       |

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

7 rows in set (0.02 sec)

mysql> insert into kitoblar values

    -> (1,'O`tgan kunlar','A.Qodiriy','Yangi avlod','2020',20,45000);

Query OK, 1 row affected (0.03 sec)




mysql> select * from kitoblar;

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

| K_id | Nomi          | Muallif   | Nashr_nomi  | Nashr_yili | Soni | Narxi |

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

|    1 | O`tgan kunlar | A.Qodiriy | Yangi avlod |       2020 |   20 | 45000 |

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

1 row in set (0.00 sec)

mysql>



Download 67,34 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish