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> show databases;
+--------------------------------------+
| Database |
+--------------------------------------+
| information_schema |
| kafedra |
| kafedra_talabalarining_ozlashtirishi |
| mysql |
| ozlashtirish_korsatgichi |
| talaba_ozlashtirish |
| talabalar_ozlash |
| talabalar_ozlashtirish |
| temiryol_stansiyasi |
| test |
+--------------------------------------+
11 rows in set (0.04 sec)
mysql> use ozlashtirish_korsatgichi;
Database changed
mysql> show tables;
+------------------------------------+
| Tables_in_ozlashtirish_korsatgichi |
+------------------------------------+
| fanlar |
| kafedralar |
| o_k |
| oqituvchilar |
| talabalar |
+------------------------------------+
5 rows in set (0.03 sec)
mysql> select hello world();
+--------------+
| Helloworld() |
+--------------+
| HELLO WORLD |
+--------------+
1 row in set (0.07 sec)
mysql> CREATE FUNCTION plus(a int,b int) RETURNS int DETERMINISTIC BEGIN DECLARE result INT; SET result = a+b; RETURN (result); END//
mysql> CREATE FUNCTION plus(a int,b int) RETURNS int DETERMINISTIC BEGIN DECLARE result INT; SET result = a+b; RETURN (result); END//
ERROR 1304 (42000): FUNCTION plus already exists
mysql> select plus(20,65);
-> //
+-------------+
| plus(20,65) |
+-------------+
| 85 |
+-------------+
1 row in set (0.07 sec)
\d// CREATE FUNCTION minus(a int,b int) RETURNS int DETERMINISTIC BEGIN DECLARE result INT; SET result = a-b; RETURN (result); END//
Query OK, 0 rows affected (0.06 sec)
mysql> select minus(50, 36);
-> //
+---------------+
| minus(50, 36) |
+---------------+
| 14 |
+---------------+
1 row in set (0.00 sec)
/ CREATE FUNCTION bolish(a int,b int) RETURNS int DETERMINISTIC BEGIN DECLARE result INT; SET result = a/b; RETURN (result); END//
Query OK, 0 rows affected (0.00 sec)
mysql> select bolish(100, 4);//
+----------------+
| bolish(100, 4) |
+----------------+
| 25 |
+----------------+
1 row in set (0.00 sec)
\d// CREATE FUNCTION ildizz(a int,b int) RETURNS int DETERMINISTIC BEGIN DECLARE result INT; SET result = sqrt(a*b); RETURN (result); END//
Query OK, 0 rows affected (0.05 sec)
mysql> select ildizz(6,6);//
+-------------+
| ildizz(6,6) |
+-------------+
| 6 |
+-------------+
1 row in set (0.00 sec)
\d// CREATE FUNCTION modul(a int) RETURNS int DETERMINISTIC BEGIN DECLARE result INT; SET result = abs(a); RETURN (result); END//
Query OK, 0 rows affected (0.00 sec)
mysql> select modul(-10);//
+------------+
| modul(-10) |
+------------+
| 10 |
+------------+
1 row in set (0.00 sec)
mysql> select modul(22);//
+-----------+
| modul(22) |
+-----------+
| 22 |
+-----------+
1 row in set (0.00 sec)
mysql> create database triger;
-> ?
Query OK, 1 row affected (0.00 sec)
mysql> use triger?
Database changed
mysql> create table bemorlar
-> (id int auto_increment primery key,
-> Nomi varchar(25),
-> Ketgan_sana date,
-> Kelgan_sana date)?
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 'primery key,
Nomi varchar(25),
Ketgan_sana date,
Kelgan_sana date)' at line 2
mysql> create table Poyezdlar
-> (id int(10),
-> Nomi varchar(25),
-> Ketgan_sana date,
-> Kelgan_sana date)?
Query OK, 0 rows affected (0.01 sec)
mysql> desc loyixalar;?
+-------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| id | int(10) | YES | | NULL | |
| Nomi | varchar(25) | YES | | NULL | |
| Ketgan_sana | date | YES | | NULL | |
| Kelgan_sana | date | YES | | NULL | |
+-------------+-------------+------+-----+---------+-------+
4 rows in set (0.02 sec)
mysql> create trigger bemorlar before insert
-> on shifoxona
-> for each row begin
-> set new.kergan_sana = now();
-> end?
ERROR 1054 (42S22): Unknown column ‘Shifoxona in 'NEW'
mysql> create trigger bemorlar before insert
-> on shifoxona
-> for each row begin
-> set new.ketgan_sana = now();
-> end?
Query OK, 0 rows affected (0.01 sec)
mysql> insert into bemorlar (nomi) values
-> ('sodiqov'),
-> ('axrorov'),
-> ('azizov')?
Query OK, 3 rows affected, 3 warnings (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 3
mysql> select * from bemorlar;
-> ?
+------+-----------+-------------+-------------+
| id | Nomi | Ketgan_sana | Kelgan_sana |
+------+-----------+-------------+-------------+
| NULL | azizov | 2021-12-16 | NULL |
| NULL | axrorov | 2021-12-16 | NULL |
| NULL | sodiqov | 2021-12-16 | NULL |
+------+-----------+-------------+-------------+
3 rows in set (0.00 sec)
mysql>
Do'stlaringiz bilan baham: |