From 53c761c0586e1bba56611061d439b2c87c441553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6?= <3228916049@qq.com> Date: Tue, 14 Mar 2023 02:41:26 +0000 Subject: [PATCH 1/6] =?UTF-8?q?=E7=AC=AC=E4=B8=83=E6=AC=A1=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李舒汶 <3228916049@qq.com> --- ...03\346\254\241\344\275\234\344\270\232.md" | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 "49 \346\235\216\350\210\222\346\261\266/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232.md" diff --git "a/49 \346\235\216\350\210\222\346\261\266/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232.md" "b/49 \346\235\216\350\210\222\346\261\266/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232.md" new file mode 100644 index 0000000..4d944de --- /dev/null +++ "b/49 \346\235\216\350\210\222\346\261\266/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232.md" @@ -0,0 +1,74 @@ + -- 按图片所给的数据进行数据表的建立和数据插入,然后进行以下查询操作 +-- 1.查询学生信息表(stuinfo)中所有列信息,给每列取上中文名称 +select stuno 学号,stuname 姓名,stuage 年龄,stuaddress 地址,stuseat 座号,stusex 性别 from stuinfo; + +select * from stuinfo; +-- 2.查询学生信息表(stuinfo)中的姓名,年龄和地址三列的信息 +select stuname 姓名,stuage 年龄,stuaddress 地址 from stuinfo; +-- 3.查询学生分数表(stuexam)中的学号,笔试和机试三列的信息,并为这三列取中文名字 +select stuno 学号,writtenexam 笔试,labexam 机试 from stuexam; +-- 5.查询学生分数表(stuexam)中的学生的学号,笔试,机试以及总分这四列的信息 +select writtenexam 笔试,labexam 机试,(writtenexam+labexam) 总分 from stuexam; +-- 6.查询学生信息表(stuInfo)中学生来自哪几个地方 +select distinct stuaddress 地址 from stuinfo; +-- 7.查询学生信息表(stuInfo)中学生有哪几种年龄,并为该列取对应的中文列名 +select stuage 年龄 from stuinfo; +-- 8.查询学生信息表(stuInfo)中前3行记录 +select * from stuinfo; + +select * from stuinfo LIMIT 3; +-- 9.查询学生信息表(stuInfo)中前4个学生的姓名和座位号 +select stuname 姓名,stuseat 座号 from stuinfo LIMIT 4; +-- 11.将地址是湖北武汉,年龄是20的学生的所有信息查询出来 +select * from stuinfo where stuaddress like '湖北武汉' and stuage=20; +-- 12.将机试成绩在60-80之间的信息查询出来,并按照机试成绩降序排列 +select * from stuexam where labexam >=60 and labexam <=80 order by labexam desc; + +-- 13.查询来自湖北武汉或者湖南长沙的学生的所有信息 +select * from stuinfo where stuaddress='湖北武汉' or stuaddress='湖南长沙'; + +-- 14.查询出笔试成绩不在70-90之间的信息,并按照笔试成绩升序排列 +select * from stuexam where writtenexam not BETWEEN 70 and 90 ORDER BY writtenexam asc; + +-- 15.查询年龄没有写的学生所有信息 +select * from stuinfo where stuage is null; + +-- 16.查询年龄写了的学生所有信息 +select * from stuinfo where !(stuage is null); + +-- 17.查询姓张的学生信息 +select * from stuinfo where stuname like '张%'; + +-- 18.查询学生地址中有‘湖’字的信息 +select * from stuinfo where stuaddress like '%湖%'; + +-- 19.查询姓张但名为一个字的学生信息 +select * from stuinfo where stuname like '张_'; + +-- 20.查询姓名中第三个字为‘俊’的学生的信息,‘俊’后面有多少个字不限制 +select * from stuinfo where stuname like '__俊%'; + +-- 21.按学生的年龄降序显示所有学生信息 +select * from stuinfo order by stuno desc; + +-- 22.按学生的年龄降序和座位号升序来显示所有学生的信息 +select * from stuinfo order by stuage desc; +select * from stuinfo order by stuseat asc; +-- 23显示笔试第一名的学生的考试号,学号,笔试成绩和机试成绩 +select * from stuexam order by writtenexam desc limit 1; +-- 24.显示机试倒数第一名的学生的考试号,学号,笔试成绩和机试成绩 +select * from stuexam order by writtenexam asc limit 1; + + +-- 25.查询每个地方的学生的平均年龄 +select stuaddress,avg(stuage) from stuinfo GROUP BY stuaddress; + +-- 26.查询男女生的分别的年龄总和 +select stuSex,sum(stuage) from stuinfo GROUP BY stusex; + +-- 27.查询每个地方的男女生的平均年龄和年龄的总和 +SELECT stuaddress,stusex, avg(stuage) as 平均年龄, sum(stuage) as 年龄总和 from stuinfo GROUP BY stuaddress,stusex; + +-- + +-- \ No newline at end of file -- Gitee From 6dc5b40ba28dea3a8ff0b996396fce5522ded909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6?= <3228916049@qq.com> Date: Tue, 14 Mar 2023 02:47:14 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=2049=20?= =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6/MySQL.md=20=E4=B8=BA=2049=20?= =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6/20230217mysql=E8=AF=AD=E5=8F=A5.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230217mysql\350\257\255\345\217\245.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "49 \346\235\216\350\210\222\346\261\266/MySQL.md" => "49 \346\235\216\350\210\222\346\261\266/20230217mysql\350\257\255\345\217\245.md" (100%) diff --git "a/49 \346\235\216\350\210\222\346\261\266/MySQL.md" "b/49 \346\235\216\350\210\222\346\261\266/20230217mysql\350\257\255\345\217\245.md" similarity index 100% rename from "49 \346\235\216\350\210\222\346\261\266/MySQL.md" rename to "49 \346\235\216\350\210\222\346\261\266/20230217mysql\350\257\255\345\217\245.md" -- Gitee From d14fd9fb47ee0945a1970a2e81d5c92572ff7f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6?= <3228916049@qq.com> Date: Tue, 14 Mar 2023 02:48:04 +0000 Subject: [PATCH 3/6] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=2049=20?= =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6/mysql2.md=20=E4=B8=BA=2049=20?= =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6/20230221mysql=E7=BA=A6=E6=9D=9Fmd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230221mysql\347\272\246\346\235\237md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "49 \346\235\216\350\210\222\346\261\266/mysql2.md" => "49 \346\235\216\350\210\222\346\261\266/20230221mysql\347\272\246\346\235\237md" (100%) diff --git "a/49 \346\235\216\350\210\222\346\261\266/mysql2.md" "b/49 \346\235\216\350\210\222\346\261\266/20230221mysql\347\272\246\346\235\237md" similarity index 100% rename from "49 \346\235\216\350\210\222\346\261\266/mysql2.md" rename to "49 \346\235\216\350\210\222\346\261\266/20230221mysql\347\272\246\346\235\237md" -- Gitee From 8bb558caacfcb13935607a190143955dbea7401b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6?= <3228916049@qq.com> Date: Tue, 14 Mar 2023 02:48:50 +0000 Subject: [PATCH 4/6] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=2049=20?= =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6/=E5=AD=90=E6=9F=A5=E8=AF=A2.md=20?= =?UTF-8?q?=E4=B8=BA=2049=20=E6=9D=8E=E8=88=92=E6=B1=B6/20230307mysql?= =?UTF-8?q?=E5=AD=90=E6=9F=A5=E8=AF=A2.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230307mysql\345\255\220\346\237\245\350\257\242.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "49 \346\235\216\350\210\222\346\261\266/\345\255\220\346\237\245\350\257\242.md" => "49 \346\235\216\350\210\222\346\261\266/20230307mysql\345\255\220\346\237\245\350\257\242.md" (100%) diff --git "a/49 \346\235\216\350\210\222\346\261\266/\345\255\220\346\237\245\350\257\242.md" "b/49 \346\235\216\350\210\222\346\261\266/20230307mysql\345\255\220\346\237\245\350\257\242.md" similarity index 100% rename from "49 \346\235\216\350\210\222\346\261\266/\345\255\220\346\237\245\350\257\242.md" rename to "49 \346\235\216\350\210\222\346\261\266/20230307mysql\345\255\220\346\237\245\350\257\242.md" -- Gitee From bce7d4a70236a8ed42642cefab4b144d88b21788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6?= <3228916049@qq.com> Date: Tue, 14 Mar 2023 02:49:38 +0000 Subject: [PATCH 5/6] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=2049=20?= =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6/=E7=AC=AC=E4=B8=83=E6=AC=A1?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A.md=20=E4=B8=BA=2049=20=E6=9D=8E=E8=88=92?= =?UTF-8?q?=E6=B1=B6/20230310=E5=A4=8D=E4=B9=A0=E4=BD=9C=E4=B8=9A.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20230310\345\244\215\344\271\240\344\275\234\344\270\232.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "49 \346\235\216\350\210\222\346\261\266/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232.md" => "49 \346\235\216\350\210\222\346\261\266/20230310\345\244\215\344\271\240\344\275\234\344\270\232.md" (100%) diff --git "a/49 \346\235\216\350\210\222\346\261\266/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232.md" "b/49 \346\235\216\350\210\222\346\261\266/20230310\345\244\215\344\271\240\344\275\234\344\270\232.md" similarity index 100% rename from "49 \346\235\216\350\210\222\346\261\266/\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232.md" rename to "49 \346\235\216\350\210\222\346\261\266/20230310\345\244\215\344\271\240\344\275\234\344\270\232.md" -- Gitee From 7a4c1a4f5cd6a4a8eef86fbc667badcb2e48e351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=88=92=E6=B1=B6?= <3228916049@qq.com> Date: Tue, 14 Mar 2023 02:54:08 +0000 Subject: [PATCH 6/6] =?UTF-8?q?20230216=20MySQL=E8=AF=AD=E6=B3=95=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李舒汶 <3228916049@qq.com> --- ...55\346\263\225\350\247\204\350\214\203.md" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "49 \346\235\216\350\210\222\346\261\266/20230216mysql\350\257\255\346\263\225\350\247\204\350\214\203.md" diff --git "a/49 \346\235\216\350\210\222\346\261\266/20230216mysql\350\257\255\346\263\225\350\247\204\350\214\203.md" "b/49 \346\235\216\350\210\222\346\261\266/20230216mysql\350\257\255\346\263\225\350\247\204\350\214\203.md" new file mode 100644 index 0000000..1e2ad44 --- /dev/null +++ "b/49 \346\235\216\350\210\222\346\261\266/20230216mysql\350\257\255\346\263\225\350\247\204\350\214\203.md" @@ -0,0 +1,38 @@ +SQL语法规范 + +(1)mysql的sql语法不区分大小写 + +- A:数据库的表中的数据是否区分大小写。这个的话要看表格的字段的数据类型、编码方式以及校对规则 。排序 + + ci(大小写不敏感),cs(大小写敏感),_bin(二进制,即比较是基于字符编码的值而与language无关,区分大小写) + +- B:sql中的关键字,比如:create,insert等,不区分大小写。但是大家习惯上把关键字都“大写”。 + +(2)命名时:尽量使用26个英文字母大小写,数字0-9,下划线,不要使用其他符号 + +(3)建议不要使用mysql的关键字等来作为**表名、字段名、数据库**名等,如果不小心使用,请在SQL语句中使用`(飘号/反引号)引起来,说明 : 反引号用于区别MySQL保留字与普通字符而引入的 (键盘esc下面的键) + +(4)数据库和表名、字段名等对象名中间不要包含空格 + +(5)同一个mysql软件中,数据库不能同名,同一个库中,表不能重名,同一个表中,字段不能重名 + +SQL脚本中如何加注释 + +- 单行注释:#注释内容(mysql特有的) +- 单行注释:--空格注释内容 其中--后面的空格必须有 +- 多行注释:/* 注释内容 */ + +mysql脚本中标点符号的要求如下: + +1. 本身成对的标点符号必须成对,例如:(),'',""。 +2. 所有标点符号必须英文状态下半角输入方式下输入。 + +几个特殊的标点符号: + +1. 小括号(): + - 在创建表、添加数据、函数使用、子查询、计算表达式等等会用()表示某个部分是一个整体结构。 + - 思考: 2+3 * 6 =20 和 (2+3) * 6 =30的区别 +2. 单引号'':**字符串和日期类型的数据值使用单引号''引起来**,数值类型的不需要加标点符号。 +3. “2023-10--10” +4. 双引号"":列的别名可以使用引号"",**给表名取别名不要用引号**。 +5. 在MySQL中双引号通常等价于单引号 \ No newline at end of file -- Gitee