141 lines
5.3 KiB
Plaintext
141 lines
5.3 KiB
Plaintext
==============================================
|
|
SQL INSERT SCENARIOS
|
|
==============================================
|
|
|
|
================================================================================
|
|
PREAMBLE
|
|
================================================================================
|
|
create user insertsqluser@localhost identified by 'insertsqluser';
|
|
grant all on *.* to insertsqluser@localhost;
|
|
================================================================================
|
|
TEST START
|
|
================================================================================
|
|
RUN DROP SCHEMA if EXISTS mysqlxplugin
|
|
|
|
0 rows affected
|
|
RUN CREATE SCHEMA mysqlxplugin
|
|
|
|
1 rows affected
|
|
RUN USE mysqlxplugin
|
|
|
|
0 rows affected
|
|
RUN CREATE TABLE Categories (
|
|
CategoryID int NOT NULL AUTO_INCREMENT,
|
|
CategoryName varchar(100),
|
|
CategoryDescription varchar(200),
|
|
CategoryIMEI tinyint,
|
|
CategoryDecimal decimal(5,2),
|
|
PRIMARY key (CategoryID)
|
|
)
|
|
|
|
0 rows affected
|
|
RUN INSERT into Categories values (1,'Sports','Sports related category',1,235.15)
|
|
|
|
1 rows affected
|
|
last insert id: 1
|
|
RUN START TRANSACTION
|
|
|
|
0 rows affected
|
|
RUN INSERT into Categories values (20,'Sports','Sports related category',1,235.15)
|
|
|
|
1 rows affected
|
|
last insert id: 20
|
|
RUN SELECT * FROM Categories
|
|
CategoryID CategoryName CategoryDescription CategoryIMEI CategoryDecimal
|
|
1 Sports Sports related category 1 235.15
|
|
20 Sports Sports related category 1 235.15
|
|
0 rows affected
|
|
RUN ROLLBACK
|
|
|
|
0 rows affected
|
|
RUN SELECT * FROM Categories
|
|
CategoryID CategoryName CategoryDescription CategoryIMEI CategoryDecimal
|
|
1 Sports Sports related category 1 235.15
|
|
0 rows affected
|
|
RUN INSERT into Categories values (2,'Entertaiment','Entertaiment related category',2,235.15)
|
|
|
|
1 rows affected
|
|
last insert id: 2
|
|
RUN INSERT INTO Categories
|
|
(CategoryID, CategoryName, CategoryDescription, CategoryIMEI, CategoryDecimal)
|
|
VALUES
|
|
(7, 'Videogames1','Videogames1 related category',7,235.15),
|
|
(8, 'Videogames2','Videogames2 related category',8,235.15),
|
|
(9, 'Videogames3','Videogames3 related category',9,235.15),
|
|
(10, 'Videogames4','Videogames4 related category',10,235.15)
|
|
|
|
4 rows affected
|
|
last insert id: 10
|
|
Records: 4 Duplicates: 0 Warnings: 0
|
|
RUN INSERT into Categories values (3,'"Quotes"','Quote Categories',3,235.15)
|
|
|
|
1 rows affected
|
|
last insert id: 3
|
|
RUN INSERT into Categories values (NULL,NULL,NULL,NULL,NULL)
|
|
|
|
1 rows affected
|
|
last insert id: 21
|
|
RUN INSERT into Categories values (6,'Kitchen','Kitchen related category',6,999.99)
|
|
|
|
1 rows affected
|
|
last insert id: 6
|
|
RUN INSERT into Categories values (12,'Kitchen','Kitchen related category',11,-999.99)
|
|
|
|
1 rows affected
|
|
last insert id: 12
|
|
RUN INSERT into Categories values (13,'Kitchen','Kitchen related category',127,156.99)
|
|
|
|
1 rows affected
|
|
last insert id: 13
|
|
RUN INSERT into Categories values (14,'Kitchen','Kitchen related category',-128,156.99)
|
|
|
|
1 rows affected
|
|
last insert id: 14
|
|
Mysqlx.Ok {
|
|
msg: "bye!"
|
|
}
|
|
ok
|
|
.
|
|
#---------- START NEGATIVE TEST ----------#
|
|
.
|
|
RUN USE mysqlxplugin
|
|
|
|
0 rows affected
|
|
RUN INSERT into Categories values (3,'Home')
|
|
While executing INSERT into Categories values (3,'Home'):
|
|
Got expected error: Column count doesn't match value count at row 1 (code 1136)
|
|
RUN INSERT into Categories values (1,'Home','Home related category',1,235.15)
|
|
While executing INSERT into Categories values (1,'Home','Home related category',1,235.15):
|
|
Got expected error: Duplicate entry '1' for key 'PRIMARY' (code 1062)
|
|
RUN INSERT into Categories values ('5','Kitchen','Kitchen related category','TinyInt',999.00)
|
|
While executing INSERT into Categories values ('5','Kitchen','Kitchen related category','TinyInt',999.00):
|
|
Got expected error: Incorrect integer value: 'TinyInt' for column 'CategoryIMEI' at row 1 (code 1366)
|
|
RUN INSERT into Categories values ('5','Kitchen','Kitchen related category',4,'Decimal')
|
|
While executing INSERT into Categories values ('5','Kitchen','Kitchen related category',4,'Decimal'):
|
|
Got expected error: Incorrect decimal value: 'Decimal' for column 'CategoryDecimal' at row 1 (code 1366)
|
|
RUN INSERT into Categories values ('5','Kitchen','Kitchen related category',4,1000.00)
|
|
While executing INSERT into Categories values ('5','Kitchen','Kitchen related category',4,1000.00):
|
|
Got expected error: Out of range value for column 'CategoryDecimal' at row 1 (code 1264)
|
|
RUN INSERT into Categories values ('5','Kitchen','Kitchen related category',4,-1000.00)
|
|
While executing INSERT into Categories values ('5','Kitchen','Kitchen related category',4,-1000.00):
|
|
Got expected error: Out of range value for column 'CategoryDecimal' at row 1 (code 1264)
|
|
RUN INSERT into Categories values ('5','Kitchen','Kitchen related category',128,999.00)
|
|
While executing INSERT into Categories values ('5','Kitchen','Kitchen related category',128,999.00):
|
|
Got expected error: Out of range value for column 'CategoryIMEI' at row 1 (code 1264)
|
|
RUN INSERT into Categories values ('5','Kitchen','Kitchen related category',-129,999.00)
|
|
While executing INSERT into Categories values ('5','Kitchen','Kitchen related category',-129,999.00):
|
|
Got expected error: Out of range value for column 'CategoryIMEI' at row 1 (code 1264)
|
|
================================================================================
|
|
CLEAN UP
|
|
================================================================================
|
|
RUN DROP SCHEMA if EXISTS mysqlxplugin
|
|
|
|
1 rows affected
|
|
RUN DROP USER insertsqluser@localhost
|
|
|
|
0 rows affected
|
|
Mysqlx.Ok {
|
|
msg: "bye!"
|
|
}
|
|
ok
|