| 1 |
============================================== |
| 2 |
SQL INSERT SCENARIOS |
| 3 |
============================================== |
| 4 |
|
| 5 |
================================================================================ |
| 6 |
PREAMBLE |
| 7 |
================================================================================ |
| 8 |
create user insertsqluser@localhost identified by 'insertsqluser'; |
| 9 |
grant all on *.* to insertsqluser@localhost; |
| 10 |
================================================================================ |
| 11 |
TEST START |
| 12 |
================================================================================ |
| 13 |
RUN DROP SCHEMA if EXISTS mysqlxplugin |
| 14 |
|
| 15 |
0 rows affected |
| 16 |
RUN CREATE SCHEMA mysqlxplugin |
| 17 |
|
| 18 |
1 rows affected |
| 19 |
RUN USE mysqlxplugin |
| 20 |
|
| 21 |
0 rows affected |
| 22 |
RUN CREATE TABLE Categories ( |
| 23 |
CategoryID int NOT NULL AUTO_INCREMENT, |
| 24 |
CategoryName varchar(100), |
| 25 |
CategoryDescription varchar(200), |
| 26 |
CategoryIMEI tinyint, |
| 27 |
CategoryDecimal decimal(5,2), |
| 28 |
PRIMARY key (CategoryID) |
| 29 |
) |
| 30 |
|
| 31 |
0 rows affected |
| 32 |
RUN INSERT into Categories values (1,'Sports','Sports related category',1,235.15) |
| 33 |
|
| 34 |
1 rows affected |
| 35 |
last insert id: 1 |
| 36 |
RUN START TRANSACTION |
| 37 |
|
| 38 |
0 rows affected |
| 39 |
RUN INSERT into Categories values (20,'Sports','Sports related category',1,235.15) |
| 40 |
|
| 41 |
1 rows affected |
| 42 |
last insert id: 20 |
| 43 |
RUN SELECT * FROM Categories |
| 44 |
CategoryID CategoryName CategoryDescription CategoryIMEI CategoryDecimal |
| 45 |
1 Sports Sports related category 1 235.15 |
| 46 |
20 Sports Sports related category 1 235.15 |
| 47 |
0 rows affected |
| 48 |
RUN ROLLBACK |
| 49 |
|
| 50 |
0 rows affected |
| 51 |
RUN SELECT * FROM Categories |
| 52 |
CategoryID CategoryName CategoryDescription CategoryIMEI CategoryDecimal |
| 53 |
1 Sports Sports related category 1 235.15 |
| 54 |
0 rows affected |
| 55 |
RUN INSERT into Categories values (2,'Entertaiment','Entertaiment related category',2,235.15) |
| 56 |
|
| 57 |
1 rows affected |
| 58 |
last insert id: 2 |
| 59 |
RUN INSERT INTO Categories |
| 60 |
(CategoryID, CategoryName, CategoryDescription, CategoryIMEI, CategoryDecimal) |
| 61 |
VALUES |
| 62 |
(7, 'Videogames1','Videogames1 related category',7,235.15), |
| 63 |
(8, 'Videogames2','Videogames2 related category',8,235.15), |
| 64 |
(9, 'Videogames3','Videogames3 related category',9,235.15), |
| 65 |
(10, 'Videogames4','Videogames4 related category',10,235.15) |
| 66 |
|
| 67 |
4 rows affected |
| 68 |
last insert id: 10 |
| 69 |
Records: 4 Duplicates: 0 Warnings: 0 |
| 70 |
RUN INSERT into Categories values (3,'"Quotes"','Quote Categories',3,235.15) |
| 71 |
|
| 72 |
1 rows affected |
| 73 |
last insert id: 3 |
| 74 |
RUN INSERT into Categories values (NULL,NULL,NULL,NULL,NULL) |
| 75 |
|
| 76 |
1 rows affected |
| 77 |
last insert id: 21 |
| 78 |
RUN INSERT into Categories values (6,'Kitchen','Kitchen related category',6,999.99) |
| 79 |
|
| 80 |
1 rows affected |
| 81 |
last insert id: 6 |
| 82 |
RUN INSERT into Categories values (12,'Kitchen','Kitchen related category',11,-999.99) |
| 83 |
|
| 84 |
1 rows affected |
| 85 |
last insert id: 12 |
| 86 |
RUN INSERT into Categories values (13,'Kitchen','Kitchen related category',127,156.99) |
| 87 |
|
| 88 |
1 rows affected |
| 89 |
last insert id: 13 |
| 90 |
RUN INSERT into Categories values (14,'Kitchen','Kitchen related category',-128,156.99) |
| 91 |
|
| 92 |
1 rows affected |
| 93 |
last insert id: 14 |
| 94 |
Mysqlx.Ok { |
| 95 |
msg: "bye!" |
| 96 |
} |
| 97 |
ok |
| 98 |
. |
| 99 |
#---------- START NEGATIVE TEST ----------# |
| 100 |
. |
| 101 |
RUN USE mysqlxplugin |
| 102 |
|
| 103 |
0 rows affected |
| 104 |
RUN INSERT into Categories values (3,'Home') |
| 105 |
While executing INSERT into Categories values (3,'Home'): |
| 106 |
Got expected error: Column count doesn't match value count at row 1 (code 1136) |
| 107 |
RUN INSERT into Categories values (1,'Home','Home related category',1,235.15) |
| 108 |
While executing INSERT into Categories values (1,'Home','Home related category',1,235.15): |
| 109 |
Got expected error: Duplicate entry '1' for key 'Categories.PRIMARY' (code 1062) |
| 110 |
RUN INSERT into Categories values ('5','Kitchen','Kitchen related category','TinyInt',999.00) |
| 111 |
While executing INSERT into Categories values ('5','Kitchen','Kitchen related category','TinyInt',999.00): |
| 112 |
Got expected error: Incorrect integer value: 'TinyInt' for column 'CategoryIMEI' at row 1 (code 1366) |
| 113 |
RUN INSERT into Categories values ('5','Kitchen','Kitchen related category',4,'Decimal') |
| 114 |
While executing INSERT into Categories values ('5','Kitchen','Kitchen related category',4,'Decimal'): |
| 115 |
Got expected error: Incorrect decimal value: 'Decimal' for column 'CategoryDecimal' at row 1 (code 1366) |
| 116 |
RUN INSERT into Categories values ('5','Kitchen','Kitchen related category',4,1000.00) |
| 117 |
While executing INSERT into Categories values ('5','Kitchen','Kitchen related category',4,1000.00): |
| 118 |
Got expected error: Out of range value for column 'CategoryDecimal' at row 1 (code 1264) |
| 119 |
RUN INSERT into Categories values ('5','Kitchen','Kitchen related category',4,-1000.00) |
| 120 |
While executing INSERT into Categories values ('5','Kitchen','Kitchen related category',4,-1000.00): |
| 121 |
Got expected error: Out of range value for column 'CategoryDecimal' at row 1 (code 1264) |
| 122 |
RUN INSERT into Categories values ('5','Kitchen','Kitchen related category',128,999.00) |
| 123 |
While executing INSERT into Categories values ('5','Kitchen','Kitchen related category',128,999.00): |
| 124 |
Got expected error: Out of range value for column 'CategoryIMEI' at row 1 (code 1264) |
| 125 |
RUN INSERT into Categories values ('5','Kitchen','Kitchen related category',-129,999.00) |
| 126 |
While executing INSERT into Categories values ('5','Kitchen','Kitchen related category',-129,999.00): |
| 127 |
Got expected error: Out of range value for column 'CategoryIMEI' at row 1 (code 1264) |
| 128 |
================================================================================ |
| 129 |
CLEAN UP |
| 130 |
================================================================================ |
| 131 |
RUN DROP SCHEMA if EXISTS mysqlxplugin |
| 132 |
|
| 133 |
1 rows affected |
| 134 |
RUN DROP USER insertsqluser@localhost |
| 135 |
|
| 136 |
0 rows affected |
| 137 |
Mysqlx.Ok { |
| 138 |
msg: "bye!" |
| 139 |
} |
| 140 |
ok |