随笔分类 - 软件测试——数据库——mysql数据库
摘要:create table student( sid varchar(50), sname varchar(50), sage varchar(50), ssex varchar(50) ); insert into student( sid,sname,sage,ssex ) values('1',
阅读全文
posted @ 2019-12-24 19:24
小白龙白龙马
摘要:合并查询结果 合并查询结果 是将多个select语句的查询结果合并到一起 union关键字,数据库会将所有的查询结果合并到一起,然后除掉相同的记录; union all关键字,只是简单的合并到一起 前期表准备: create table employee ( num int(50), d_id in
阅读全文
posted @ 2019-12-24 19:22
小白龙白龙马
摘要:子查询: 子查询是将一个查询语句嵌套在另外一个查询语句中,内层查询语句的查询结果,可以作为外来层查询语句提供查询条件。因此在特定条件下,一个查询语句的条件,需要另外一个查询语句来获取。 前期准备表: create table employee ( num int(50), d_id int(50),
阅读全文
posted @ 2019-12-24 19:18
小白龙白龙马
摘要:create table employee ( num int(50), d_id int(50), name varchar(50), age int(50), sex varchar(50), homeadd varchar(50) ); insert into employee values(
阅读全文
posted @ 2019-12-24 18:56
小白龙白龙马
摘要:内连接查询:可以查询两个或者两个以上的表,当两个表中存在表示相同意义的字段时,可以通过该字段来连接这两个表; 当该字段的值相等时,就查询出该记录。 前期准备两个表: create table employee ( num int(50), d_id int(50), name varchar(50)
阅读全文
posted @ 2019-12-24 18:43
小白龙白龙马
摘要:create database see; use database see; drop database sww; create table cr01 ( sx int(50), mz varchar(50), bz varchar(50) ); insert into cr01 ( sx,mz,b
阅读全文
posted @ 2019-12-24 18:27
小白龙白龙马
摘要:create table student( sid varchar(50), sname varchar(50), sage varchar(50), ssex varchar(50) ); insert into student( sid,sname,sage,ssex ) values('1',
阅读全文
posted @ 2019-12-24 18:25
小白龙白龙马
摘要:create table score ( xh int(50), km varchar(50), cj int(50) ); select * from score; insert into score values(1,'shuxue',80); insert into score values(
阅读全文
posted @ 2019-12-24 18:22
小白龙白龙马
摘要:使用聚合函数查询 group by关键字通常和聚合函数一起使用 1、count()函数 count()函数用来统计记录的条数 举例:使用count()函数统计employee表的记录数 select count(*) from employee; 举例:使用count()函数统计employee表中
阅读全文
posted @ 2019-12-24 18:19
小白龙白龙马
摘要:一、基本查询语句 select的基本语法格式如下: select 属性列表 from 表名和视图列表 [ where 条件表达式1 ] [ group by 属性名1 [ having 条件表达式2 ] ] [ order by 属性名2 [ asc | desc ] ] 属性列表参数表示需要查询的
阅读全文
posted @ 2019-12-24 18:14
小白龙白龙马
摘要:一、基本查询语句 select的基本语法格式如下: select 属性列表 from 表名和视图列表 [ where 条件表达式1 ] [ group by 属性名1 [ having 条件表达式2 ] ] [ order by 属性名2 [ asc | desc ] ] 属性列表参数表示需要查询的
阅读全文
posted @ 2019-12-24 16:56
小白龙白龙马
摘要:一、基本查询语句 select的基本语法格式如下: select 属性列表 from 表名和视图列表 [ where 条件表达式1 ] [ group by 属性名1 [ having 条件表达式2 ] ] [ order by 属性名2 [ asc | desc ] ] 属性列表参数表示需要查询的
阅读全文
posted @ 2019-12-24 15:27
小白龙白龙马
摘要:插入数据 一、前提,新建表: create table student( sid varchar(50), sname varchar(50), sage varchar(50), ssex varchar(50) ); select * from student; 二、多种方式插入数据: inse
阅读全文
posted @ 2019-12-24 15:17
小白龙白龙马
摘要:一、插入数据 1、为表的所有字段插入数据 (1)insert语句中不指定具体的字段名 语法格式:insert into 表名 values(值1,值2,……,值n); 表名指定记录插入到哪一个表中; 值等表示要插入的数据;值1到值n分别对应着表中的每一个字的;表中定义了几个字段,insert语句中就
阅读全文
posted @ 2019-12-24 01:01
小白龙白龙马
摘要:一、创建表和插入数据: create table cr01 ( sx int(50), mz varchar(50), bz varchar(50) ); insert into cr01 ( sx,mz,bz ) values (1,'sww','sww01'); insert into cr01
阅读全文
posted @ 2019-12-24 00:52
小白龙白龙马
摘要:查看表结构 查看表结构是指:查看数据库中已经存在的表的定义 1、查看表基本结构的语句:describe describe语句可以查看表的基本定义:其中包括字段名、字段数据类型、是否为主键和默认值等; describe语句的语法格式如下: describe 表名; describe可以缩写为desc:
阅读全文
posted @ 2019-12-23 22:24
小白龙白龙马
摘要:一、创建一个数据表 create table 表名 ( 列名1 数据类型1 [完整性约束条件], 列名2 数据类型2 [完整性约束条件], 列名3 数据类型3 [完整性约束条件], 列名4 数据类型4 [完整性约束条件], …… 列名n 数据类型n ); 表名:所要创建的表的名称 列名:表示表中字段
阅读全文
posted @ 2019-12-23 22:12
小白龙白龙马
摘要:一、查看数据库 show databases; 二、创建数据库 create database 数据库名; 三、删除数据库 drop database 数据库名; 四、查看数据库存储引擎 show engines; PS:可以用 \g结尾,作用和 ; 一样; 用\G结尾,显示更美观点;
阅读全文
posted @ 2019-12-23 21:49
小白龙白龙马
摘要:前提:连接进入mysql数据库本机安装的myslq基础信息:host= "localhost", # 数据库主机地址:127.0.0.1 port=3306, # 端口号 user="root", # myslql数据库用户名 passwd="123", # 数据库密码 database="runo
阅读全文
posted @ 2019-12-23 18:08
小白龙白龙马