- •Лабораторная работа №2 по курсу субд oracle Введение
- •Задание
- •Составить и выполнить команды select
- •Примеры
- •13 Rows selected.
- •13 Rows selected.
- •13 Rows selected.
- •3.5" Floppy Disk 10
- •13 Rows selected.
- •3.5" Floppy Disk 10
- •12 Rows selected.
- •2 Where (price between 10 and 60) and (price not in (10,60));
- •3.5" Floppy Disk 10 30
- •11 Rows selected.
- •3.5" Floppy Disk
- •11 Rows selected.
- •3.5" Floppy Disk 10
- •14 Rows selected.
- •14 Rows selected.
12 Rows selected.
SQL>
SQL> -- выборка строк в диапазоне значений (10,60) и [10,60]
SQL> SELECT name, price FROM product WHERE (price > 10) AND (price < 60);
NAME PRICE
------------------------- ----------
CD-RW Disk 20
CD-R Disk 15
Milk 1 lt. 20
SQL> SELECT name, price FROM product WHERE (price >= 10) AND (price <= 60);
NAME PRICE
------------------------- ----------
CD-RW Disk 20
CD-R Disk 15
3.5" Floppy Disk 10
Red Ink Marker 60
Green Ink Marker 60
Blue Ink Marker 60
Milk 1 lt. 20
Milk 3 lt. 60
8 rows selected.
SQL>
SQL> -- выборка строк вне диапазоне значений (10,60) и [10,60]
SQL> SELECT name, price FROM product WHERE (price < 10) OR (price > 60);
NAME PRICE
------------------------- ----------
DVD-R Disk 80
DVD+R Disk 80
DVD-RW Disk 300
DVD+RW Disk 300
Blue Ink Marker 80
Milk 3 lt. 65
6 rows selected.
SQL> SELECT name, price FROM product WHERE (price <= 10) OR (price >= 60);
NAME PRICE
------------------------- ----------
3.5" Floppy Disk 10
DVD-R Disk 80
DVD+R Disk 80
DVD-RW Disk 300
DVD+RW Disk 300
Red Ink Marker 60
Green Ink Marker 60
Blue Ink Marker 60
Blue Ink Marker 80
Milk 3 lt. 60
Milk 3 lt. 65
11 rows selected.
SQL>
SQL> -- использование уcловия BETWEEN для выборки строк в диапазоне [10,60]
SQL> SELECT name, price FROM product WHERE price BETWEEN 10 AND 60;
NAME PRICE
------------------------- ----------
CD-RW Disk 20
CD-R Disk 15
3.5" Floppy Disk 10
Red Ink Marker 60
Green Ink Marker 60
Blue Ink Marker 60
Milk 1 lt. 20
Milk 3 lt. 60
8 rows selected.
SQL> -- использование уcловия BETWEEN для выборки строк вне диапазоне [10,60]
SQL> SELECT name, price FROM product WHERE price NOT BETWEEN 10 AND 60;
NAME PRICE
------------------------- ----------
DVD-R Disk 80
DVD+R Disk 80
DVD-RW Disk 300
DVD+RW Disk 300
Blue Ink Marker 80
Milk 3 lt. 65
6 rows selected.
SQL>
SQL> -- использование списка значений IN
SQL> SELECT name, price FROM product WHERE price IN (10, 15, 20);
NAME PRICE
------------------------- ----------
CD-RW Disk 20
CD-R Disk 15
3.5" Floppy Disk 10
Milk 1 lt. 20
SQL> SELECT name, price FROM product WHERE name IN ('CD-R Disk', 'CD-RW Disk');
NAME PRICE
------------------------- ----------
CD-RW Disk 20
CD-R Disk 15
SQL>
SQL> -- использование BETWEEN и IN для выборки строк в диапазоне (10,60)
SQL> SELECT name, price FROM product