针对记录的SQL语句
记录:表中的一行一行的数据称之为是一条记录
1、查看记录
select * from t1; # 查所有 
 
2、增加数据
    insert into t1 values(1, 'kevin', 20); # 第一种方式,全字段增加, 单条增加
    insert into t1 values(2, 'kevin1', 20),(3, 'kevin2', 20),(4, 'kevin3', 20),(5, 'kevin4', 20),(6, 'kevin5', 20); # 第二种方式,全字段增加, 批量增加
    insert into t1(id, name) values(7, 'kevin7'); # 空的使用NULL填充 
     
 3、修改
 
update t1 set name='tank' where id=1;
update t1 set age=30 where name='tank';
update t1 set name='jerry',age=30 where id=3;
update t1 set name='oscar' where name='tank' and age=30;
update t1 set name='oscar' where name='kevin3' or name='kevin4';
update t1 set name='tony'; 
 
 4、删除
 
delete from t1 where id=1;
delete from t1 where id=2 or id=7;
delete from t1;  # 这是清空表 
 
配置文件的使用
将默认编码修改为utf-8
步骤:
1.找到配置文件:my-default.ini
2.复制一份,命名为:my.ini
3.将以下内容写入文件:
4.保存即可
存储引擎的使用
存储引擎就是存储数据的方式
MySQL支持多少种存储引擎方式
如何查看存储引擎:
show engines; 
一共九种存储引擎,重点学习:MyISAM MEMORY InnoDB
# 演示
create table t2 (id int, name varchar(64)) engine=MyISAM;
create table t3 (id int, name varchar(64)) engine=InnoDB;
create table t4 (id int, name varchar(64)) engine=MEMORY; 
 
"""
对于不同的存储引擎,硬盘中保存的文件个数也是不一样的
MyISAM:3个文件
		.frm 存储表结构
		.MYD 存储的是表数据
		.MYI 存索引(当成是字典的目录,加快查询速度)
InnoDB:2个文件
		.frm 存储表结构
		.ibd 存储数据和索引
MEMORY:1个文件
		.frm 存储表结构
""" 
 
数据类型(重要)
1、整型: 存储整数的类型
    tinyint: 它是使用一个字节来保存数据,一个字节代表8位 11111111--->256种情况(0-255) (-128-127)
    smallint:2个字节, 代表16位, 65536(0-65535) (-32768-32767)
    mediumint: 3个字节
    int: 4个字节,2**32=42....(-21...- 21...)
    bigint:8个字节(最大的) 可以存手机号(11) 
     """怎么选数据类型:看你这一列存什么数据"""
     比如:age int
## 整型默认情况下带不带符号?
    create table t5 (id tinyint);
    insert into t5 values(256);
结论是:带符号的,所有的整型默认都是带符号的 减半
# 怎么样去掉符号
    create table t6 (id tinyint unsigned); 
 2、浮点型
 
 
 3、字符串(重要)
 
 
create table t10 (id int, name char(4));
create table t11 (id int, name varchar(4));
    
insert into t10 values(1, 'jerry');
insert into t11 values(1, 'jerry');
     
     """如果你想超出范围之后,直接报错,需要设置严格模式!!!"""
sql_mode
show variables like "%mode%"; 
 
 ## 研究定长和不定长
create table t12 (id int, name char(4));
create table t13 (id int, name varchar(4));
    
insert into t12 values(1, 'ke');
insert into t13 values(1, 'ke'); 
## 验证是否补充了空格
select char_length(name) from t12;
select char_length(name) from t13; 
 """默认情况下,没有对char类型填充空格,如果想看填充了空格,需要设置严格模式"""
  
     
 4、日期
 
 
create table t14 (
    id int, 
    reg_time date, 
    reg1_time datetime, 
    reg2_time time, 
    reg3_time year
);
insert into t14 values(1, '2023-10-1', '2023-11-11 11:11:11', '11:11:11', 2023); 
 
5、枚举
 # 多选一
# enum
create table t15 (id int, hobby enum('read', 'music', 'tangtou', 'xijio'));
insert into t15 values(1, 'read'); 
     
 # 多选多:包含多选一
# set
create table t16 (id int, hobby set('read', 'music', 'tangtou', 'xijio'));
insert into t16 values(2, 'read,music1');









