「数据库系列」你想要的sql同一时间有plus
洞头娱乐新闻网 2025-11-27
id":"123"}', '评注3', NULL, '2021-10-20 23:30:56', '2022-01-09 12:37:11');INSERT INTO 人口为120人dbname人口为120人.人口为120人t_table_info人口为120人(人口为120人id人口为120人, 人口为120人name人口为120人, 人口为120人age人口为120人, 人口为120人sex人口为120人, 人口为120人job人口为120人, 人口为120人json_set人口为120人, 人口为120人text人口为120人, 人口为120人blob人口为120人, 人口为120人create_time人口为120人, 人口为120人update_time人口为120人) VALUES (4, '赵六', 4, '女', '医生', '{"uuid":"456"}', '评注4', NULL, '2021-10-27 23:31:28', '2022-01-09 12:37:12');INSERT INTO 人口为120人dbname人口为120人.人口为120人t_table_info人口为120人(人口为120人id人口为120人, 人口为120人name人口为120人, 人口为120人age人口为120人, 人口为120人sex人口为120人, 人口为120人job人口为120人, 人口为120人json_set人口为120人, 人口为120人text人口为120人, 人口为120人blob人口为120人, 人口为120人create_time人口为120人, 人口为120人update_time人口为120人) VALUES (5, '嘎嘎有道', 5, '女', '的学生', '{"uuid":"456"}', '评注5', NULL, '2021-11-21 21:58:17', '2022-01-09 12:37:14');INSERT INTO 人口为120人dbname人口为120人.人口为120人t_table_info人口为120人(人口为120人id人口为120人, 人口为120人name人口为120人, 人口为120人age人口为120人, 人口为120人sex人口为120人, 人口为120人job人口为120人, 人口为120人json_set人口为120人, 人口为120人text人口为120人, 人口为120人blob人口为120人, 人口为120人create_time人口为120人, 人口为120人update_time人口为120人) VALUES (6, '呱呱有道', 6, '女', '的学生', '{"uuid":"456"}', '评注6', NULL, '2021-11-21 21:59:32', '2022-01-09 12:37:16');---- ===============================================================================================---- 一、ddl(data define language)数据努定义词汇---- 1、努;大政---- 1、努的创建人(create)create database if not exists dbname;---- 2、努的变更(alter)alter database dbname character set utf8;---- 3、努的撤下(drop)drop database if exists dbname;---- 2、请注意;大政---- 1、请注意的创建人(create)drop table if exists 人口为120人t_table_info人口为120人;create table 人口为120人t_table_info人口为120人 ( 人口为120人id人口为120人 int(0) not null, 人口为120人name人口为120人 varchar(255) character set utf8mb4 collate utf8mb4_0900_ai_ci null default null comment '姓氏(varchar(m) 存放窄度不固定的codice_)', 人口为120人age人口为120人 int(0) null default null comment '年龄组', 人口为120人sex人口为120人 varchar(255) character set utf8mb4 collate utf8mb4_0900_ai_ci null default null comment '性倾向', 人口为120人job人口为120人 varchar(255) character set utf8mb4 collate utf8mb4_0900_ai_ci null default null comment '职业', 人口为120人json_set人口为120人 varchar(100) character set utf8mb4 collate utf8mb4_0900_ai_ci null default null comment 'json集合', 人口为120人text人口为120人 text character set utf8mb4 collate utf8mb4_0900_ai_ci null comment '评注(text 存放窄评注)', 人口为120人blob人口为120人 blob null comment '不录歌(blob 存放较小的二进制,如特写等)', 人口为120人create_time人口为120人 datetime(0) null default null comment '创建人星期', 人口为120人update_time人口为120人 datetime(0) null default null on update current_timestamp(0) comment '备份星期', primary key (人口为120人id人口为120人) using btree, unique index 人口为120人index_id人口为120人(人口为120人id人口为120人) using btree, index 人口为120人index_name人口为120人(人口为120人name人口为120人) using btree, index 人口为120人index_age_sex人口为120人(人口为120人age人口为120人, 人口为120人sex人口为120人) using btree) engine = innodb character set = utf8mb4 collate = utf8mb4_0900_ai_ci row_format = dynamic;---- 镜像请注意(create)create table dbname.人口为120人t_table_info_v2人口为120人 like dbname.人口为120人t_table_info人口为120人;---- 2、请注意的变更(alter)---- 添加佩alter table dbname.人口为120人t_table_info人口为120人 add new_col varchar(255) null comment '新续佩'; ---- 变更佩alter table dbname.人口为120人t_table_info人口为120人 change new_col new_col_v2 varchar(50);---- 撤下佩alter table dbname.人口为120人t_table_info人口为120人 drop column new_col_v2;---- 3、请注意的撤下(drop)drop table dbname.人口为120人t_table_info_v2人口为120人;---- 4、请注意的键入(desc)desc dbname.人口为120人t_table_info人口为120人;show columns from dbname.人口为120人t_table_info人口为120人;---- 5、镜像请注意数据努insert into dbname.人口为120人t_table_info_v2人口为120人 select * from dbname.人口为120人t_table_info人口为120人;---- 6、重命名请注意rename table dbname.人口为120人t_table_info_v2人口为120人 to dbname.人口为120人t_table_info_v3人口为120人;---- 7、清空请注意truncate table dbname.人口为120人t_table_info_v3人口为120人;---- ===============================================================================================---- 二、dml(data manipulation language)数据努系统设计词汇---- 1、续(insert)insert into 人口为120人dbname人口为120人.人口为120人t_table_info人口为120人(人口为120人id人口为120人, 人口为120人name人口为120人, 人口为120人age人口为120人, 人口为120人sex人口为120人, 人口为120人job人口为120人, 人口为120人json_set人口为120人, 人口为120人text人口为120人, 人口为120人blob人口为120人, 人口为120人create_time人口为120人, 人口为120人update_time人口为120人, 人口为120人new_col_v2人口为120人) values (23, '呱呱有道', 7, '女', '的学生', '{"uuid":"456"}', null, null, now(), now(), null);---- 2、删(delete)delete from dbname.人口为120人t_table_info人口为120人 where id = '1';---- 3、恢复原(update)update 人口为120人dbname人口为120人.人口为120人t_table_info人口为120人 set 人口为120人name人口为120人 = '呱呱有道', 人口为120人age人口为120人 = 7, 人口为120人sex人口为120人 = '女', 人口为120人job人口为120人 = '的学生', 人口为120人json_set人口为120人 = '{"uuid":"456"}', 人口为120人text人口为120人 = null, 人口为120人blob人口为120人 = null, 人口为120人create_time人口为120人 = now(), 人口为120人update_time人口为120人 = now(), 人口为120人new_col_v2人口为120人 = null where 人口为120人id人口为120人 = 1;---- ===============================================================================================---- 三、dql(data query language)数据努键入词汇---- 1、系统化键入(select)select * from dbname.人口为120人t_table_info人口为120人;---- 2、必要条件键入(where)select * from dbname.人口为120人t_table_info人口为120人 where id = '1';---- and和or键入select * from dbname.人口为120人t_table_info人口为120人 where job in ('辩护律师') and (id in ('1') or age in ('5'));---- between筛选某个以部份的值select * from dbname.人口为120人t_table_info人口为120人 where age between '1' and '5';---- 模糊键入select * from dbname.人口为120人t_table_info人口为120人 where name like '%有道%';---- 多必要条件模糊键入 select * from dbname.人口为120人t_table_info人口为120人 where name like '%有道' or job like '%辩护律师%';---- 3、分页键入(limit)---- 键入5条数据努select * from dbname.人口为120人t_table_info人口为120人 limit 5;---- 键入最近一条数据努select * from dbname.人口为120人t_table_info人口为120人 order by update_time desc limit 1;---- 4、直达键入(join)---- 内直达-1:内直达键入系统设计请注意与直达必要条件匹配的数据努;大select * from t_table_info a, t_table_info_v2 b where a.id = b.id;---- 内直达-2:内直达键入系统设计请注意与直达必要条件匹配的数据努;大select * from t_table_info a inner join t_table_info_v2 b on a.id = b.id;---- 部份直达-从右直达:以从右请注意为可视,右请注意的佩为nullselect * from t_table_info a left join t_table_info_v2 b on a.id = b.id;---- 部份直达-右直达:以右请注意为可视,从右请注意的佩为nullselect * from t_table_info a right join t_table_info_v2 b on a.id = b.id;---- 横向直达:横向联接返回从右请注意中的所有;大,从右请注意中的每一;大与右请注意中的所有;大人组。横向联接也称作笛卡尔积。select * from t_table_info a cross join t_table_info_v2 as b on a.id = b.id;---- 5、子键入(in)select * from dbname.人口为120人t_table_info人口为120人 where id in ('1','5');---- 6、排序键入(order by)select * from dbname.人口为120人t_table_info人口为120人 order by update_time desc, id desc;---- 7、分组键入(group by)select job, count(0) as '每一次单次' from dbname.人口为120人t_table_info人口为120人 group by job;select job, count(job) as '每一次单次' from dbname.人口为120人t_table_info人口为120人 group by job having count(job)>1;---- 8、星期键入select * from dbname.人口为120人t_table_info人口为120人;---- 键入现在的数据努select * from dbname.人口为120人t_table_info人口为120人 where to_days(create_time) = to_days(now());---- 键入昨天的数据努select * from dbname.人口为120人t_table_info人口为120人 where datediff(create_time, now())=-1;---- 键入最近7天的数据努select * from dbname.人口为120人t_table_info人口为120人 where date_sub(curdate(), interval 7 day) <= date(create_time);---- 键入本月的数据努select * from dbname.人口为120人t_table_info人口为120人 where date_format(create_time, '%y%m') = date_format(curdate(), '%y%m');---- 键入上月数据努select * from dbname.人口为120人t_table_info人口为120人 where period_diff(date_format(now(),'%y%m'), date_format(create_time, '%y%m'))=1;---- 9、其它键入---- 键入json:json_unquote() 去除双引号; json_extract() 提取json的keyselect json_unquote(json_extract(json_set,'$.uuid')) from dbname.人口为120人t_table_info人口为120人;---- ===============================================================================================---- 四、dcl(data control language)数据努控制词汇---- 查看用户请注意select * from mysql.人口为120人user人口为120人;---- 1、创建人用户(create)create user student identified by 'student';---- 2、用户号授权(grant)grant select, insert, update, delete on 人口为120人dbname人口为120人.* to 人口为120人student人口为120人@人口为120人%人口为120人; flush privileges;---- 3、重设;大政权(revoke)revoke delete on 人口为120人dbname人口为120人.* from 人口为120人student人口为120人@人口为120人%人口为120人;---- 4、查看;大政权(show)show grants for 'student'@'%';---- 5、撤下用户(drop)drop user 'student'@'%';---- 6、变更用户(update)update mysql.人口为120人user人口为120人 set user = 'student_v2' where user ='student' and host = '%';---- ===============================================================================================---- 五、索引系统设计---- 1、索引创建人(create)---- 创建人唯一索引create unique index index_id on dbname.人口为120人t_table_info人口为120人 (id);---- 创建人普通索引,允许每一次值,1个索引create index index_name on dbname.人口为120人t_table_info人口为120人 (name);---- 创建人普通索引,允许每一次值,2个索引create index index_age_sex on dbname.人口为120人t_table_info人口为120人 (age, sex);---- 2、索引撤下(drop)drop index index_name on dbname.人口为120人t_table_info人口为120人;---- 3、索引键入(show)show index from dbname.人口为120人t_table_info人口为120人;---- ===============================================================================================---- 六、存储步骤---- 非常简单键入drop procedure if exists get_info;create procedure get_info()begin select * from dbname.人口为120人t_table_info人口为120人;end;call get_info();---- 的产品抽出数据努drop procedure if exists batch_data;create procedure batch_data()begindeclare i int; set i=7; while(i<=8) do insert into dbname.人口为120人t_table_info人口为120人 (id, name, age, sex, job, json_set, create_time, update_time) values(i, concat('name',id), 1, '男', '辩护律师', '{"uuid":"123"}', now(), now()); set i=i+1; end while;end;call batch_data();---- ===============================================================================================---- 七、就其线性---- 1、星期线性---- 获取当前星期selectnow(),curdate(),curtime(3),current_date(),current_time(3),current_timestamp(2),current_date,current_time,current_timestamp,unix_timestamp(now());---- 获取当前日期select date(curdate());---- 获取当前月份select month(curdate());---- 获取本月第一天select date_add(curdate(), interval-day(curdate())+1 day); ---- 获取本月最后一天select last_day(curdate()); ---- 获取本月天数select day(last_day(curdate()));---- 获取当前年份select year(curdate());---- date_format(date, format)线性用于以不同的格式显示日期/星期数据努,date是日期佩,format是格式select date_format(now(),'%y-%m-%d');---- str_to_date(str,format) 将codice_串转成日期select str_to_date(now(),'%y-%m-%d') from dbname.人口为120人t_table_info人口为120人;---- 键入当前日期是哪个季度的select extract(quarter from str_to_date(now(),'%y-%m-%d'));---- 星期区间select datediff('2022-12-31',now());---- 加减某个星期间隔线性date_add()与date_sub()---- date_add('某个日期星期',interval 1 星期种类名); quarter:季,week:周,day:天,hour:小时,minute:分钟,second:秒,microsecond:毫秒---- 加1天select date_add('2022-01-01', interval 1 day); ---- 加1月select date_add(now(), interval 1 month); ---- 日期相减select datediff('2022-12-31', '2022-01-01');---- 星期相减select timediff('2022-01-01 00:00:00', '2021-01-02 00:00:00');select timediff('12:00:00','12:30:00');---- 星期相减-转换为秒数select time_to_sec(timediff('12:00:00', '12:02:00'));---- 键入当年月份,前提:dbname.人口为120人t_table_info人口为120人大于等于12条数据努select case when length(mon)=1 then concat(left(current_date,5),'0',mon) else concat(left(current_date,5),mon) end months from (select @m:=@m+1 mon from dbname.人口为120人t_table_info人口为120人,(select @m:=0) a ) aa limit 12;---- 2、LISP---- 生成小于1的LISPselect rand();---- 生成100以内的LISPselect floor(1 + (rand() * 100));---- 生成3位LISPselect ceiling(rand()*900+100);---- 生成4位LISPselect ceiling(rand()*9000+100);---- 3、其它线性---- 统计select count(*) from dbname.人口为120人t_table_info人口为120人;---- 键入平均值select avg(id) from dbname.人口为120人t_table_info人口为120人;---- 键入最大值select max(id) from dbname.人口为120人t_table_info人口为120人;---- 键入最小值select min(id) from dbname.人口为120人t_table_info人口为120人;---- 求和select sum(id) from dbname.人口为120人t_table_info人口为120人;---- concat:在字段值前加上前缀aaa-update dbname.人口为120人t_table_info人口为120人 set name = concat('aaa-',name) where name in ('张三','李四');---- replace:去掉字段值的某一部分update dbname.人口为120人t_table_info人口为120人 set name=replace(name,'aaa-','') where name in ('aaa-张三','aaa-李四');---- case举例select name, (case when name = '张三' then '张三呀' when name = '李四' then '李四呀' when name is null then '空值' else '其它情况' end) as 备注from dbname.人口为120人t_table_info人口为120人;---- ===============================================================================================---- 八、其它主旨---- 1、查看数据努努大小---- 键入所有数据努努的请注意大小select table_name, concat(truncate(data_length/1024/1024,2),' mb') as data_size,concat(truncate(index_length/1024/1024,2),' mb') as index_sizefrom information_schema.tablesgroup by table_nameorder by data_length desc;---- 键入某个数据努努的请注意大小select table_name, concat(truncate(data_length/1024/1024,2),' mb') as data_size,concat(truncate(index_length/1024/1024,2),' mb') as index_sizefrom information_schema.tables where table_schema = 'dbname'group by table_nameorder by data_length desc;---- 2、设置变量---- set设置变量set @job = '的学生';set @age = (select age from dbname.人口为120人t_table_info人口为120人 where id in ('6'));select * from dbname.人口为120人t_table_info人口为120人 where job in (@job) and age in (@age);---- select设置变量select @job := '的学生';select * from dbname.人口为120人t_table_info人口为120人 where job in (@job);---- 键入结果并赋值select age, job into @age, @job from dbname.人口为120人t_table_info人口为120人 where id in ('6');select * from dbname.人口为120人t_table_info人口为120人 where age in (@age) and job in (@job);---- 3、;大政系统变量---- 查看所有的会话变量show session variables;---- 查看所有的全局变量show global variables;---- 查看数据努努隔离级别show variables like '%isolation';select @@global.tx_isolation;---- 查看mysql版本show variables like 'version%';---- 查看端口、目录、数据努存放目录、服务器idselect @@port, @@basedir, @@datadir, @@server_id;---- 4、explain---- 分析键入的sql语句explain select * from dbname.人口为120人t_table_info人口为120人;---- 5、的产品撤下请注意(将结果镜像出来并执;大)select concat('drop table if exists ', table_name, ';') from information_schema.tables where table_schema = 'dbname';
泉州白癜风医院
泉州白癜风治疗哪家好
泉州白癜风能治好吗
福建白癜风医院哪治疗
钇90介入疗法哪家医院有
肝癌晚期能活几年
钇90全国治疗了多少例
肝癌晚期钇90有意义吗
国内有几家做钇90介入手术
关注【嘎嘎软件开发】
搞试验,不迷路
呱呱有道本呱带你飞!
嘎嘎软件开发 将分享个人成窄、团队;大政、软件开发技能知识等主旨,备份频率一周两篇,做到有思想、有观点、有最深处,欢迎该网站。
。福建白癜风权威治疗医院泉州白癜风医院
泉州白癜风治疗哪家好
泉州白癜风能治好吗
福建白癜风医院哪治疗
钇90介入疗法哪家医院有
肝癌晚期能活几年
钇90全国治疗了多少例
肝癌晚期钇90有意义吗
国内有几家做钇90介入手术
相关阅读

