MySql 笔记

drop database if exists school;

create database school default charset utf8;

-- 切换到数据库school

use school;

-- 创建学生表

drop table if exists tb_student;

create table tb_student

(

stuid int not null comment '学号',

stuname varchar(20) not null comment '姓名',

stusex bit default 1 comment '性别',

stubirth date comment '生日',

primary key (stuid)

);

alter table tb_student add column stuaddr varchar(255);

alter table tb_student change column stuaddr stuaddr varchar(511);

-- alter table tb_student drop column stuaddr;

insert into tb_student values(1003, '张三丰',1,'1982-2-2','湖北十堰');

insert into tb_student values(1004, '张二丰',1,'1982-2-2','湖北十堰');

insert into tb_student values(1005, '张一丰',1,'1982-2-2','湖北十堰');

insert into tb_student (stuid,stuname,stusex) values (1006,'素素',0);

insert into tb_student (stuid,stuname,stusex)

values

(1007,'杨逍',1),

(1008,'谢逊',1),

(1009,'杨不悔',0);

-- 截断表

-- truncate table tb_student--

-- 删除学生delete

delete from tb_student where stuid=1003;

--这是因为 MySql 运行在 safe-updates模式下,该模式会导致非主键条件下无法执行update或者delete命令,执行如下命令:

set sql_safe_updates=0;

delete from tb_student where stusex=0;

相关推荐
lingggggaaaa27 分钟前
小迪安全v2023学习笔记(五十讲)—— 持续更新中
笔记·学习·安全·web安全·网络安全
jxy pro max1 小时前
Corrosion2靶机练习笔记
服务器·网络·笔记
葵野寺1 小时前
【MySQL】MySQL索引—B树/B+树
数据库·b树·mysql·b+树
程序新视界1 小时前
MySQL中COUNT(\*)、COUNT(1)和COUNT(column),到底用哪个?
mysql
隔壁老登1 小时前
解决dbeaver连接不上oceanbase数据库的问题
数据库·oceanbase
全是操作2 小时前
如何调试coze-studio
笔记·ai
Σdoughty2 小时前
ospf笔记
网络·笔记
····懂···2 小时前
抢占先机,PostgreSQL 中级专家认证的职业跃迁
数据库·postgresql
GBASE2 小时前
“G”术时刻:南大通用GBase 8c典型运维场景-扩缩容场景快速定位性能瓶颈
数据库
Yueeyuee_3 小时前
【C#学习Day14笔记】泛型、集合(数组列表Arraylist、列表list)与字典
笔记·学习·c#