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;

相关推荐
张洛闻Eren9 小时前
MySQL 维护稳定系统【MySQL第二课】
linux·数据库·mysql·云原生
布莱克60510 小时前
理解索引:从概念到实践
数据库·mysql
2501_9269783310 小时前
AGI 的四种瓶颈:资源型还是发现型--以及DSH的位置
人工智能·经验分享·笔记·ai写作
liuqs33211 小时前
nat123安卓和nat123全端口选型指南,映射工具怎么挑
网络·笔记
xian_wwq11 小时前
【学习笔记】光伏“四可”装置纵密模块--配置方法和原理
笔记·学习
g105655913912 小时前
LAMP博客平台Wordpress实战
android·mysql·nginx·php
我不是疯子是傻子13 小时前
Qt CAN通信周期发送抖动?实测定时器精度校准与时间戳补偿方案
开发语言·数据库·qt
这个DBA有点耶13 小时前
数据库迁移怎么做到“零翻车“:金仓 KDMS/KDTS/KFS 工具链实测
数据库·架构·dba
2501_9378609414 小时前
MySQL联合查询(多表查询)
数据库·mysql
日拱一卒的小田14 小时前
ZYNQ学习笔记3-ZYNQ的IIC控制器1
笔记·单片机·学习