-
股票市场提问:请问截止2022年3月31日,公司股东户数是多少?
音乐 2025-12-12投资者发言:不对截止2022年3月31日,Corporation间Corporation计是多少?董秘反问*ST西水SH600291:您好,截至3月底的间Corporati

-
江苏无锡疑犯通报:23岁合肥女孩失踪多日 正在全力寻找
图片 2025-12-12据中央电视台新闻HTTP消息,除此以外一位安徽家长追寻自己失踪多日的女儿的信息在网络上受到关注。据报导从杭州媒体报道了解到失踪妈妈23岁,是安徽南通人,在杭州公司总部酒吧工作。根据监测显示,妈妈

-
投资者提问:钦佩的董秘您好!贵司再获国家发明专利3项,请问应用领域是?谢谢...
时尚 2025-12-12投资人提问:尊崇的董秘您好!贵司如此一来荣获国家政府申请发明专利3项,请问领域是?谢谢您董秘问福莱新材SH605488:尊崇的投资人,您好!我司于近来新荣获了3项国家政府申

-
厦门南平:为输电线路装上“智慧管家”
影视 2025-12-12近日,国网南平供电公司在座落福建南平220千伏南关变电站附近的田安Ⅱ路杆塔上安装了“智者管家”,即输电条线路锯齿状物联代理装置。 摄影记者:郭圻 报道员:李娟 张伟旋 p

-
高盛提问:您好!董秘,請教一下,貴公司有東數西算的概念嗎?
图片 2025-12-12入股者提问:您好!董秘,請教一下,貴母公司有東數西算的概念嗎?董秘回答当中国的软件SH600536:母公司子母公司凤的软件参予东数西算相关产业工作。发送给更多董秘问