diff --git "a/data/1.MySQL\345\210\235\351\230\266/2.\345\256\211\350\243\205\345\222\214\347\231\273\345\275\225/2.\347\231\273\345\275\225/prepare.md" "b/data/1.MySQL\345\210\235\351\230\266/2.\345\256\211\350\243\205\345\222\214\347\231\273\345\275\225/2.\347\231\273\345\275\225/prepare.md" index ad32a0e7e9abd27900afbb6bc4ca45c063c62ce0..d562db26a968dd6b0e9f5ff0412911ffe5782b60 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/2.\345\256\211\350\243\205\345\222\214\347\231\273\345\275\225/2.\347\231\273\345\275\225/prepare.md" +++ "b/data/1.MySQL\345\210\235\351\230\266/2.\345\256\211\350\243\205\345\222\214\347\231\273\345\275\225/2.\347\231\273\345\275\225/prepare.md" @@ -25,8 +25,13 @@ mysql mysql ``` 创建数据库用户 joe 并授权: ```sql -create user 'joe'@'localhost' identified by 'joe'; -grant all privileges on *.* to `joe`@`localhost`; +create user + 'joe'@'localhost' + identified by 'joe'; + +grant all privileges + on *.* to `joe`@`localhost`; + flush privileges ; ``` @@ -41,7 +46,9 @@ mysql mysql ``` 为 joe 授权 ```sql -grant all privileges on *.* to joe; +grant all + privileges on *.* to joe; + flush privileges ; ``` @@ -55,7 +62,9 @@ mysql mysql 为 joe 授权 ```sql -grant all privileges on *.* to joe; +grant all + privileges on *.* to joe; + flush privileges ; ``` @@ -68,7 +77,10 @@ mysql mysql 创建数据库用户 joe ```sql -create user 'joe'@'localhost' identified by 'joe'; +create user + 'joe'@'localhost' + identified by 'joe'; + flush privileges ; ``` @@ -81,7 +93,12 @@ mysql mysql ``` 创建数据库用户 joe 并授权: ```sql -create user 'joe'@'%' identified by 'joe'; -grant all privileges on *.* to joe; +create user + 'joe'@'%' + identified by 'joe'; + +grant all + privileges on *.* to joe; + flush privileges ; ``` diff --git "a/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/1.\346\217\222\345\205\245/config.json" "b/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/1.\346\217\222\345\205\245/config.json" index 92b180e51f792f3e8fbe68d6301813853555efd9..e2a1bd612534cb4e525869734994a7d3b4fb86b3 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/1.\346\217\222\345\205\245/config.json" +++ "b/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/1.\346\217\222\345\205\245/config.json" @@ -1,12 +1,18 @@ { "node_id": "mysql-fcca525ab0f04f16834ded9b2b3f38a4", - "keywords": ["insert", "插入"], + "keywords": [ + "insert", + "插入" + ], "children": [], "export": [ "insert.json" ], "keywords_must": [ - ["mysql", "插入"] + [ + "mysql", + "插入" + ] ], "keywords_forbid": [], "group": 1 diff --git "a/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/1.\346\217\222\345\205\245/insert.md" "b/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/1.\346\217\222\345\205\245/insert.md" index 56258b1debe899d59cb9b0fff8d2925aae86b5d5..3b9e524c4946d0cfb84e4bc9db1cb900c70f6675 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/1.\346\217\222\345\205\245/insert.md" +++ "b/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/1.\346\217\222\345\205\245/insert.md" @@ -26,8 +26,24 @@ create unique index idx_book_isbn on book(isbn); ## 答案 ```sql -insert into book(title, price, isbn, publish_at) select 'a book title', 25.4, 'xx-xxxx-xxxx', '2019-12-1'; -insert into book(title, price, isbn, publish_at) select 'a other book title', 25.4, 'yy-yyyy-xxxx', '2019-12-1'; +insert into book( + title, + price, + isbn, + publish_at) + select 'a book title', + 25.4, + 'xx-xxxx-xxxx', + '2019-12-1'; + +insert into book(title, + price, + isbn, + publish_at) + select 'a other book title', + 25.4, + 'yy-yyyy-xxxx', + '2019-12-1'; ``` ## 选项 @@ -35,27 +51,83 @@ insert into book(title, price, isbn, publish_at) select 'a other book title', 25 ### 唯一键冲突 ```sql -insert into book(title, price, isbn, publish_at) select 'a book title', 25.4, 'xx-xxxx-xxxx', '2019-12-1'; -insert into book(title, price, isbn, publish_at) select 'a other book title', 35.4, 'xx-xxxx-xxxx', '2019-12-1'; +insert into book(title, + price, + isbn, + publish_at) + select 'a book title', + 25.4, + 'xx-xxxx-xxxx', + '2019-12-1'; + +insert into book(title, + price, + isbn, + publish_at) + select 'a other book title', + 35.4, + 'xx-xxxx-xxxx', + '2019-12-1'; ``` ### 缺少必要的列 ```sql -insert into book(price, isbn, publish_at) select 25.4, 'xx-xxxx-xxxx', '2019-12-1'; -insert into book(price, isbn, publish_at) select 35.4, 'yy-yyyy-xxxx', '2019-12-1'; +insert into book(price, + isbn, + publish_at) + select 25.4, + 'xx-xxxx-xxxx', + '2019-12-1'; + +insert into book(price, + isbn, + publish_at) + select 35.4, + 'yy-yyyy-xxxx', + '2019-12-1'; ``` ### 类型错误 ```sql -insert into book(title, price, isbn, publish_at) select 'a book title', 'unknown', 'xx-xxxx-xxxx', '2019-12-1'; -insert into book(title, price, isbn, publish_at) select 'a other book title', 'unknown', 'xx-xxxx-xxxx', '2019-12-1'; +insert into book(title, + price, + isbn, + publish_at) + select 'a book title', + 'unknown', + 'xx-xxxx-xxxx', + '2019-12-1'; + +insert into book(title, + price, + isbn, + publish_at) + select 'a other book title', + 'unknown', + 'xx-xxxx-xxxx', + '2019-12-1'; ``` ### 违反非空约束 ```sql -insert into book(title, price, isbn, publish_at) select null, 'unknown', 'xx-xxxx-xxxx', '2019-12-1'; -insert into book(title, price, isbn, publish_at) select null, 'unknown', 'xx-xxxx-xxxx', '2019-12-1'; +insert into book(title, + price, + isbn, + publish_at) + select null, + 'unknown', + 'xx-xxxx-xxxx', + '2019-12-1'; + +insert into book(title, + price, + isbn, + publish_at) + select null, + 'unknown', + 'xx-xxxx-xxxx', + '2019-12-1'; ``` diff --git "a/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/2.\344\277\256\346\224\271/update.md" "b/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/2.\344\277\256\346\224\271/update.md" index a1d73279ebf455eb72e04713708b0092c6431ba5..dfa92e1d98c83620bec1f3c888e457ccc8513a82 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/2.\344\277\256\346\224\271/update.md" +++ "b/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/2.\344\277\256\346\224\271/update.md" @@ -24,7 +24,9 @@ Joe 希望修改销售部(dept 字段为 sale)员工 Dora Muk 的工资,将其 ## 答案 ```sql -update employee set salary = salary + 1000 where dept = 'sale' and name = 'Dora Muk'; +update employee set + salary = salary + 1000 +where dept = 'sale' and name = 'Dora Muk'; ``` ## 选项 @@ -32,19 +34,23 @@ update employee set salary = salary + 1000 where dept = 'sale' and name = 'Dora ### 过滤条件不严谨 ```sql -update employee set salary = salary + 1000 where name = 'Dora Muk'; +update employee set + salary = salary + 1000 +where name = 'Dora Muk'; ``` ### 缺少过滤条件 ```sql -update employee set salary = salary + 1000; +update employee set + salary = salary + 1000; ``` ### 错误的赋值语句 ```sql -update employee set salary += 1000; +update employee set + salary += 1000; ``` diff --git "a/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/3.\345\210\240\351\231\244/delete.md" "b/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/3.\345\210\240\351\231\244/delete.md" index 7571ad4998992accc93719b2dbdfc34352420691..3e17d3e056ecce206bfda86b6bad6492ea0363b7 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/3.\345\210\240\351\231\244/delete.md" +++ "b/data/1.MySQL\345\210\235\351\230\266/5.\346\225\260\346\215\256\344\277\256\346\224\271/3.\345\210\240\351\231\244/delete.md" @@ -4,14 +4,14 @@ ```sql create table orders ( - id int primary key auto_increment, - item_id int, - amount int, - unit_price decimal(12, 4), - price decimal(12, 4), - description varchar(2000), - ts timestamp default now(), - deal bool default false + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + price decimal(12, 4), + description varchar(2000), + ts timestamp default now(), + deal bool default false ); ``` @@ -60,14 +60,14 @@ from orders; ```sql drop table orders; create table if not exists orders ( - id int primary key auto_increment, - item_id int, - amount int, - unit_price decimal(12, 4), - price decimal(12, 4), - description varchar(2000), - ts timestamp default now(), - deal bool default false + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + price decimal(12, 4), + description varchar(2000), + ts timestamp default now(), + deal bool default false ); ``` diff --git "a/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/1.SELECT/config.json" "b/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/1.SELECT/config.json" index 42d0c328df954a4f5e69edaec6c8098ed7ba2acd..cb558acf0b46727e816bae281d8935a9e7ce304f 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/1.SELECT/config.json" +++ "b/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/1.SELECT/config.json" @@ -1,12 +1,18 @@ { "node_id": "mysql-f5527eae7f3148108c92ff99a6d4ed4a", - "keywords": ["查询", "select"], + "keywords": [ + "查询", + "select" + ], "children": [], "export": [ "select.json" ], "keywords_must": [ - ["mysql", "select"] + [ + "mysql", + "select" + ] ], "keywords_forbid": [], "group": 1 diff --git "a/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/1.SELECT/select.md" "b/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/1.SELECT/select.md" index cb25e6d5d2d7f23bdb2944bc7fc9987f02874e92..e66aa5938efb70a0548f7f78eda0991ad6ab3864 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/1.SELECT/select.md" +++ "b/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/1.SELECT/select.md" @@ -39,7 +39,9 @@ select * from employee where dept = 'hr'; ### D ```sql -select id, name, dept, salary from employee where salary > 10000; +select id, name, dept, salary +from employee +where salary > 10000; ``` ### E diff --git "a/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/2.WHERE/config.json" "b/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/2.WHERE/config.json" index 1fa83289e27b9852fd38a871d965cca7ad150b5d..cdd0e3ee604c5bde7d5776a873f2f6f19df73e3b 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/2.WHERE/config.json" +++ "b/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/2.WHERE/config.json" @@ -1,12 +1,19 @@ { "node_id": "mysql-91cc9c73e58945d3ba654370a057a1c7", - "keywords": ["查询", "select", "where"], + "keywords": [ + "查询", + "select", + "where" + ], "children": [], "export": [ "where.json" ], "keywords_must": [ - ["mysql", "where"] + [ + "mysql", + "where" + ] ], "keywords_forbid": [], "group": 1 diff --git "a/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/2.WHERE/where.md" "b/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/2.WHERE/where.md" index 4b282d61c0e7ca8624f1b7d6f0b444bd0e6bbd6d..816d9b572824d712543ca404a585adb5be6ce6ba 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/2.WHERE/where.md" +++ "b/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/2.WHERE/where.md" @@ -40,7 +40,9 @@ where date(ts) = '2022-05-25' ```sql select id -from (select * from orders where date(ts) = '2022-05-25') as o +from (select * + from orders + where date(ts) = '2022-05-25') as o where unit_prise < 20; ``` @@ -58,7 +60,8 @@ where date(ts) = '2022-05-25' ```sql select id from orders -if date(ts) = '2022-05-25' or unit_prise < 20; +if date(ts) = '2022-05-25' + or unit_prise < 20; ``` ### D diff --git "a/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/3.\350\277\220\347\256\227\347\254\246/config.json" "b/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/3.\350\277\220\347\256\227\347\254\246/config.json" index 12ff25b8215ea920b9fc82b925ac700495238c7b..b38772881d142f12598621233389693f138c8b17 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/3.\350\277\220\347\256\227\347\254\246/config.json" +++ "b/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/3.\350\277\220\347\256\227\347\254\246/config.json" @@ -9,7 +9,10 @@ "geo.json" ], "keywords_must": [ - ["mysql", "运算符"] + [ + "mysql", + "运算符" + ] ], "keywords_forbid": [], "group": 1 diff --git "a/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/3.\350\277\220\347\256\227\347\254\246/geo.md" "b/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/3.\350\277\220\347\256\227\347\254\246/geo.md" index 1bc5e9690dba7d956497f5be4f1d71bf3d7e7c82..a8fb1e9c63f38316a81edc80bd12b16127d68a26 100644 --- "a/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/3.\350\277\220\347\256\227\347\254\246/geo.md" +++ "b/data/1.MySQL\345\210\235\351\230\266/6.\346\225\260\346\215\256\346\237\245\350\257\242/3.\350\277\220\347\256\227\347\254\246/geo.md" @@ -22,7 +22,8 @@ create table points( ## 答案 ```sql -select id, sqrt(x^2 + y^2) from points; +select id, sqrt(x^2 + y^2) +from points; ``` ## 选项 @@ -30,23 +31,30 @@ select id, sqrt(x^2 + y^2) from points; ### A ```sql -select sqrt(vx+vy) from (select x^2 as vx, y^2 as vy from points) as t; +select sqrt(vx+vy) +from ( + select x^2 as vx, y^2 as vy + from points) as t; ``` ### B ```sql -select sqrt(vx + vy) from points where x^2 as vx, y^2 as vy ; +select sqrt(vx + vy) +from points +where x^2 as vx, y^2 as vy ; ``` ### C ```sql -select id + sqrt(x^2 + y^2) from points; +select id + sqrt(x^2 + y^2) +from points; ``` ### D ```sql -select id || sqrt(x^2 + y^2) from points; +select id || sqrt(x^2 + y^2) +from points; ``` \ No newline at end of file diff --git "a/data/2.MySQL\344\270\255\351\230\266/1.\346\225\260\346\215\256\345\272\223\347\273\204\346\210\220/3.\345\255\230\345\202\250\350\277\207\347\250\213\345\222\214\345\207\275\346\225\260/create_procedure.md" "b/data/2.MySQL\344\270\255\351\230\266/1.\346\225\260\346\215\256\345\272\223\347\273\204\346\210\220/3.\345\255\230\345\202\250\350\277\207\347\250\213\345\222\214\345\207\275\346\225\260/create_procedure.md" index 2f663f7b9a058a02f93968bde2ad2e86cf59a155..3d3faaf1a0c4c14874cb0cd4f874373af3aa99cf 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/1.\346\225\260\346\215\256\345\272\223\347\273\204\346\210\220/3.\345\255\230\345\202\250\350\277\207\347\250\213\345\222\214\345\207\275\346\225\260/create_procedure.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/1.\346\225\260\346\215\256\345\272\223\347\273\204\346\210\220/3.\345\255\230\345\202\250\350\277\207\347\250\213\345\222\214\345\207\275\346\225\260/create_procedure.md" @@ -14,7 +14,10 @@ Joe 希望这个计算更紧凑一些,在已经有 individual_income_tax 的 ## 答案 ```sql -create procedure sp_idt(in salary decimal(12, 4), out tax decimal(12, 4), out take_home decimal(12, 4)) +create procedure sp_idt( + in salary decimal(12, 4), + out tax decimal(12, 4), + out take_home decimal(12, 4)) begin set tax = individual_income_tax(salary); set take_home = salary - tax; @@ -26,7 +29,9 @@ end; ### A ```sql -create procedure sp_idt(salary decimal(12, 4)) returns (tax decimal(12, 4), take_home decimal(12, 4)) +create procedure sp_idt(salary decimal(12, 4)) + returns (tax decimal(12, 4), + take_home decimal(12, 4)) begin set tax = individual_income_tax(salary); set take_home = salary - tax; @@ -37,7 +42,8 @@ end; ```sql -create procedure sp_idt(salary decimal(12, 4)) returns (decimal(12, 4), decimal(12, 4)) +create procedure sp_idt(salary decimal(12, 4)) + returns (decimal(12, 4), decimal(12, 4)) begin declare tax, take_home decimal(12, 4); set tax = individual_income_tax(salary); diff --git "a/data/2.MySQL\344\270\255\351\230\266/1.\346\225\260\346\215\256\345\272\223\347\273\204\346\210\220/5. \350\247\246\345\217\221\345\231\250/audit.md" "b/data/2.MySQL\344\270\255\351\230\266/1.\346\225\260\346\215\256\345\272\223\347\273\204\346\210\220/5. \350\247\246\345\217\221\345\231\250/audit.md" index befab47166a8034d3a8a88fd6c5a35c88ccf9912..adb11e82566609492d13ea16dc114aed93e5869d 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/1.\346\225\260\346\215\256\345\272\223\347\273\204\346\210\220/5. \350\247\246\345\217\221\345\231\250/audit.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/1.\346\225\260\346\215\256\345\272\223\347\273\204\346\210\220/5. \350\247\246\345\217\221\345\231\250/audit.md" @@ -45,13 +45,44 @@ create table orders_log ## 答案 ```sql -create trigger in_orders after insert on orders - for each row insert into orders_log(id, item_id, amount, unit_price, total, description, ts, direction) - values(NEW.id, NEW.item_id, NEW.amount, NEW.unit_price, NEW.total, NEW.description, NEW.ts, 'in'); - -create trigger out_orders after delete on orders - for each row insert into orders_log(id, item_id, amount, unit_price, total, description, ts, direction) - values(OLD.id, OLD.item_id, OLD.amount, OLD.unit_price, OLD.total, OLD.description, OLD.ts, 'out'); +create trigger in_orders + after insert on orders + for each row insert into orders_log( + id, + item_id, + amount, + unit_price, + total, + description, + ts, + direction) + values(NEW.id, + NEW.item_id, + NEW.amount, + NEW.unit_price, + NEW.total, + NEW.description, + NEW.ts, 'in'); + +create trigger out_orders + after delete on orders + for each row insert into orders_log( + id, + item_id, + amount, + unit_price, + total, + description, + ts, + direction) + values(OLD.id, + OLD.item_id, + OLD.amount, + OLD.unit_price, + OLD.total, + OLD.description, + OLD.ts, + 'out'); ``` ## 选项 @@ -60,8 +91,23 @@ create trigger out_orders after delete on orders ```sql create trigger in_orders after insert on orders - for each row insert into orders_log(id, item_id, amount, unit_price, total, description, ts, direction) - values(NEW.id, NEW.item_id, NEW.amount, NEW.unit_price, NEW.total, NEW.description, NEW.ts, 'in'); + for each row insert into orders_log( + id, + item_id, + amount, + unit_price, + total, + description, + ts, + direction) + values(NEW.id, + NEW.item_id, + NEW.amount, + NEW.unit_price, + NEW.total, + NEW.description, + NEW.ts, + 'in'); ``` @@ -70,8 +116,23 @@ create trigger in_orders after insert on orders ```sql create trigger out_orders after delete on orders - for each row insert into orders_log(id, item_id, amount, unit_price, total, description, ts, direction) - values(OLD.id, OLD.item_id, OLD.amount, OLD.unit_price, OLD.total, OLD.description, OLD.ts, 'out'); + for each row insert into orders_log( + id, + item_id, + amount, + unit_price, + total, + description, + ts, + direction) + values(OLD.id, + OLD.item_id, + OLD.amount, + OLD.unit_price, + OLD.total, + OLD.description, + OLD.ts, + 'out'); ``` @@ -79,17 +140,63 @@ create trigger out_orders after delete on orders ```sql create trigger in_orders after insert on orders - for each row insert into orders_log(id, item_id, amount, unit_price, total, description, ts, direction) - values(NEW.id, NEW.item_id, NEW.amount, NEW.unit_price, NEW.total, NEW.description, NEW.ts, 'in'); + for each row insert into orders_log( + id, + item_id, + amount, + unit_price, + total, + description, + ts, + direction) + values(NEW.id, + NEW.item_id, + NEW.amount, + NEW.unit_price, + NEW.total, + NEW.description, + NEW.ts, + 'in'); + after delete on orders - for each row insert into orders_log(id, item_id, amount, unit_price, total, description, ts, direction) - values(OLD.id, OLD.item_id, OLD.amount, OLD.unit_price, OLD.total, OLD.description, OLD.ts, 'out'); + for each row insert into orders_log( + id, + item_id, + amount, + unit_price, + total, + description, + ts, + direction) + values(OLD.id, + OLD.item_id, + OLD.amount, + OLD.unit_price, + OLD.total, + OLD.description, + OLD.ts, + 'out'); ``` ### D ```sql create trigger in_orders after insert, after delete on orders - for each row insert into orders_log(id, item_id, amount, unit_price, total, description, ts, direction) - values(NEW.id, NEW.item_id, NEW.amount, NEW.unit_price, NEW.total, NEW.description, NEW.ts, 'in'); + for each row insert into orders_log( + id, + item_id, + amount, + unit_price, + total, + description, + ts, + direction) + values(NEW.id, + NEW.item_id, + NEW.amount, + NEW.unit_price, + NEW.total, + NEW.description, + NEW.ts, + 'in'); ``` \ No newline at end of file diff --git "a/data/2.MySQL\344\270\255\351\230\266/11.\347\224\250\346\210\267\345\222\214\346\235\203\351\231\220/1.\345\210\233\345\273\272\346\231\256\351\200\232\347\224\250\346\210\267/create_user.md" "b/data/2.MySQL\344\270\255\351\230\266/11.\347\224\250\346\210\267\345\222\214\346\235\203\351\231\220/1.\345\210\233\345\273\272\346\231\256\351\200\232\347\224\250\346\210\267/create_user.md" index 009aa910d66b130fedf2b46ff6413804754ab6a7..b3ab74accaf488b9fe1d1c2c155cb46d27a9cf1a 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/11.\347\224\250\346\210\267\345\222\214\346\235\203\351\231\220/1.\345\210\233\345\273\272\346\231\256\351\200\232\347\224\250\346\210\267/create_user.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/11.\347\224\250\346\210\267\345\222\214\346\235\203\351\231\220/1.\345\210\233\345\273\272\346\231\256\351\200\232\347\224\250\346\210\267/create_user.md" @@ -13,8 +13,11 @@ Joe 要给数据组的 John 创建一个用户,他希望John 能够从 `192.16 ## 答案 ```sql -create user 'john'@'192.168.7.42' identified by 'goods123' password expire; +create user 'john'@'192.168.7.42' + identified by 'goods123' password expire; + grant select on goods.* to 'john'@'192.168.7.42'; + flush privileges; ``` @@ -23,22 +26,31 @@ flush privileges; ### A ```sql -create user 'john'@'192.168.7.42' identified by 'goods123'; +create user 'john'@'192.168.7.42' + identified by 'goods123'; + grant select on goods.* to 'john'@'192.168.7.42'; + flush privileges; ``` ### B ```sql -create user 'john'@'192.168.7.42' identified by 'goods123'; -grant usage on goods.* to 'john'@'192.168.7.42'; +create user 'john'@'192.168.7.42' + identified by 'goods123'; + +grant usage on + goods.* to 'john'@'192.168.7.42'; + flush privileges; ``` ### C ```sql -create user 'john'@'192.168.7.42' identified by 'goods123' on database goods; +create user 'john'@'192.168.7.42' + identified by 'goods123' on database goods; + flush privileges; ``` \ No newline at end of file diff --git "a/data/2.MySQL\344\270\255\351\230\266/11.\347\224\250\346\210\267\345\222\214\346\235\203\351\231\220/1.\345\210\233\345\273\272\346\231\256\351\200\232\347\224\250\346\210\267/create_user_desc.md" "b/data/2.MySQL\344\270\255\351\230\266/11.\347\224\250\346\210\267\345\222\214\346\235\203\351\231\220/1.\345\210\233\345\273\272\346\231\256\351\200\232\347\224\250\346\210\267/create_user_desc.md" index 162815082fb4138d382b474fae48267886410c58..9a11c7a3d0cb5b535e267650c6c02c6ba7cdaf6f 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/11.\347\224\250\346\210\267\345\222\214\346\235\203\351\231\220/1.\345\210\233\345\273\272\346\231\256\351\200\232\347\224\250\346\210\267/create_user_desc.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/11.\347\224\250\346\210\267\345\222\214\346\235\203\351\231\220/1.\345\210\233\345\273\272\346\231\256\351\200\232\347\224\250\346\210\267/create_user_desc.md" @@ -22,31 +22,21 @@ IDENTIFIED BY '@Binghe123456'; ### A -``` 可以使用GRANT来创建用户 -``` ### B -``` 可以使用CREATE USER语句来创建用户 -``` ### C -``` CREATE USER 'binghe'@'localhost'; 创建用户名为binghe的MySQL用户,其主机名为localhost。 -``` ### D -``` 使用GRANT语句创建用户,不仅可以添加用户,而且还能为用户赋予相应的权限。 -``` ### E -``` 使用CREATE USER语句创建用户时,只是在mysql数据库下的user数据表中添加了一条记录,并没有为用户授权。 -``` \ No newline at end of file diff --git "a/data/2.MySQL\344\270\255\351\230\266/11.\347\224\250\346\210\267\345\222\214\346\235\203\351\231\220/7.\351\231\220\345\210\266\347\224\250\346\210\267\344\275\277\347\224\250\350\265\204\346\272\220/limit_action.md" "b/data/2.MySQL\344\270\255\351\230\266/11.\347\224\250\346\210\267\345\222\214\346\235\203\351\231\220/7.\351\231\220\345\210\266\347\224\250\346\210\267\344\275\277\347\224\250\350\265\204\346\272\220/limit_action.md" index be5a7a9470580f4e11654511ad44b865570ff561..ce8e9eb2ea6d4cf44bbd69d719cfd33d9c5e7dae 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/11.\347\224\250\346\210\267\345\222\214\346\235\203\351\231\220/7.\351\231\220\345\210\266\347\224\250\346\210\267\344\275\277\347\224\250\350\265\204\346\272\220/limit_action.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/11.\347\224\250\346\210\267\345\222\214\346\235\203\351\231\220/7.\351\231\220\345\210\266\347\224\250\346\210\267\344\275\277\347\224\250\350\265\204\346\272\220/limit_action.md" @@ -12,7 +12,8 @@ Joe 需要限制数据分析组(role analysis)的用户, 每小时查询次 ## 答案 ```sql -alter user analysis with MAX_QUERIES_PER_HOUR 10000; +alter user analysis + with MAX_QUERIES_PER_HOUR 10000; ``` ## 选项 @@ -20,24 +21,28 @@ alter user analysis with MAX_QUERIES_PER_HOUR 10000; ### A ```sql -set user analysis with MAX_QUERIES_PER_HOUR 10000; +set user analysis + with MAX_QUERIES_PER_HOUR 10000; ``` ### B ```sql -alter role analysis with MAX_QUERIES_PER_HOUR 10000; +alter role analysis + with MAX_QUERIES_PER_HOUR 10000; ``` ### C ```sql -alter role analysis with MAX_QUERIES_PER_HOUR=10000; +alter role analysis + with MAX_QUERIES_PER_HOUR=10000; ``` ### D ```sql -alter user analysis set MAX_QUERIES_PER_HOUR 10000; +alter user analysis + set MAX_QUERIES_PER_HOUR 10000; ``` diff --git "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/2. BETWEEN/between.md" "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/2. BETWEEN/between.md" index 4a42b6f78ff5eb5a2f2b51e87dc0e443d59bc01a..bb61964dbc9551e7d39a75ae8ea5b6efdfcc9d6b 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/2. BETWEEN/between.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/2. BETWEEN/between.md" @@ -24,7 +24,10 @@ create table goods( ## 答案 ```sql -SELECT * FROM goods HAVING price BETWEEN 1000 AND 2000; +SELECT * +FROM goods +HAVING price + BETWEEN 1000 AND 2000; ``` @@ -33,18 +36,25 @@ SELECT * FROM goods HAVING price BETWEEN 1000 AND 2000; ### A ```sql -SELECT * FROM goods WHERE price BETWEEN 1000 AND 2000; +SELECT * +FROM goods +WHERE price + BETWEEN 1000 AND 2000; ``` ### B ```sql -SELECT * FROM goods WHERE price >= 1000 AND price <= 2000; +SELECT * +FROM goods +WHERE price >= 1000 AND price <= 2000; ``` ### C ```sql -SELECT * FROM goods WHERE not (price < 1000 or price > 2000); +SELECT * +FROM goods +WHERE not (price < 1000 or price > 2000); ``` diff --git "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/2. BETWEEN/config.json" "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/2. BETWEEN/config.json" index 21c324ce55b85aee3f34336704ed856578be3fb4..e696abda25d276b37c24aeebb8a83aa43c26818a 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/2. BETWEEN/config.json" +++ "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/2. BETWEEN/config.json" @@ -1,12 +1,17 @@ { "node_id": "mysql-2296dbe96d584a52bd28a3ad5f655518", - "keywords": ["where"], + "keywords": [ + "where" + ], "children": [], "export": [ "between.json" ], "keywords_must": [ - ["mysql", "between"] + [ + "mysql", + "between" + ] ], "keywords_forbid": [], "group": 1 diff --git "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/4.DISTINCT/distinct.md" "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/4.DISTINCT/distinct.md" index 52fba35ebf0768839354b4c96258f87da5cb8038..d66299b4ac1477886dc6cc5891858ac2b76a8dd5 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/4.DISTINCT/distinct.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/4.DISTINCT/distinct.md" @@ -26,7 +26,8 @@ create table goods( ## 答案 ```sql -select count(distinct price) from goods; +select count(distinct price) +from goods; ``` ## 选项 @@ -34,23 +35,27 @@ select count(distinct price) from goods; ### A ```sql -select count(distinct *) from goods; +select count(distinct *) +from goods; ``` ### B ```sql -select distinct count(price) from goods; +select distinct count(price) +from goods; ``` ### C ```sql -select count(price) from goods; +select count(price) +from goods; ``` ### D ```sql -select distinct price from goods; +select distinct price +from goods; ``` diff --git "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/5.ORDER BY/order_by.md" "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/5.ORDER BY/order_by.md" index ae73cc91810923bf3f6636c7e6fd5108a0c97657..7cc61b7cf1fa310a5d35e5ddbddfc65494ff2460 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/5.ORDER BY/order_by.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/5.ORDER BY/order_by.md" @@ -24,7 +24,9 @@ create table employee ## 答案 ```sql -select id, name, dept, salary from employee order by dept, salary desc; +select id, name, dept, salary +from employee +order by dept, salary desc; ``` ## 选项 @@ -32,28 +34,38 @@ select id, name, dept, salary from employee order by dept, salary desc; ### A ```sql -select id, name, dept, salary from employee order by dept, salary; +select id, name, dept, salary +from employee +order by dept, salary; ``` ### B ```sql -select id, name, dept, salary from employee order by dept desc, salary desc; +select id, name, dept, salary +from employee +order by dept desc, salary desc; ``` ### C ```sql -select id, name, dept, salary from employee order by dept and salary desc; +select id, name, dept, salary +from employee +order by dept and salary desc; ``` ### D ```sql -select id, name, dept, salary from employee order by dept, salary, id, name; +select id, name, dept, salary +from employee +order by dept, salary, id, name; ``` ### E ```sql -select id, name, dept, salary from employee order by dept, salary desc; +select id, name, dept, salary +from employee +order by dept, salary desc; ``` diff --git "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/6.UNION/config.json" "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/6.UNION/config.json" index 97e0731a14f3ab1eb97ed0ab9d613f801f0ac3ea..42f889f1e2028a0d95dbff6039739271f53267d4 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/6.UNION/config.json" +++ "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/6.UNION/config.json" @@ -1,12 +1,17 @@ { "node_id": "mysql-b57b6c08f5f240c6a997284e4448f088", - "keywords": ["union"], + "keywords": [ + "union" + ], "children": [], "export": [ "union.json" ], "keywords_must": [ - ["mysql", "union"] + [ + "mysql", + "union" + ] ], "keywords_forbid": [], "group": 1 diff --git "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/6.UNION/union.md" "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/6.UNION/union.md" index 641f9b82ab5cec2b8dbd6cfa42e83b2c29aa1c89..10b9885fd00873b29600b22dc72e3a33d9643d76 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/6.UNION/union.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/6.UNION/union.md" @@ -12,10 +12,10 @@ create table employee( ); create table customer( - id int primary key auto_increment, - name varchar(256), - address varchar(1024), - level int + id int primary key auto_increment, + name varchar(256), + address varchar(1024), + level int -- ignore more ) diff --git "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/8. \345\210\206\351\241\265\346\237\245\350\257\242/paged.md" "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/8. \345\210\206\351\241\265\346\237\245\350\257\242/paged.md" index 01790f6a1515994e665726b7570625391c7f7ddd..f858ca5518a4e078b4421b25990355a101b45fa3 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/8. \345\210\206\351\241\265\346\237\245\350\257\242/paged.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/2.\346\237\245\350\257\242\350\277\233\351\230\266/8. \345\210\206\351\241\265\346\237\245\350\257\242/paged.md" @@ -25,7 +25,11 @@ create table orders ## 答案 ```sql -select id, product_id, order_date, quantity, customer_id +select id, + product_id, + order_date, + quantity, + customer_id from orders where date = $1 offset $2 limit 100; @@ -36,7 +40,11 @@ offset $2 limit 100; ### 缺少 limit ```sql -select id, product_id, order_date, quantity, customer_id +select id, + product_id, + order_date, + quantity, + customer_id from orders where date = $1 offset $2; @@ -45,7 +53,11 @@ offset $2; ### 缺少 offset ```sql -select id, product_id, order_date, quantity, customer_id +select id, + product_id, + order_date, + quantity, + customer_id from orders where date = $1; ``` @@ -53,7 +65,11 @@ where date = $1; ### 结构不对 ```sql -select id, product_id, order_date, quantity, customer_id +select id, + product_id, + order_date, + quantity, + customer_id from orders where date = $1 and offset $2 and limit 100; diff --git "a/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/convert.md" "b/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/convert.md" index 61e4382fda398a1be458de2c603a2c8e77c35425..a0a900fa6497c4f98f02acaeda3bd23cb56e6870 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/convert.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/3.\345\206\205\347\275\256\345\207\275\346\225\260/5.\345\205\266\345\256\203\345\207\275\346\225\260/convert.md" @@ -18,7 +18,8 @@ select name from goods; ## 答案 ```sql -select convert(name using 'gb18030') from goods; +select convert(name using 'gb18030') +from goods; ``` ## 选项 @@ -27,27 +28,31 @@ select convert(name using 'gb18030') from goods; ### A ```sql -select str(name, 'gb18303') from goods; +select str(name, 'gb18303') +from goods; ``` ### B ```sql -select encode(decode(name, 'utf8mb4'), 'gb18303') from goods; +select encode(decode(name, 'utf8mb4'), 'gb18303') +from goods; ``` ### C ```sql -select convert(name from 'utf8mb4' to 'gb18303') from goods; +select convert(name from 'utf8mb4' to 'gb18303') +from goods; ``` ### D ```sql -select convert(name to 'gb18303') from goods; +select convert(name to 'gb18303') +from goods; ``` ### E diff --git "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/1. \350\256\241\346\225\260/count.md" "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/1. \350\256\241\346\225\260/count.md" index 1042a3161fc7fd9b0672b941816b9ed901d69538..e9422681d2351e63d2e9e6ce7f767bc2c4363910 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/1. \350\256\241\346\225\260/count.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/1. \350\256\241\346\225\260/count.md" @@ -17,7 +17,8 @@ mysql> select * from items; 当他执行 ```sql -select count(*), count(item) from items; +select count(*), count(item) +from items; ``` 会得到什么结果? diff --git "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/2. \346\261\202\345\222\214/sum.md" "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/2. \346\261\202\345\222\214/sum.md" index ae6ee7dea93f73be771acd693c0e5f899428ae6f..c72fd3a20e06714e36bdc5082b78aea673ba2366 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/2. \346\261\202\345\222\214/sum.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/2. \346\261\202\345\222\214/sum.md" @@ -4,14 +4,14 @@ Joe 想要得到 orders 表 ```sql create table orders ( - id int primary key auto_increment, - item_id int, - amount int, - unit_price decimal(12, 4), - total decimal(12, 4), - description varchar(2000), - ts timestamp default now(), - deal bool default false + id int primary key auto_increment, + item_id int, + amount int, + unit_price decimal(12, 4), + total decimal(12, 4), + description varchar(2000), + ts timestamp default now(), + deal bool default false ); ``` @@ -27,7 +27,9 @@ create table orders ( ## 答案 ```sql -select sum(total) from orders where deal and unit_price > 1000; +select sum(total) +from orders +where deal and unit_price > 1000; ``` ## 选项 @@ -35,17 +37,24 @@ select sum(total) from orders where deal and unit_price > 1000; ### A ```sql -select sum(total) from orders having deal and unit_price > 1000; +select sum(total) +from orders +having deal and unit_price > 1000; ``` ### B ```sql -select sum(total) from orders group by deal having unit_price > 1000; +select sum(total) +from orders +group by deal +having unit_price > 1000; ``` ### C ```sql -select sum(total) from orders order by deal and unit_price > 1000; +select sum(total) +from orders +order by deal and unit_price > 1000; ``` \ No newline at end of file diff --git "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/3.\346\234\200\345\260\217\345\200\274/min.md" "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/3.\346\234\200\345\260\217\345\200\274/min.md" index 2bef6c26aa5d0dab75217da64db9715628614ca3..eb6ef2bdd0389a119919f09ceba7d3071a64daf2 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/3.\346\234\200\345\260\217\345\200\274/min.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/3.\346\234\200\345\260\217\345\200\274/min.md" @@ -24,7 +24,9 @@ create table employee ## 答案 ```sql -select dept, min(salary) from employee group by dept; +select dept, min(salary) +from employee +group by dept; ``` ## 选项 @@ -32,17 +34,20 @@ select dept, min(salary) from employee group by dept; ### A ```sql -select dept, min(salary) from employee; +select dept, min(salary) +from employee; ``` ### B ```sql -select dept, min(salary) from employee order by dept; +select dept, min(salary) +from employee order by dept; ``` ### C ```sql -select dept, min(total) from employee; +select dept, min(total) +from employee; ``` \ No newline at end of file diff --git "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/5. \345\271\263\345\235\207\345\200\274/avg.md" "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/5. \345\271\263\345\235\207\345\200\274/avg.md" index 9bec946de9e46b326c695a5d5563c1a979709c59..af9a21473b82de58596e9f226f8b59ca632a0b89 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/5. \345\271\263\345\235\207\345\200\274/avg.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/5. \345\271\263\345\235\207\345\200\274/avg.md" @@ -24,7 +24,9 @@ create table employee ## 答案 ```sql -select dept, avg(salary) from employee group by dept; +select dept, avg(salary) +from employee +group by dept; ``` ## 选项 @@ -32,17 +34,22 @@ select dept, avg(salary) from employee group by dept; ### A ```sql -select dept, avg(salary) from employee; +select dept, avg(salary) +from employee; ``` ### B ```sql -select dept, avg(dept) from employee group by dept; +select dept, avg(dept) +from employee +group by dept; ``` ### C ```sql -select dept, avg(salary) from employee group by salary; +select dept, avg(salary) +from employee +group by salary; ``` diff --git "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/5. \345\271\263\345\235\207\345\200\274/config.json" "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/5. \345\271\263\345\235\207\345\200\274/config.json" index 7061a24e7a784f93d77bb5764205964b0ca92d94..27a53768eff2f8647508c6a1bbbc86e025fdb269 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/5. \345\271\263\345\235\207\345\200\274/config.json" +++ "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/5. \345\271\263\345\235\207\345\200\274/config.json" @@ -1,6 +1,9 @@ { "node_id": "mysql-11462fccf9d24d17a372d5c60af90f54", - "keywords": ["avg", "平均值"], + "keywords": [ + "avg", + "平均值" + ], "children": [], "export": [ "avg.json" diff --git "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/6.HAVING/config.json" "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/6.HAVING/config.json" index f49eae2b6bb6fbf83b4de99ebda7c06336678c52..080ccbf2cf5cd3303b172d4ade80f138352df7c7 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/6.HAVING/config.json" +++ "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/6.HAVING/config.json" @@ -6,7 +6,10 @@ "having.json" ], "keywords_must": [ - ["mysql", "having"] + [ + "mysql", + "having" + ] ], "keywords_forbid": [], "group": 1 diff --git "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/6.HAVING/having.md" "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/6.HAVING/having.md" index 6f2958b57ae38bf4d74bffe75c855f30586fca59..9602b2fe6b72755ac0ebfc7d81dd3d90670511e5 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/6.HAVING/having.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/4.\350\201\232\345\220\210\345\222\214\345\210\206\347\273\204/6.HAVING/having.md" @@ -24,7 +24,10 @@ create table employee ## 答案 ```sql -select dept from employee group by dept having sum(salary) > 100000; +select dept +from employee +group by dept +having sum(salary) > 100000; ``` ## 选项 @@ -32,25 +35,36 @@ select dept from employee group by dept having sum(salary) > 100000; ### A ```sql -select dept from employee group by dept where sum(salary) > 100000; +select dept +from employee +group by dept where sum(salary) > 100000; ``` ### B ```sql -select dept from employee where sum(salary) > 100000 group by dept; +select dept +from employee +where sum(salary) > 100000 +group by dept; ``` ### C ```sql -select dept from employee where sum(salary) > 100000 order by dept; +select dept +from employee +where sum(salary) > 100000 +order by dept; ``` ### D ```sql -select dept from employee group by dept where sum(salary) > 100000; +select dept +from employee +group by dept +where sum(salary) > 100000; ``` diff --git "a/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/1.\347\233\270\345\205\263\345\255\220\346\237\245\350\257\242/subquery.md" "b/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/1.\347\233\270\345\205\263\345\255\220\346\237\245\350\257\242/subquery.md" index 0a1568fc4442f8feb563f0571417ac4fe06f776e..160d7f13880b848583edf237e1da7a2cedfa5d2b 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/1.\347\233\270\345\205\263\345\255\220\346\237\245\350\257\242/subquery.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/1.\347\233\270\345\205\263\345\255\220\346\237\245\350\257\242/subquery.md" @@ -48,7 +48,8 @@ having salary > max(salary) ```sql select l.id, l.name, l.dept, l.salary from employee as l - join employee as r on l.salary > max(r.salary) + join employee as r + on l.salary > max(r.salary) where r.dept = 'sale' group by r.dept ``` @@ -58,7 +59,9 @@ group by r.dept ```sql select id, name, dept, salary from employee -having salary > (select max(salary) from employee where dept = 'sale') +having salary > (select max(salary) + from employee + where dept = 'sale') ``` diff --git "a/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/2. ANY/any.md" "b/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/2. ANY/any.md" index 7179d35012989c8459f90fc8d162ba4b051f675d..841e6d994a0c29f7b01fa10153d82624fc9ae149 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/2. ANY/any.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/2. ANY/any.md" @@ -25,7 +25,9 @@ create table employee( ```sql select id, name, dept, salary from employee as o -where o.salary < any(select salary from employee as i where i.dept=o.dept) +where o.salary < any(select salary + from employee as i + where i.dept=o.dept) ``` ## 选项 @@ -35,7 +37,8 @@ where o.salary < any(select salary from employee as i where i.dept=o.dept) ```sql select id, name, dept, salary from employee as o -join employee as i on o.dept = i.dept and o.salary < i.salary +join employee as i on + o.dept = i.dept and o.salary < i.salary ``` ### B @@ -43,7 +46,8 @@ join employee as i on o.dept = i.dept and o.salary < i.salary ```sql select o.id, o.name, o.dept, o.salary from employee as o -left join employee as i on o.dept = i.dept and o.salary < i.salary +left join employee as i on + o.dept = i.dept and o.salary < i.salary where i.id is null; ``` @@ -52,6 +56,7 @@ where i.id is null; ```sql select o.id, o.name, o.dept, o.salary from employee as o - left join employee as i on o.dept = i.dept and o.salary < i.salary + left join employee as i + on o.dept = i.dept and o.salary < i.salary where i.id is not null; ``` \ No newline at end of file diff --git "a/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/3.ALL/all.md" "b/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/3.ALL/all.md" index fb7614b9e217a0ca038b92cf2bfd4356ecfe427d..f0f97ab637ca60915d50b4f978553a6830c352d3 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/3.ALL/all.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/3.ALL/all.md" @@ -25,7 +25,10 @@ create table employee( ```sql select id, name, dept from employee as o -where 'assistant' != all(select post from employee as i where o.dept = i.dept); +where 'assistant' != + all(select post + from employee as i + where o.dept = i.dept); ``` ## 选项 @@ -35,7 +38,10 @@ where 'assistant' != all(select post from employee as i where o.dept = i.dept); ```sql select id, name, dept from employee as o -where 'assistant' = all(select post from employee as i where o.dept = i.dept); +where 'assistant' = + all(select post + from employee as i + where o.dept = i.dept); ``` ### B @@ -43,14 +49,19 @@ where 'assistant' = all(select post from employee as i where o.dept = i.dept); ```sql select id, name, dept from employee as o -where 'assistant' != all(select post from employee as i where o.dept = i.dept); +where 'assistant' != + all(select post + from employee as i + where o.dept = i.dept); ``` ### C ```sql select id, name, dept from employee as o -where 'assistant' != all(select post from employee as i); +where 'assistant' != + all(select post + from employee as i); ``` ### D @@ -58,5 +69,8 @@ where 'assistant' != all(select post from employee as i); ```sql select id, name, dept from employee as o -where 'assistant' != ANY(select post from employee as i where o.dept = i.dept); +where 'assistant' != + ANY(select post + from employee as i + where o.dept = i.dept); ``` \ No newline at end of file diff --git "a/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/4.EXISTS/exists.md" "b/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/4.EXISTS/exists.md" index 095e382017a95daa0b1d7280dc615b5d7a3e3b89..9753b51b9426f572d60216385b6aebb6884c52ec 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/4.EXISTS/exists.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/4.EXISTS/exists.md" @@ -26,7 +26,10 @@ create table employee( ```sql select id, name, dept from employee as o -where not exists(select * from employee as i where o.dept = i.dept and post='assistant'); +where not exists( + select * + from employee as i + where o.dept = i.dept and post='assistant'); ``` ## 选项 @@ -36,14 +39,19 @@ where not exists(select * from employee as i where o.dept = i.dept and post='ass ```sql select id, name, dept from employee as o -where exists(select * from employee as i where o.dept = i.dept and post='assistant'); +where exists( + select * + from employee as i + where o.dept = i.dept and post='assistant'); ``` ### B ```sql select id, name, dept from employee as o -where 'assistant' != exists(select post from employee as i); +where 'assistant' != exists( + select post + from employee as i); ``` ### C @@ -51,5 +59,8 @@ where 'assistant' != exists(select post from employee as i); ```sql select id, name, dept from employee as o -where 'assistant' = not exists(select post from employee as i where o.dept = i.dept); +where 'assistant' = not exists( + select post + from employee as i + where o.dept = i.dept); ``` \ No newline at end of file diff --git "a/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/5. IN/in.md" "b/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/5. IN/in.md" index fe43dccabf83711fae50b0ea1a660fed9302b56c..ac05ae169b76c0fa0837d554344aadbb55b53997 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/5. IN/in.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/5. IN/in.md" @@ -43,7 +43,9 @@ where dept in (select 'dev', 'hr'); ```sql select id, dept, name, post from employee -where dept in (select * from 'dev', 'hr'); +where dept in + (select * + from 'dev', 'hr'); ``` ### C diff --git "a/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/6. \345\210\227\345\255\220\346\237\245\350\257\242/in_column.md" "b/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/6. \345\210\227\345\255\220\346\237\245\350\257\242/in_column.md" index 07e4b531e913b147e4f5ffe12f6274e3d126afab..6afe590531977349c39fe70759bbe2137fd3d444 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/6. \345\210\227\345\255\220\346\237\245\350\257\242/in_column.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/5.\345\255\220\346\237\245\350\257\242/6. \345\210\227\345\255\220\346\237\245\350\257\242/in_column.md" @@ -24,10 +24,10 @@ create table employee ## 答案 ```sql -select distinct(dept) as dept, - (select count(*) - from employee as i - where i.dept = o.dept) as emp +select distinct(dept) as dept, + (select count(*) + from employee as i + where i.dept = o.dept) as emp from employee as o; ``` @@ -36,28 +36,28 @@ from employee as o; ### A ```sql -select distinct(dept) as dept, - (select count(*) - from employee as i) as emp +select distinct(dept) as dept, + (select count(*) + from employee as i) as emp from employee as o; ``` ### B ```sql -select distinct(dept) as dept, - (select count(*) - from employee - where dept = dept) as emp +select distinct(dept) as dept, + (select count(*) + from employee + where dept = dept) as emp from employee ``` ### C ```sql -select dept as dept, - (select count(*) - from employee as i - where i.dept = o.dept) as emp +select dept as dept, + (select count(*) + from employee as i + where i.dept = o.dept) as emp from employee as o ``` \ No newline at end of file diff --git "a/data/2.MySQL\344\270\255\351\230\266/6.\350\277\236\346\216\245\346\237\245\350\257\242/2. LEFT JOIN/left_join.md" "b/data/2.MySQL\344\270\255\351\230\266/6.\350\277\236\346\216\245\346\237\245\350\257\242/2. LEFT JOIN/left_join.md" index 2398f054967921290be639bc853fcd3110b7fce5..88649510412e120402eafac6bbb2fa8847bbd4e1 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/6.\350\277\236\346\216\245\346\237\245\350\257\242/2. LEFT JOIN/left_join.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/6.\350\277\236\346\216\245\346\237\245\350\257\242/2. LEFT JOIN/left_join.md" @@ -34,8 +34,11 @@ Joe 想要列出所有的部门,如果这个部门有部门助理(post 为 ` ```sql select d.id, d.name, e.name as assistant from department as d - left join employee as e on e.dept = d.id -where e.post = 'assistant' + left join (select name, dept_id + from employee + where post='assistant') as e on e.dept_id = d.id + + ``` ## 选项 diff --git "a/data/2.MySQL\344\270\255\351\230\266/6.\350\277\236\346\216\245\346\237\245\350\257\242/3. RIGHT JOIN/right_join.md" "b/data/2.MySQL\344\270\255\351\230\266/6.\350\277\236\346\216\245\346\237\245\350\257\242/3. RIGHT JOIN/right_join.md" index 37305199b7295c501cbf7cc1cd472eee84f33128..43ca05f929770646fafe7b60a495f3ed70646c80 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/6.\350\277\236\346\216\245\346\237\245\350\257\242/3. RIGHT JOIN/right_join.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/6.\350\277\236\346\216\245\346\237\245\350\257\242/3. RIGHT JOIN/right_join.md" @@ -46,7 +46,7 @@ where d.id is null; ```sql select e.id, e.name, e.dept from employee as e - right join department as d on d.id = e.dept + right join department as d on d.id = e.dept where e.id is null; ``` @@ -55,7 +55,7 @@ where e.id is null; ```sql select e.id, e.name, e.dept from employee as e - right join department as d on d.id = e.dept + right join department as d on d.id = e.dept where d.id is null; ``` diff --git "a/data/2.MySQL\344\270\255\351\230\266/7. \347\264\242\345\274\225/2.\345\210\233\345\273\272\347\264\242\345\274\225/config.json" "b/data/2.MySQL\344\270\255\351\230\266/7. \347\264\242\345\274\225/2.\345\210\233\345\273\272\347\264\242\345\274\225/config.json" index 2094d1ab96a2100d83dbca773f59f56814329865..9f8abae295288cdf59b4ac45b9655d3cce2f3ddd 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/7. \347\264\242\345\274\225/2.\345\210\233\345\273\272\347\264\242\345\274\225/config.json" +++ "b/data/2.MySQL\344\270\255\351\230\266/7. \347\264\242\345\274\225/2.\345\210\233\345\273\272\347\264\242\345\274\225/config.json" @@ -1,6 +1,9 @@ { "node_id": "mysql-fe65d5c615ad40f8ac056cc654f2d788", - "keywords": ["create index", "创建索引"], + "keywords": [ + "create index", + "创建索引" + ], "children": [], "export": [ "create_index.json" diff --git "a/data/2.MySQL\344\270\255\351\230\266/7. \347\264\242\345\274\225/2.\345\210\233\345\273\272\347\264\242\345\274\225/create_index.md" "b/data/2.MySQL\344\270\255\351\230\266/7. \347\264\242\345\274\225/2.\345\210\233\345\273\272\347\264\242\345\274\225/create_index.md" index 082df2f1d9c48f1add4028d25f4f5a366e104859..ec6897552453b0074e493de313fc0067ebc35758 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/7. \347\264\242\345\274\225/2.\345\210\233\345\273\272\347\264\242\345\274\225/create_index.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/7. \347\264\242\345\274\225/2.\345\210\233\345\273\272\347\264\242\345\274\225/create_index.md" @@ -27,7 +27,8 @@ create table goods( ## 答案 ```sql -create index idx_goods_category on goods(category_id); +create index idx_goods_category + on goods(category_id); ``` ## 选项 @@ -35,17 +36,20 @@ create index idx_goods_category on goods(category_id); ### A ```sql -create unique index idx_goods_category on goods(category_id); +create unique index idx_goods_category + on goods(category_id); ``` ### B ```sql -create index idx_goods_category on goods(name); +create index idx_goods_category + on goods(name); ``` ### C ```sql -alter table goods add unique index (category_id); +alter table goods + add unique index (category_id); ``` \ No newline at end of file diff --git "a/data/2.MySQL\344\270\255\351\230\266/7. \347\264\242\345\274\225/3.\345\210\240\351\231\244\347\264\242\345\274\225/drop_index.md" "b/data/2.MySQL\344\270\255\351\230\266/7. \347\264\242\345\274\225/3.\345\210\240\351\231\244\347\264\242\345\274\225/drop_index.md" index 920b3449577bf7af2ee3379ed7758bdcf521b7d0..962e97115b88fa49fdd7e75fd088b9eb685d234a 100644 --- "a/data/2.MySQL\344\270\255\351\230\266/7. \347\264\242\345\274\225/3.\345\210\240\351\231\244\347\264\242\345\274\225/drop_index.md" +++ "b/data/2.MySQL\344\270\255\351\230\266/7. \347\264\242\345\274\225/3.\345\210\240\351\231\244\347\264\242\345\274\225/drop_index.md" @@ -20,7 +20,8 @@ show index from goods; 查看 goods 表的索引(假设查到是 idx_goods_category),然后执行 ```sql -alter table goods drop index idx_goods_category; +alter table goods + drop index idx_goods_category; ``` ## 选项 @@ -36,7 +37,8 @@ show index from goods; 查看 goods 表的索引(假设查到是 idx_goods_category),然后执行 ```sql -alter table goods delete index idx_goods_category; +alter table goods + delete index idx_goods_category; ``` ### B @@ -50,7 +52,8 @@ show index from goods; 查看 goods 表的索引(假设查到是 idx_goods_category),然后执行 ```sql -alter table goods remove index idx_goods_category; +alter table goods + remove index idx_goods_category; ``` ### C @@ -64,7 +67,8 @@ show index from goods; 查看 goods 表的索引(假设查到是 idx_goods_category),然后执行 ```sql -alter table goods drop idx_goods_category; +alter table goods + drop idx_goods_category; ``` diff --git "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/1.\345\224\257\344\270\200\347\264\242\345\274\225/unique.md" "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/1.\345\224\257\344\270\200\347\264\242\345\274\225/unique.md" index f0316a958649b162a03bec0a55fc3b98107278b9..3b6b0dbc39f481631852e1c05a8cd82e1a970fb3 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/1.\345\224\257\344\270\200\347\264\242\345\274\225/unique.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/1.\345\224\257\344\270\200\347\264\242\345\274\225/unique.md" @@ -25,7 +25,8 @@ Joe 需要确保同一个类型下没有重名的商品,他应该怎么做? ## 答案 ```sql -alter table goods add unique index (category_id, name); +alter table goods + add unique index (category_id, name); ``` ## 选项 @@ -33,17 +34,20 @@ alter table goods add unique index (category_id, name); ### A ```sql -alter table goods add index (category_id, name); +alter table goods + add index (category_id, name); ``` ### B ```sql -alter table goods add unique index (category_id + name); +alter table goods + add unique index (category_id + name); ``` ### C ```sql -alter table goods add unique index (concat(category_id, name)); +alter table goods + add unique index (concat(category_id, name)); ``` diff --git "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/2.\345\205\250\345\200\274\345\214\271\351\205\215/config.json" "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/2.\345\205\250\345\200\274\345\214\271\351\205\215/config.json" index 90ad368262934e2d68b811e80ef0ca25e414526b..d1d673481f42b498c4c7ada060f51113a91a7c25 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/2.\345\205\250\345\200\274\345\214\271\351\205\215/config.json" +++ "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/2.\345\205\250\345\200\274\345\214\271\351\205\215/config.json" @@ -7,7 +7,12 @@ "export": [ "total_index.json" ], - "keywords_must": [["mysql", "全值匹配"]], + "keywords_must": [ + [ + "mysql", + "全值匹配" + ] + ], "keywords_forbid": [], "group": 2 } \ No newline at end of file diff --git "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/2.\345\205\250\345\200\274\345\214\271\351\205\215/total_index.md" "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/2.\345\205\250\345\200\274\345\214\271\351\205\215/total_index.md" index b98932fbc8e393307baa49d1de0ac8175fcfe99c..623f6ed8f1b27568f7e875b9557d921e20e366d7 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/2.\345\205\250\345\200\274\345\214\271\351\205\215/total_index.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/2.\345\205\250\345\200\274\345\214\271\351\205\215/total_index.md" @@ -25,7 +25,8 @@ create table goods( ## 答案 ```sql -alter table goods add index (name, price); +alter table goods + add index (name, price); ``` ## 选项 @@ -39,11 +40,14 @@ alter table goods add index (name, price); 建立一个计算字段: ```sql -alter table goods add summary varchar(1024) generated always as (concat(name, '(', 0.5, ')')); +alter table goods + add summary varchar(1024) + generated always as (concat(name, '(', 0.5, ')')); ``` ### C ```sql -alter table goods add index (concat(name, price)); +alter table goods + add index (concat(name, price)); ``` \ No newline at end of file diff --git "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/3.\345\214\271\351\205\215\351\241\272\345\272\217/match_fields.md" "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/3.\345\214\271\351\205\215\351\241\272\345\272\217/match_fields.md" index 2607b91f20331c44f9e702050be04752a7f6ae1a..6c391144cc5a318d0208bcef5950015ef27b8b5b 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/3.\345\214\271\351\205\215\351\241\272\345\272\217/match_fields.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/3.\345\214\271\351\205\215\351\241\272\345\272\217/match_fields.md" @@ -29,7 +29,12 @@ Joe 发现有大量查询 `select id, category_id, name, price from goods where 将该查询改写为 ```sql -select id, category_id, name, price from goods where category_id=? and name=?; +select id, + category_id, + name, + price +from goods +where category_id=? and name=?; ``` ## 选项 @@ -39,7 +44,12 @@ select id, category_id, name, price from goods where category_id=? and name=?; 将该查询改写为 ```sql -select id, category_id, name, price from goods where category_id and name= (?, ?); +select id, + category_id, + name, + price +from goods +where category_id and name= (?, ?); ``` ### B @@ -47,7 +57,12 @@ select id, category_id, name, price from goods where category_id and name= (?, ? 将该查询改写为 ```sql -select id, category_id, name, price from goods where not (category_id !=? or name != ?); +select id, + category_id, + name, + price +from goods +where not (category_id !=? or name != ?); ``` ### C @@ -55,6 +70,11 @@ select id, category_id, name, price from goods where not (category_id !=? or nam 将该查询改写为 ```sql -select id, category_id, name, price from goods where not (category_id !=?) and not (name != ?); +select id, + category_id, + name, + price +from goods +where not (category_id !=?) and not (name != ?); ``` diff --git "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/4.\347\273\204\345\220\210\347\264\242\345\274\225/combinate.md" "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/4.\347\273\204\345\220\210\347\264\242\345\274\225/combinate.md" index 7b2d5d816af480b39ff4a0cdc2b5132f17350826..b753404cbebf3b363a662f7cef14f304d5173db7 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/4.\347\273\204\345\220\210\347\264\242\345\274\225/combinate.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/4.\347\273\204\345\220\210\347\264\242\345\274\225/combinate.md" @@ -14,7 +14,19 @@ create table goods( ) ``` -现有大量查询 `select id, category_id, name, price, stock from goods where stock=? and category_id=? and name like ?`, +现有大量查询 +```sql +select + id, + category_id, + name, + price, + stock +from goods +where stock=? + and category_id=? + and name like ?`, +``` Joe 应该如何优化?
@@ -27,7 +39,8 @@ Joe 应该如何优化? ## 答案 ```sql -alter table goods add index (stock, category_id, name); +alter table goods + add index (stock, category_id, name); ``` ## 选项 @@ -35,17 +48,20 @@ alter table goods add index (stock, category_id, name); ### A ```sql -alter table goods add index (stock and category_id and name); +alter table goods + add index (stock and category_id and name); ``` ### B ```sql -alter table goods add index (concat(stock, category_id, name)); +alter table goods + add index (concat(stock, category_id, name)); ``` ### C ```sql -alter table goods add index (stock + category_id + name); +alter table goods + add index (stock + category_id + name); ``` diff --git "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/5.\347\251\272\351\227\264\347\264\242\345\274\225/geo_index.md" "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/5.\347\251\272\351\227\264\347\264\242\345\274\225/geo_index.md" index 23cad41063c6e09963d76eca33c01f36ca745179..bd8fe977996b127056daaf7c11c07ede7ed48391 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/5.\347\251\272\351\227\264\347\264\242\345\274\225/geo_index.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/5.\347\251\272\351\227\264\347\264\242\345\274\225/geo_index.md" @@ -22,8 +22,10 @@ create table shop ( ## 答案 ```sql -alter table shop modify location GEOMETRY not null; -alter table shop add INDEX geo_index(location); +alter table shop + modify location GEOMETRY not null; +alter table shop + add INDEX geo_index(location); ``` ## 选项 @@ -31,25 +33,31 @@ alter table shop add INDEX geo_index(location); ### A ```sql -alter table shop add INDEX geo_index(location); +alter table shop + add INDEX geo_index(location); ``` ### B ```sql -alter table shop add INDEX location; +alter table shop + add INDEX location; ``` ### C ```sql -alter table shop modify location GEOMETRY not null; -alter table shop add INDEX location; +alter table shop + modify location GEOMETRY not null; +alter table shop + add INDEX location; ``` ### D ```sql -alter table shop modify location GEOMETRY not null; -alter table shop add INDEX location; +alter table shop + modify location GEOMETRY not null; +alter table shop + add INDEX location; ``` diff --git "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/6.\345\205\250\346\226\207\347\264\242\345\274\225/full_text_index.md" "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/6.\345\205\250\346\226\207\347\264\242\345\274\225/full_text_index.md" index e6fc999b37c2de8b75cfbdac2a83728102febec8..06eb5cd03e633012497ff2e72aa7596e511d635f 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/6.\345\205\250\346\226\207\347\264\242\345\274\225/full_text_index.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/6.\345\205\250\346\226\207\347\264\242\345\274\225/full_text_index.md" @@ -22,7 +22,8 @@ create table shop ( ## 答案 ```sql -alter table shop add fulltext(description); +alter table shop + add fulltext(description); ``` ## 选项 @@ -30,17 +31,20 @@ alter table shop add fulltext(description); ### A ```sql -alter table shop add index fulltext(description); +alter table shop + add index fulltext(description); ``` ### B ```sql -alter table shop create fulltext(description); +alter table shop + create fulltext(description); ``` ### C ```sql -alter table shop alter description add fulltext(description); +alter table shop + alter description add fulltext(description); ``` \ No newline at end of file diff --git "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/7.\351\232\220\350\227\217\347\264\242\345\274\225/config.json" "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/7.\351\232\220\350\227\217\347\264\242\345\274\225/config.json" index 5918ca48d3db5ef5dd5885299728b693e03d0714..b64ebca6f70291798a5a503a15d68e43d30495a0 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/7.\351\232\220\350\227\217\347\264\242\345\274\225/config.json" +++ "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/7.\351\232\220\350\227\217\347\264\242\345\274\225/config.json" @@ -1,6 +1,10 @@ { "node_id": "mysql-c57e1195b0914cd38798ce029156ec87", - "keywords": ["invisible", "visible", "隐藏索引"], + "keywords": [ + "invisible", + "visible", + "隐藏索引" + ], "children": [], "export": [ "invisible.json" diff --git "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/7.\351\232\220\350\227\217\347\264\242\345\274\225/invisible.md" "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/7.\351\232\220\350\227\217\347\264\242\345\274\225/invisible.md" index 75d122f9b4da2edc85678b60e94f90adfa970a95..09d4314d6a600044a224d20bc74e88f44c90d923 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/7.\351\232\220\350\227\217\347\264\242\345\274\225/invisible.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/7.\351\232\220\350\227\217\347\264\242\345\274\225/invisible.md" @@ -28,13 +28,15 @@ Joe 应该怎么做? 先执行 ```sql -alter table shop alter index description invisible ; +alter table shop + alter index description invisible ; ``` 将索引隐藏,观察确认没有影响后再执行 ```sql -alter table shop drop index description; +alter table shop + drop index description; ``` 删除。 @@ -47,7 +49,8 @@ alter table shop drop index description; 先备份 shop 表,然后执行 ```sql -alter table shop drop index description; +alter table shop + drop index description; ``` 删除,有问题的话从备份文件恢复。 @@ -60,13 +63,15 @@ alter table shop drop index description; 先执行 ```sql -alter table shop alter index description invisible ; +alter table shop + alter index description invisible ; ``` 将索引隐藏,确认后再执行 ```sql -alter table shop alter index description visible ; +alter table shop + alter index description visible ; ``` 恢复索引可见。 \ No newline at end of file diff --git "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/8.\345\207\275\346\225\260\345\222\214\350\241\250\350\276\276\345\274\217\347\264\242\345\274\225/daily_payment.md" "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/8.\345\207\275\346\225\260\345\222\214\350\241\250\350\276\276\345\274\217\347\264\242\345\274\225/daily_payment.md" index e55af79c5f447f73c57ef83510e84982be9ce885..20e8dca7f2dfa38dd937502da4b745f5d45ea489 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/8.\345\207\275\346\225\260\345\222\214\350\241\250\350\276\276\345\274\217\347\264\242\345\274\225/daily_payment.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/1.\346\267\261\345\205\245\347\264\242\345\274\225/8.\345\207\275\346\225\260\345\222\214\350\241\250\350\276\276\345\274\217\347\264\242\345\274\225/daily_payment.md" @@ -40,7 +40,8 @@ mysql> desc payment; 建立表达式索引 ```sql -alter table payment add index idx_payment_date((date(payment_date))); +alter table payment + add index idx_payment_date((date(payment_date))); ``` ## 选项 @@ -50,7 +51,8 @@ alter table payment add index idx_payment_date((date(payment_date))); 建立视图 ```sql -create view view_daily_payment as select date(payment_date) as day, amount from payment; +create view view_daily_payment as + select date(payment_date) as day, amount from payment; ``` 然后在视图 view_daily_payment 上执行 @@ -75,7 +77,8 @@ create index idx_payment_date on payment(payment_date); 建立计算列 ```sql -alter table payment add day date generated always as (date(payment_date)) stored; +alter table payment add day date + generated always as (date(payment_date)) stored; ``` 然后使用它改写查询 diff --git "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/1.CTE\345\222\214\351\200\222\345\275\222\346\237\245\350\257\242/continuous.md" "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/1.CTE\345\222\214\351\200\222\345\275\222\346\237\245\350\257\242/continuous.md" index 57c0ab40ab3fdb36c901f430cd2a9e3e10680505..ab6ad751c9b98f81eb94ebe8368547840dd54089 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/1.CTE\345\222\214\351\200\222\345\275\222\346\237\245\350\257\242/continuous.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/1.CTE\345\222\214\351\200\222\345\275\222\346\237\245\350\257\242/continuous.md" @@ -28,13 +28,14 @@ create table orders ## 答案 ```sql -with recursive r(id) as (select id - from orders - where id = $1 - union - select d.id - from orders as d - join r on d.id = r.id + 1) +with recursive r(id) as ( + select id + from orders + where id = $1 + union + select d.id + from orders as d + join r on d.id = r.id + 1) select orders.id, content from orders join r on orders.id = r.id; @@ -50,8 +51,8 @@ from orders ```sql select data.id, content -from orders - join orders as r on orders.id = r.id - 1 +from orders + join orders as r on orders.id = r.id - 1 where id = $1; ``` @@ -60,7 +61,10 @@ where id = $1; ```sql select id, content from orders -where id in (select id from orders where id = id + 1); +where id in ( + select id + from orders + where id = id + 1); ``` ### D diff --git "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/salary.md" "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/salary.md" index f312bcf338747eef509f6c8e621c0a818b110e53..5f6979b658b87f7280fe3547ab868843af10f6e7 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/salary.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/2.Window Function/salary.md" @@ -25,7 +25,13 @@ create table employee ```sql select id, name, dept, salary -from (select id, name, dept, salary, rank() over (partition by dept order by salary desc) as r +from (select id, + name, + dept, + salary, + rank() over ( + partition by dept + order by salary desc) as r from employee) as t where r <= 5; ``` @@ -58,16 +64,23 @@ where count(r.id) <= 5; ```sql select l.id, l.name, l.dept, l.salary from employee as l - join (select max(salary, 5) as salary, dept - from employee - group by dept) as r - on l.dept = r.dept and l.salary = r.salary + join ( + select max(salary, 5) as salary, dept + from employee + group by dept) as r + on l.dept = r.dept and l.salary = r.salary ``` ### 结构错误 ```sql -select id, name, dept, salary, rank() over (partition by dept order by salary desc) as r +select id, + name, + dept, + salary, + rank() over ( + partition by dept + order by salary desc) as r from employee where r <= 5; ``` @@ -75,7 +88,13 @@ where r <= 5; ### 结构错误 ```sql -select id, name, dept, salary, rank() as r over (partition by dept order by salary desc) +select id, + name, + dept, + salary, + rank() as r over ( + partition by dept + order by salary desc) from employee where r <= 5; ``` diff --git "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/3.\351\200\217\350\247\206\350\241\250 /config.json" "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/3.\351\200\217\350\247\206\350\241\250 /config.json" index 39de68b6efa9e4400bf14c615cec6303852152e0..f003a5e424f9f2c5d7b1b074dbe8809fc3d38294 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/3.\351\200\217\350\247\206\350\241\250 /config.json" +++ "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/3.\351\200\217\350\247\206\350\241\250 /config.json" @@ -9,7 +9,9 @@ "export": [ "pivot.json" ], - "keywords_must": ["mysql"], + "keywords_must": [ + "mysql" + ], "keywords_forbid": [], "group": 1 } \ No newline at end of file diff --git "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/3.\351\200\217\350\247\206\350\241\250 /pivot.md" "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/3.\351\200\217\350\247\206\350\241\250 /pivot.md" index 122e39013cb6e7252a9f69dcf3a4da70cb38f575..b5a960fee04ea6bc0be6576c4335bbdbd4f30972 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/3.\351\200\217\350\247\206\350\241\250 /pivot.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/3.\351\200\217\350\247\206\350\241\250 /pivot.md" @@ -25,18 +25,30 @@ create index on sales(created_at); ```sql select sku_id, - sum(case extract(month from created_at) when 1 then amount else 0 end) as Jan, - sum(case extract(month from created_at) when 2 then amount else 0 end) as Feb, - sum(case extract(month from created_at) when 3 then amount else 0 end) as Mar, - sum(case extract(month from created_at) when 4 then amount else 0 end) as Apr, - sum(case extract(month from created_at) when 5 then amount else 0 end) as May, - sum(case extract(month from created_at) when 6 then amount else 0 end) as June, - sum(case extract(month from created_at) when 7 then amount else 0 end) as July, - sum(case extract(month from created_at) when 8 then amount else 0 end) as Aug, - sum(case extract(month from created_at) when 9 then amount else 0 end) as Sept, - sum(case extract(month from created_at) when 10 then amount else 0 end) as Oct, - sum(case extract(month from created_at) when 11 then amount else 0 end) as Nov, - sum(case extract(month from created_at) when 12 then amount else 0 end) as Dec + sum(case extract(month from created_at) + when 1 then amount else 0 end) as Jan, + sum(case extract(month from created_at) + when 2 then amount else 0 end) as Feb, + sum(case extract(month from created_at) + when 3 then amount else 0 end) as Mar, + sum(case extract(month from created_at) + when 4 then amount else 0 end) as Apr, + sum(case extract(month from created_at) + when 5 then amount else 0 end) as May, + sum(case extract(month from created_at) + when 6 then amount else 0 end) as June, + sum(case extract(month from created_at) + when 7 then amount else 0 end) as July, + sum(case extract(month from created_at) + when 8 then amount else 0 end) as Aug, + sum(case extract(month from created_at) + when 9 then amount else 0 end) as Sept, + sum(case extract(month from created_at) + when 10 then amount else 0 end) as Oct, + sum(case extract(month from created_at) + when 11 then amount else 0 end) as Nov, + sum(case extract(month from created_at) + when 12 then amount else 0 end) as Dec from sales where created_at between '2020-01-01'::timestamp and '2021-01-01'::timestamp group by sku_id; @@ -78,18 +90,30 @@ group by sku_id, extract(month from created_at); ```sql select sku_id, - sum(amount having extract(month from created_at) = 1) as Jan, - sum(amount having extract(month from created_at) = 2) as Feb, - sum(amount having extract(month from created_at) = 3) as Mar, - sum(amount having extract(month from created_at) = 4) as Apr, - sum(amount having extract(month from created_at) = 5) as May, - sum(amount having extract(month from created_at) = 6) as June, - sum(amount having extract(month from created_at) = 7) as July, - sum(amount having extract(month from created_at) = 8) as Aug, - sum(amount having extract(month from created_at) = 9) as Sept, - sum(amount having extract(month from created_at) = 10) as Oct, - sum(amount having extract(month from created_at) = 11) as Nov, - sum(amount having extract(month from created_at) = 12) as Dec + sum(amount having + extract(month from created_at) = 1) as Jan, + sum(amount having + extract(month from created_at) = 2) as Feb, + sum(amount having + extract(month from created_at) = 3) as Mar, + sum(amount having + extract(month from created_at) = 4) as Apr, + sum(amount having + extract(month from created_at) = 5) as May, + sum(amount having + extract(month from created_at) = 6) as June, + sum(amount having + extract(month from created_at) = 7) as July, + sum(amount having + extract(month from created_at) = 8) as Aug, + sum(amount having + extract(month from created_at) = 9) as Sept, + sum(amount having + extract(month from created_at) = 10) as Oct, + sum(amount having + extract(month from created_at) = 11) as Nov, + sum(amount having + extract(month from created_at) = 12) as Dec from sales where created_at between '2020-01-01'::timestamp and '2021-01-01'::timestamp group by sku_id, extract(month from created_at); diff --git "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/4.Double Not Exists/DoubleNotExists.md" "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/4.Double Not Exists/DoubleNotExists.md" index 7f85ef9d97ef49c1f6c287960f42efb7f45fab56..8213784e4f786a9a700c364959d567996dc23964 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/4.Double Not Exists/DoubleNotExists.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/4.Double Not Exists/DoubleNotExists.md" @@ -46,14 +46,14 @@ Joe 想要找出参与了所有投标的企业(有围标嫌疑),那么这 select * from company where not exists( - select * - from invitation - where not exists( - select * - from bids - where invitation.id = bids.invitation_id - and bids.company_id = company.id - ) + select * + from invitation + where not exists( + select * + from bids + where invitation.id = bids.invitation_id + and bids.company_id = company.id + ) ) ``` @@ -82,7 +82,9 @@ where id = any (select company_id ```sql select * from company -where company.id in (select distinct company_id from bids) +where company.id in ( + select distinct company_id + from bids) ``` ### D @@ -91,8 +93,8 @@ where company.id in (select distinct company_id from bids) select * from company where exists( - select * - from bids - where bids.company_id = company.id - ) + select * + from bids + where bids.company_id = company.id +) ``` \ No newline at end of file diff --git "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/4.Double Not Exists/config.json" "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/4.Double Not Exists/config.json" index d59135eff61712b8255ee71dc9ed8349c7f75580..217ae8d2f5afcbe5e9eb58862213791695702e60 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/4.Double Not Exists/config.json" +++ "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/4.Double Not Exists/config.json" @@ -9,7 +9,9 @@ "export": [ "DoubleNotExists.json" ], - "keywords_must": ["mysql"], + "keywords_must": [ + "mysql" + ], "keywords_forbid": [], "groups": 2 } \ No newline at end of file diff --git "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/5.\345\206\231\345\205\245\345\222\214\345\206\262\347\252\201/score.md" "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/5.\345\206\231\345\205\245\345\222\214\345\206\262\347\252\201/score.md" index 638391a65c800000e73cf2e9d8b9285556dab43e..bdc664c587c07bcb56fd8a22c461898efc4af49a 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/5.\345\206\231\345\205\245\345\222\214\345\206\262\347\252\201/score.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/2.SQL\351\253\230\347\272\247\346\212\200\345\267\247/5.\345\206\231\345\205\245\345\222\214\345\206\262\347\252\201/score.md" @@ -22,7 +22,8 @@ create table book_in( ## 答案 ```sql -insert into book_in(login, score) values ($1, $2) on DUPLICATE KEY update score=$2; +insert into book_in(login, score) +values ($1, $2) on DUPLICATE KEY update score=$2; ``` ## 选项 diff --git "a/data/3.MySQL\351\253\230\351\230\266/3.\350\277\207\347\250\213\345\214\226\347\274\226\347\250\213/5. \346\270\270\346\240\207/cursor.md" "b/data/3.MySQL\351\253\230\351\230\266/3.\350\277\207\347\250\213\345\214\226\347\274\226\347\250\213/5. \346\270\270\346\240\207/cursor.md" index 841c6d42e7e61d9791a1d87d39b929e9c09ae366..0d06bd2cbc37fec78950c8a167f4a6a8604881dc 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/3.\350\277\207\347\250\213\345\214\226\347\274\226\347\250\213/5. \346\270\270\346\240\207/cursor.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/3.\350\277\207\347\250\213\345\214\226\347\274\226\347\250\213/5. \346\270\270\346\240\207/cursor.md" @@ -74,7 +74,9 @@ end; create procedure make_trade() begin DECLARE done INT DEFAULT FALSE; - declare cur_orders cursor for select id, price, item_id, amount from orders order by id limit 1000; + declare cur_orders cursor for + select id, price, item_id, amount + from orders order by id limit 1000; declare order_id, item_id, amount INT; declare price decimal(12, 4); DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; @@ -100,7 +102,11 @@ end; ```sql create procedure make_trade() begin - declare cur_orders cursor for select id, price, item_id, amount from orders order by id limit 1000; + declare cur_orders cursor for + select id, price, item_id, amount + from orders + order by id + limit 1000; declare order_id, item_id, amount INT; declare price decimal(12, 4); DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; @@ -122,7 +128,11 @@ end; create procedure make_trade() begin DECLARE done INT DEFAULT FALSE; - declare cur_orders cursor for select id, price, item_id, amount from orders order by id limit 1000; + declare cur_orders cursor for + select id, price, item_id, amount + from orders + order by id + limit 1000; declare order_id, item_id, amount INT; declare price decimal(12, 4); DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; @@ -143,7 +153,11 @@ end; create procedure make_trade() begin DECLARE done INT DEFAULT FALSE; - declare cur_orders cursor for select id, price, item_id, amount from orders order by id limit 1000; + declare cur_orders cursor for + select id, price, item_id, amount + from orders + order by id + limit 1000; declare order_id, item_id, amount INT; declare price decimal(12, 4); DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; diff --git "a/data/3.MySQL\351\253\230\351\230\266/3.\350\277\207\347\250\213\345\214\226\347\274\226\347\250\213/5. \346\270\270\346\240\207/cursor_desc.md" "b/data/3.MySQL\351\253\230\351\230\266/3.\350\277\207\347\250\213\345\214\226\347\274\226\347\250\213/5. \346\270\270\346\240\207/cursor_desc.md" index 3e4005bc87c151da48fab0874e7830e849f6fdc4..2d11b8f2b7a6eef778a8c354be84bcc8d6037f18 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/3.\350\277\207\347\250\213\345\214\226\347\274\226\347\250\213/5. \346\270\270\346\240\207/cursor_desc.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/3.\350\277\207\347\250\213\345\214\226\347\274\226\347\250\213/5. \346\270\270\346\240\207/cursor_desc.md" @@ -19,24 +19,16 @@ ### A -``` "DECLARE 游标名字 CURSOR FOR 查询语句;" 用来声明游标 -``` ### B -``` 定义好游标之后,需要使用"OPEN 游标名;"来打开游标 -``` ### C -``` 游标使用有需要关闭"CLOSE 游标名;" -``` ### D -``` 游标就像指针一样,可以定位操作查询的数据 -``` \ No newline at end of file diff --git "a/data/3.MySQL\351\253\230\351\230\266/4.\350\256\276\350\256\241\344\274\230\345\214\226/1.\347\224\237\346\210\220\345\210\227/generated.md" "b/data/3.MySQL\351\253\230\351\230\266/4.\350\256\276\350\256\241\344\274\230\345\214\226/1.\347\224\237\346\210\220\345\210\227/generated.md" index e67bb0c8e8e2fe45efbd4f3371667acfe44a9b81..9fe4829191781836a6dfb556132ed33b0e9cea56 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/4.\350\256\276\350\256\241\344\274\230\345\214\226/1.\347\224\237\346\210\220\345\210\227/generated.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/4.\350\256\276\350\256\241\344\274\230\345\214\226/1.\347\224\237\346\210\220\345\210\227/generated.md" @@ -30,7 +30,8 @@ column_name data_type [GENERATED ALWAYS] AS (expression) ## 答案 ```sql -alter table points add modulus double generated always as (sqrt(x*x + y*y)); +alter table points add modulus double + generated always as (sqrt(x*x + y*y)); ``` ## 选项 @@ -38,17 +39,20 @@ alter table points add modulus double generated always as (sqrt(x*x + y*y)); ### A ```sql -create generated modulus on table points as (sqrt(x*x + y*y)); +create generated modulus + on table points as (sqrt(x*x + y*y)); ``` ### B ```sql -alter table points add modulus generated always as (sqrt(x*x + y*y)); +alter table points + add modulus generated always as (sqrt(x*x + y*y)); ``` ### C ```sql -alter table points add modulus float generated sqrt(x*x + y*y); +alter table points + add modulus float generated sqrt(x*x + y*y); ``` diff --git "a/data/3.MySQL\351\253\230\351\230\266/4.\350\256\276\350\256\241\344\274\230\345\214\226/4.\345\242\236\345\212\240\344\270\255\351\227\264\350\241\250/daily_payment2.md" "b/data/3.MySQL\351\253\230\351\230\266/4.\350\256\276\350\256\241\344\274\230\345\214\226/4.\345\242\236\345\212\240\344\270\255\351\227\264\350\241\250/daily_payment2.md" index 7df9cdecca9cd2ded344d09e574b20c6ec77ffad..4395d301a8ec842beb45b9b9cc52ba930def16af 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/4.\350\256\276\350\256\241\344\274\230\345\214\226/4.\345\242\236\345\212\240\344\270\255\351\227\264\350\241\250/daily_payment2.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/4.\350\256\276\350\256\241\344\274\230\345\214\226/4.\345\242\236\345\212\240\344\270\255\351\227\264\350\241\250/daily_payment2.md" @@ -38,26 +38,35 @@ group by date(payment_date); 建立中间表并建立索引。 ```postgresql -create table daily_payment(day date primary key , amount decimal(12, 4)); +create table daily_payment( + day date primary key , + amount decimal(12, 4)); insert into daily_payment(day, amount) -select payment_date::date as day, sum(amount) as amount from payment group by day; +select payment_date::date as day, + sum(amount) as amount +from payment group by day; ``` 使用 ```sql -select day, amount from view_daily_payment where day between $1 and $2; +select day, amount +from view_daily_payment +where day between $1 and $2; ``` 进行查询。并且每天定时执行一次刷新命令 ```sql insert into daily_payment(day, amount) -select date(payment_date) as day, sum(amount) as amount +select date(payment_date) as day, + sum(amount) as amount from payment -where date(payment_date) between DATE_SUB(CURDATE(), INTERVAL 2 DAY) and DATE_SUB(CURDATE(), INTERVAL 1 DAY) +where date(payment_date) + between DATE_SUB(CURDATE(), INTERVAL 2 DAY) + and DATE_SUB(CURDATE(), INTERVAL 1 DAY) group by day; ``` @@ -69,7 +78,8 @@ group by day; 在 payment_date 列上建立索引 ```sql -create index idx_payment_date on payment(payment_date); +create index idx_payment_date on + payment(payment_date); ``` ### 不会优化 sum @@ -77,7 +87,8 @@ create index idx_payment_date on payment(payment_date); 建立计算列 ```sql -alter table payment add day date generated always as ( payment_date::date ) stored +alter table payment add day date + generated always as ( payment_date::date ) stored ``` 然后使用它改写查询 @@ -94,7 +105,8 @@ group by day; 建立表达式索引 ```sql -create index idx_payment_day on payment((date(payment_date))); +create index idx_payment_day + on payment((date(payment_date))); ``` ### 不做物化,对查询速度不会有显著改善 @@ -102,7 +114,8 @@ create index idx_payment_day on payment((date(payment_date))); 建立视图 ```sql -create view view_daily_payment as select date(payment_date) as day, amount from payment; +create view view_daily_payment as + select date(payment_date) as day, amount from payment; ``` 然后在视图 view_daily_payment 上执行 diff --git "a/data/3.MySQL\351\253\230\351\230\266/5.\350\277\220\347\273\264\344\270\216\346\236\266\346\236\204/6.\345\244\215\345\210\266\350\277\207\346\273\244\345\231\250/filter.md" "b/data/3.MySQL\351\253\230\351\230\266/5.\350\277\220\347\273\264\344\270\216\346\236\266\346\236\204/6.\345\244\215\345\210\266\350\277\207\346\273\244\345\231\250/filter.md" index 55c6296a845d2eb6e1870adbb0890fe986800ea7..2a6d95a6f1d42799ad9b0fed4027b398f9a388bb 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/5.\350\277\220\347\273\264\344\270\216\346\236\266\346\236\204/6.\345\244\215\345\210\266\350\277\207\346\273\244\345\231\250/filter.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/5.\350\277\220\347\273\264\344\270\216\346\236\266\346\236\204/6.\345\244\215\345\210\266\350\277\207\346\273\244\345\231\250/filter.md" @@ -84,7 +84,8 @@ SET GLOBAL replicate-ignore-db=goods,auth; 可以在从库执行以下命令,设定忽略 goods 数据库和 auth 数据库 ```sql -CHANGE REPLICATION FILTER REPLICATE_IGNORE_DB=(goods, auth); +CHANGE REPLICATION FILTER + REPLICATE_IGNORE_DB=(goods, auth); ``` ### J @@ -108,7 +109,8 @@ SET GLOBAL replicate-do-table=goods.goods,goods.orders; 可以在在从库的 MySQL 命令行设定只同步 goods 表和 orders 表 ```sql -CHANGE REPLICATION FILTER REPLICATE_DO_TABLE=( goods.goods,goods.orders); +CHANGE REPLICATION FILTER + REPLICATE_DO_TABLE=( goods.goods,goods.orders); ``` ### M @@ -124,7 +126,8 @@ replicate-do-table=goods.goods,goods.orders 可以在在从库的 MySQL 命令行设定只同步名称前缀为 `t_` 的表 ```sql -CHANGE REPLICATION FILTER REPLICATE_WILD_DO_TABLE =( goods.t_%); +CHANGE REPLICATION FILTER + REPLICATE_WILD_DO_TABLE =( goods.t_%); ``` ### P @@ -140,7 +143,8 @@ SET GLOBAL replicate-ignore-table=goods.orders,goods.trade; 可以在从库的 MySQL 命令行设定忽略 orders 和 trade 表 ```sql -CHANGE REPLICATION FILTER REPLICATE_ IGNORE_TABLE=( goods.orders,goods.trade); +CHANGE REPLICATION FILTER + REPLICATE_ IGNORE_TABLE=( goods.orders,goods.trade); ``` @@ -157,7 +161,8 @@ replicate-ignore-table =goods.orders,goods.trade 可以在在从库的 MySQL 命令行设定忽略名称前缀为 `o_` 的表 ```sql -CHANGE REPLICATION FILTER REPLICATE_WILD_DO_TABLE =( goods.o_%); +CHANGE REPLICATION FILTER + REPLICATE_WILD_DO_TABLE =( goods.o_%); ``` ### S diff --git "a/data/3.MySQL\351\253\230\351\230\266/6.\346\237\245\350\257\242\344\274\230\345\214\226/3. EXPLAIN/explain.md" "b/data/3.MySQL\351\253\230\351\230\266/6.\346\237\245\350\257\242\344\274\230\345\214\226/3. EXPLAIN/explain.md" index a1b0296ba3969bc953395956221a8aab052d70ff..c57dd4b6526fecc3871f251e1988fa704049b6dd 100644 --- "a/data/3.MySQL\351\253\230\351\230\266/6.\346\237\245\350\257\242\344\274\230\345\214\226/3. EXPLAIN/explain.md" +++ "b/data/3.MySQL\351\253\230\351\230\266/6.\346\237\245\350\257\242\344\274\230\345\214\226/3. EXPLAIN/explain.md" @@ -3,13 +3,14 @@ Joe 从交易服务中发现了一些高频查询和慢查询,例如 ```sql -with recursive r(id) as (select id - from orders - where id = $1 - union - select d.id - from orders as d - join r on d.id = r.id + 1) +with recursive r(id) as ( + select id + from orders + where id = $1 + union + select d.id + from orders as d + join r on d.id = r.id + 1) select orders.id, content from orders join r on orders.id = r.id; @@ -29,13 +30,14 @@ from orders 在测试库使用 ```sql -explain with recursive r(id) as (select id - from orders - where id = $1 - union - select d.id - from orders as d - join r on d.id = r.id + 1) +explain with recursive r(id) as ( + select id + from orders + where id = $1 + union + select d.id + from orders as d + join r on d.id = r.id + 1) select orders.id, content from orders join r on orders.id = r.id; @@ -44,13 +46,14 @@ from orders 进行剖分,对于需要了解详细执行计划的使用 ```sql -explain analyze with recursive r(id) as (select id - from orders - where id = 100 - union - select d.id - from orders as d - join r on d.id = r.id + 1) +explain analyze with recursive r(id) as ( + select id + from orders + where id = 100 + union + select d.id + from orders as d + join r on d.id = r.id + 1) select orders.id from orders join r on orders.id = r.id; @@ -73,13 +76,14 @@ from orders 使用 ```sql -analyze with recursive r(id) as (select id - from orders - where id = 100 - union - select d.id - from orders as d - join r on d.id = r.id + 1) +analyze with recursive r(id) as ( + select id + from orders + where id = 100 + union + select d.id + from orders as d + join r on d.id = r.id + 1) select orders.id from orders join r on orders.id = r.id; diff --git a/data/tree.json b/data/tree.json index 6c9a635f933d6b8e203237f762009e5f1579d519..4723fa02060a7a20fa03582268be445ae23467a2 100644 --- a/data/tree.json +++ b/data/tree.json @@ -32,8 +32,7 @@ "概念" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -50,14 +49,12 @@ "概念" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -79,8 +76,7 @@ "安装" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -98,14 +94,12 @@ "登录" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -135,8 +129,7 @@ "删除" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -151,8 +144,7 @@ "表" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -170,8 +162,7 @@ "编码" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -188,14 +179,12 @@ "存储引擎" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -221,8 +210,7 @@ "数值类型" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -244,8 +232,7 @@ "时间类型" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -266,8 +253,7 @@ "字符串" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -286,14 +272,12 @@ "字符串" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -315,8 +299,7 @@ "插入" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -332,8 +315,7 @@ "修改" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -349,14 +331,12 @@ "删除" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -378,8 +358,7 @@ "select" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -397,8 +376,7 @@ "where" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -415,8 +393,7 @@ "运算符" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -435,20 +412,17 @@ "函数" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } }, { @@ -477,8 +451,7 @@ "表" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -495,8 +468,7 @@ "视图" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -516,8 +488,7 @@ "存储过程", "函数" ] - ], - "group": 2 + ] } }, { @@ -537,8 +508,7 @@ "约束" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -555,8 +525,7 @@ "触发器" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -574,14 +543,12 @@ "存储引擎" ] ], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -603,8 +570,7 @@ "别名" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -620,8 +586,7 @@ "between" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -640,8 +605,7 @@ "case" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -657,8 +621,7 @@ "distinct" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -675,8 +638,7 @@ "order by" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -692,8 +654,7 @@ "union" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -710,8 +671,7 @@ "正则表达式" ] ], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } }, { @@ -729,14 +689,12 @@ "分页" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -756,8 +714,7 @@ "keywords_must": [ "mysql" ], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } }, { @@ -770,8 +727,7 @@ "keywords_must": [ "mysql" ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -785,8 +741,7 @@ "keywords_must": [ "mysql" ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -809,8 +764,7 @@ "keywords_must": [ "mysql" ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -825,14 +779,12 @@ "keywords_must": [ "mysql" ], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -861,8 +813,7 @@ "count" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -883,8 +834,7 @@ "sum" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -905,8 +855,7 @@ "min" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -927,8 +876,7 @@ "max" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -940,8 +888,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } }, { @@ -955,14 +902,12 @@ "having" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -987,8 +932,7 @@ "相关子查询" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1006,8 +950,7 @@ "any" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1025,8 +968,7 @@ "all" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1044,8 +986,7 @@ ], "keywords_forbid": [ "not exists" - ], - "group": 1 + ] } }, { @@ -1065,8 +1006,7 @@ ], "keywords_forbid": [ "not in" - ], - "group": 1 + ] } }, { @@ -1083,8 +1023,7 @@ "列子查询" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } } ], @@ -1092,8 +1031,7 @@ "子查询", "subquery" ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1119,8 +1057,7 @@ "inner join" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1137,8 +1074,7 @@ "left join" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1155,8 +1091,7 @@ "right join" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1173,8 +1108,7 @@ "cross join" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1190,8 +1124,7 @@ "复杂连接" ] ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], @@ -1199,8 +1132,7 @@ "join", "连接查询" ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1223,8 +1155,7 @@ "入门" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1242,8 +1173,7 @@ "索引" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1261,14 +1191,12 @@ "索引" ] ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1282,14 +1210,12 @@ "keywords": [], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1306,8 +1232,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1319,8 +1244,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1332,8 +1256,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1344,14 +1267,12 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1372,8 +1293,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1384,14 +1304,12 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1407,8 +1325,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1423,8 +1340,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1436,8 +1352,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1450,8 +1365,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1463,8 +1377,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1476,8 +1389,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1490,20 +1402,17 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } }, { @@ -1525,8 +1434,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1542,8 +1450,7 @@ "全值匹配" ] ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1561,8 +1468,7 @@ "匹配顺序" ] ], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } }, { @@ -1574,8 +1480,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1589,8 +1494,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1602,8 +1506,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1616,8 +1519,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } }, { @@ -1637,14 +1539,12 @@ "performance", "优化" ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1666,8 +1566,7 @@ "递归查询", "recursive" ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1681,8 +1580,7 @@ "keywords_must": [ "mysql" ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1697,8 +1595,7 @@ "keywords_must": [ "mysql" ], - "keywords_forbid": [], - "group": 1 + "keywords_forbid": [] } }, { @@ -1713,8 +1610,7 @@ "keywords_must": [ "mysql" ], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } }, { @@ -1729,8 +1625,7 @@ "keywords_must": [ "mysql" ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1747,14 +1642,12 @@ "事务" ] ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1770,8 +1663,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1783,8 +1675,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1796,8 +1687,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1808,8 +1698,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1821,14 +1710,12 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1844,8 +1731,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1856,8 +1742,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1869,8 +1754,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } }, { @@ -1882,8 +1766,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } }, { @@ -1895,14 +1778,12 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1920,8 +1801,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1935,8 +1815,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1951,8 +1830,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1967,8 +1845,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1981,8 +1858,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -1995,8 +1871,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2009,14 +1884,12 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2032,8 +1905,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2044,8 +1916,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2057,14 +1928,12 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2078,8 +1947,7 @@ "keywords": [], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2093,14 +1961,12 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2119,8 +1985,7 @@ "keywords_must": [ "mysqladmin" ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2135,8 +2000,7 @@ "keywords_must": [ "myisampack" ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2151,8 +2015,7 @@ "keywords_must": [ "mysqlbinlog" ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2165,8 +2028,7 @@ "keywords_must": [ "mysqlcheck" ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2177,8 +2039,7 @@ "keywords_must": [ "mysqlshow" ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2191,14 +2052,12 @@ "keywords_must": [ "mysqlpump" ], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2216,8 +2075,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2230,8 +2088,7 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } }, { @@ -2243,25 +2100,21 @@ ], "children": [], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 2 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } } ], "keywords_must": [], - "keywords_forbid": [], - "group": 0 + "keywords_forbid": [] } } \ No newline at end of file