Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Setting environment for using XAMPP for Windows.
- nelly@NELLYIVANOVA c:\xampp
- # mysql -uroot
- Welcome to the MariaDB monitor. Commands end with ; or \g.
- Your MariaDB connection id is 16
- Server version: 10.4.21-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 cont;
- Query OK, 1 row affected (0.001 sec)
- MariaDB [(none)]> use cont;
- Database changed
- MariaDB [cont]> create table triangles(
- -> id MEDIUMINT NOT NULL AUTO_INCREMENT,
- -> side1 float(3,2) DEFAULT '0' NOT NULL,
- -> side2 float(3,2) DEFAULT '0' NOT NULL,
- -> side3 float(3,2) DEFAULT '0' NOT NULL);
- ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
- MariaDB [cont]> create table triangles(
- -> PRIMARY KEY id MEDIUMINT NOT NULL AUTO_INCREMENT,
- -> side1 float(3,2) DEFAULT '0' NOT NULL,
- -> side2 float(3,2) DEFAULT '0' NOT NULL,
- -> side3 float(3,2) DEFAULT '0' NOT NULL);
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'MEDIUMINT NOT NULL AUTO_INCREMENT,
- side1 float(3,2) DEFAULT '0' NOT NULL...' at line 2
- MariaDB [cont]>
- MariaDB [cont]> create table triangles(
- -> id INT AUTO_INCREMENT,
- -> side1 float(3,2) DEFAULT '0' NOT NULL,
- -> side2 float(3,2) DEFAULT '0' NOT NULL,
- -> side3 float(3,2) DEFAULT '0' NOT NULL,
- -> primary key(id));
- Query OK, 0 rows affected (0.015 sec)
- MariaDB [cont]> create table types(
- -> id INT NOT NULL,
- -> kind VARCHAR(16),
- -> primary key(id));
- Query OK, 0 rows affected (0.009 sec)
- MariaDB [cont]> INSERT INTO types (id, kind) VALUES("1", "illegal");
- Query OK, 1 row affected (0.017 sec)
- MariaDB [cont]>
- MariaDB [cont]> INSERT INTO types (id, kind) VALUES("2", "equilateral");
- Query OK, 1 row affected (0.002 sec)
- MariaDB [cont]> INSERT INTO types (id, kind) VALUES("3", "isosceles");
- Query OK, 1 row affected (0.008 sec)
- MariaDB [cont]> INSERT INTO types (id, kind) VALUES("4", "scalene");
- Query OK, 1 row affected (0.008 sec)
- MariaDB [cont]> INSERT INTO types (id, kind) VALUES("5", "acute");
- Query OK, 1 row affected (0.002 sec)
- MariaDB [cont]> INSERT INTO types (id, kind) VALUES("6", "obtuse");
- Query OK, 1 row affected (0.008 sec)
- MariaDB [cont]>
- MariaDB [cont]> INSERT INTO types (id, kind) VALUES("7", "right");
- Query OK, 1 row affected (0.002 sec)
- MariaDB [cont]> INSERT INTO triangles (id, side1, side2, side3) VALUES("1", 10,20,30);
- Query OK, 1 row affected, 3 warnings (0.010 sec)
- MariaDB [cont]> select* from triangles;
- +----+-------+-------+-------+
- | id | side1 | side2 | side3 |
- +----+-------+-------+-------+
- | 1 | 9.99 | 9.99 | 9.99 |
- +----+-------+-------+-------+
- 1 row in set (0.009 sec)
- MariaDB [cont]> delete* from triangles;
- ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '* from triangles' at line 1
- MariaDB [cont]> INSERT INTO triangles (id, side1, side2, side3) VALUES("1", '10.00','20.00','30.00');
- ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'
- MariaDB [cont]> INSERT INTO triangles (id, side1, side2, side3) VALUES("2", '10.00','20.00','30.00');
- Query OK, 1 row affected, 3 warnings (0.007 sec)
- MariaDB [cont]> select* from triangles;
- +----+-------+-------+-------+
- | id | side1 | side2 | side3 |
- +----+-------+-------+-------+
- | 1 | 9.99 | 9.99 | 9.99 |
- | 2 | 9.99 | 9.99 | 9.99 |
- +----+-------+-------+-------+
- 2 rows in set (0.000 sec)
- MariaDB [cont]> create table triangle1(
- -> id INT AUTO_INCREMENT,
- -> side1 decimal(3,2) DEFAULT '0' NOT NULL,
- -> side2 decimal(3,2) DEFAULT '0' NOT NULL,
- -> side3 decimal(3,2) DEFAULT '0' NOT NULL,
- -> primary key(id));
- Query OK, 0 rows affected (0.017 sec)
- MariaDB [cont]>
- MariaDB [cont]> INSERT INTO triangles1 (id, side1, side2, side3) VALUES("1", 10,20,30);
- ERROR 1146 (42S02): Table 'cont.triangles1' doesn't exist
- MariaDB [cont]> INSERT INTO triangle1 (id, side1, side2, side3) VALUES("1", 10,20,30);
- Query OK, 1 row affected, 3 warnings (0.009 sec)
- MariaDB [cont]> select* from tables;
- ERROR 1146 (42S02): Table 'cont.tables' doesn't exist
- MariaDB [cont]> select* from triangle1;
- +----+-------+-------+-------+
- | id | side1 | side2 | side3 |
- +----+-------+-------+-------+
- | 1 | 9.99 | 9.99 | 9.99 |
- +----+-------+-------+-------+
- 1 row in set (0.000 sec)
- MariaDB [cont]> create table triangle2(
- -> id INT AUTO_INCREMENT,
- -> side1 decimal(5,2) DEFAULT '0' NOT NULL,
- -> side2 decimal(5,2) DEFAULT '0' NOT NULL,
- -> side3 decimal(5,2) DEFAULT '0' NOT NULL,
- -> primary key(id));
- Query OK, 0 rows affected (0.012 sec)
- MariaDB [cont]> INSERT INTO triangle2 (id, side1, side2, side3) VALUES("1", 10,20,30);
- Query OK, 1 row affected (0.009 sec)
- MariaDB [cont]> INSERT INTO triangle2 (id, side1, side2, side3) VALUES("1", 20,10,20);
- ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'
- MariaDB [cont]> INSERT INTO triangle2 (id, side1, side2, side3) VALUES("2", 20,10,20);
- Query OK, 1 row affected (0.007 sec)
- MariaDB [cont]> INSERT INTO triangle2 (id, side1, side2, side3) VALUES("3", 20,20,20);
- Query OK, 1 row affected (0.008 sec)
- MariaDB [cont]> INSERT INTO triangle2 (id, side1, side2, side3) VALUES("4", 30,50,40);
- Query OK, 1 row affected (0.008 sec)
- MariaDB [cont]> select* from triangle2;
- +----+-------+-------+-------+
- | id | side1 | side2 | side3 |
- +----+-------+-------+-------+
- | 1 | 10.00 | 20.00 | 30.00 |
- | 2 | 20.00 | 10.00 | 20.00 |
- | 3 | 20.00 | 20.00 | 20.00 |
- | 4 | 30.00 | 50.00 | 40.00 |
- +----+-------+-------+-------+
- 4 rows in set (0.001 sec)
- MariaDB [cont]> INSERT INTO triangle2 (id, side1, side2, side3) VALUES("5", 167.41,160.87,32.05 );
- Query OK, 1 row affected (0.008 sec)
- MariaDB [cont]> INSERT INTO triangle2 (id, side1, side2, side3) VALUES("6",17.95,153.41,102.11 );
- Query OK, 1 row affected (0.002 sec)
- MariaDB [cont]> INSERT INTO triangle2 (id, side1, side2, side3) VALUES("7",195.85,133.22,189.62);
- Query OK, 1 row affected (0.002 sec)
- MariaDB [cont]>
- MariaDB [cont]> select* from triangle2 where side1+side2 >side3 or side1+side3>side2 or side2+side3>side1;
- +----+--------+--------+--------+
- | id | side1 | side2 | side3 |
- +----+--------+--------+--------+
- | 1 | 10.00 | 20.00 | 30.00 |
- | 2 | 20.00 | 10.00 | 20.00 |
- | 3 | 20.00 | 20.00 | 20.00 |
- | 4 | 30.00 | 50.00 | 40.00 |
- | 5 | 167.41 | 160.87 | 32.05 |
- | 6 | 17.95 | 153.41 | 102.11 |
- | 7 | 195.85 | 133.22 | 189.62 |
- +----+--------+--------+--------+
- 7 rows in set (0.004 sec)
- MariaDB [cont]> select* from triangles where side1+side2 >side3 and side1+side3>side2 and side2+side3>side1;
- +----+-------+-------+-------+
- | id | side1 | side2 | side3 |
- +----+-------+-------+-------+
- | 1 | 9.99 | 9.99 | 9.99 |
- | 2 | 9.99 | 9.99 | 9.99 |
- +----+-------+-------+-------+
- 2 rows in set (0.002 sec)
- MariaDB [cont]> select* from triangle2 where side1+side2 >side3 and side1+side3>side2 and side2+side3>side1 ORDER BY side1 ASC;
- +----+--------+--------+--------+
- | id | side1 | side2 | side3 |
- +----+--------+--------+--------+
- | 2 | 20.00 | 10.00 | 20.00 |
- | 3 | 20.00 | 20.00 | 20.00 |
- | 4 | 30.00 | 50.00 | 40.00 |
- | 5 | 167.41 | 160.87 | 32.05 |
- | 7 | 195.85 | 133.22 | 189.62 |
- +----+--------+--------+--------+
- 5 rows in set (0.002 sec)
- MariaDB [cont]> SELECT side1 + side2 + side3 as "Perimeter" FROM triangle2;
- +-----------+
- | Perimeter |
- +-----------+
- | 60.00 |
- | 50.00 |
- | 60.00 |
- | 120.00 |
- | 360.33 |
- | 273.47 |
- | 518.69 |
- +-----------+
- 7 rows in set (0.001 sec)
- MariaDB [cont]> SELECT id, side1 + side2 + side3 as "Perimeter" FROM triangle2 where side1+side2 >side3 and side1+side3>side2 and side2+side3>side1 ORDER BY side1 ASC;
- +----+-----------+
- | id | Perimeter |
- +----+-----------+
- | 2 | 50.00 |
- | 3 | 60.00 |
- | 4 | 120.00 |
- | 5 | 360.33 |
- | 7 | 518.69 |
- +----+-----------+
- 5 rows in set (0.001 sec)
- MariaDB [cont]> SELECT id, side1 + side2 + side3 as "Perimeter" FROM triangle2 where side1+side2 >side3 and side1+side3>side2 and side2+side3>side1 ORDER BY Perimeter DESC;
- +----+-----------+
- | id | Perimeter |
- +----+-----------+
- | 7 | 518.69 |
- | 5 | 360.33 |
- | 4 | 120.00 |
- | 3 | 60.00 |
- | 2 | 50.00 |
- +----+-----------+
- 5 rows in set (0.001 sec)
- MariaDB [cont]>
- MariaDB [cont]> SELECT id, side1 + side2 + side3 as "Perimeter" FROM triangle2 where side1+side2 >side3 and side1+side3>side2 and side2+side3>side1 ORDER BY Perimeter ASC;
- +----+-----------+
- | id | Perimeter |
- +----+-----------+
- | 2 | 50.00 |
- | 3 | 60.00 |
- | 4 | 120.00 |
- | 5 | 360.33 |
- | 7 | 518.69 |
- +----+-----------+
- 5 rows in set (0.001 sec)
- MariaDB [cont]> SELECT id, SQRT((side1+side2+side3)/2*((side1+side2+side3)/2-side1)*((side1+side2+side3)/2-side2)*((side1+side2+side3)/2-side3)) as "Area" FROM triangle2 where side1+side2 >side3 and side1+side3>side2 and side2+side3>side1 ORDER BY Area ASC;
- +----+--------------------+
- | id | Area |
- +----+--------------------+
- | 2 | 96.82458365518542 |
- | 3 | 173.20508075688772 |
- | 4 | 600 |
- | 5 | 2562.697571787604 |
- | 7 | 12033.821205647631 |
- +----+--------------------+
- 5 rows in set (0.009 sec)
- MariaDB [cont]>MariaDB [cont]> select
- -> case
- -> when side1+side2 <side3 or side1+side3<side2 or side2+side3<side1 then "Not A Triangle"
- -> when side1=side2 and side2=side3 then "Equilateral"
- -> when side1=side2 or side1=side3 or side2=side3 then "Isosceles"
- -> when side1<>side2 and side2<>side3 then "Scalene"
- ->
- -> end as triangles_type
- -> from triangle2;
- +----------------+
- | triangles_type |
- +----------------+
- | Scalene |
- | Isosceles |
- | Equilateral |
- | Scalene |
- | Scalene |
- | Not A Triangle |
- | Scalene |
- +----------------+
- 7 rows in set (0.008 sec)
- MariaDB [cont]>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement