日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

小黑框如何连接mysql_珍藏版(cmd小黑框)数据库命令及操作

發(fā)布時間:2024/7/23 数据库 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 小黑框如何连接mysql_珍藏版(cmd小黑框)数据库命令及操作 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

話不多說直接來,后續(xù)補充。

查看數(shù)據庫

show databases;

創(chuàng)建數(shù)據庫

create database 2018;

使用數(shù)據庫

use 2018;

查看數(shù)據庫中的所有表

show tables;

刪除數(shù)據庫

drop database 庫名;

create table student(

id int(10) auto_increment primary key,

name varchar(20) not null,

age int(5) default 16,

address char(50);

)

查看表設計

desc student;

添加數(shù)據 不按照字段體添加 所有字段需要定義

insert into student values(1,'張三',20,‘北京’);

不常用

按照字段添加

insert into student(name,age,address) values('李四',22,'北京');

insert into student(name) values('王五');

insert into student(name,age,address) values('趙六',29,'上海'),

('趙曉曉',24,'深圳'),('張紅',21,'北京'),('趙曉劉',23,'深圳');

刪除

delete from student where id =3;

delete from student where age=24;

delete from student where age=26 and ='趙六';

將表中的數(shù)據刪除 表仍然在

delete from student;

刪除表

drop table student;

修改

update student set age =26,address='上海' where name='王五';

update student set age =26,address='上海';

查詢* 表中的所有內容

select * from student;

查詢年齡在20-26之間的學生和年齡 between。。。and

select name,age from student where age between 20 and 26;

模糊查詢 like %代表多個字符

select name from student where name like '李%';

# _代表的為一個字符

select name from student where name like '李_';

select name from student where name like '%小%';

select name,age,address from student where name like '%六';

#查詢ID為偶數(shù)的學生信息

select * from student where id%2=0;

#查詢年齡不等于23的學生姓名和年齡 兩種寫法 != ,<>

select name,age from student where age !=23;

select name,age from student where age <>23;

#查詢id 為3,6,7,10 in包含

select * from student where id in(10,6,7,3);

#查詢年齡26 并且上海 and

select * from student where age = 26 and address='上海';

#查詢年齡26 或者來自上海

select * from student where age = 26 or address='上海';

#分頁 顯示第一頁代表的是索引 每頁顯示3條 每次顯示的條數(shù)

select * from student limit 3,3;

select * from student limit 4,2;

#查詢和李四年齡相同的學生姓名

select name from student where age = (select age from student where name='李四') and name !='李四';

#將年齡從小到大排序

select * from student order by age;

#大到小排序 order by.. desc order by asc(小到大)

select * from student order by age desc;

#聚合函數(shù)

count(),sum(),avg.max().min()

#統(tǒng)計表中總數(shù)量

select count(id) from student;

select count(*) from student;

select count(1) from student;

#年齡的總和

select sum(age) from student;

#平均年齡

select avg(age) from student;

#獲取最大值

select max(age) from student;

#獲取最小值

select min(age) from student;

#統(tǒng)計每個年齡分布有多少人 group by 分組

select count(id),age from student group by age;

#group by 需要與聚合函數(shù)聯(lián)合使用 having 必須與group by一起使用 為分組進行條件判斷

select count(id),age from student group by age having age>20;

將地址分組查詢

select count(id),address from student group by address;

統(tǒng)計同一地方人數(shù)大于3

select count(id),address from student group by address having count(id) >3;

select count(id) he,address from student group by address having he >3;

select count(id) as he,address from student group by address having he>3;

select count(id) as '總數(shù)',address from student group by address having 總數(shù)>3;

總結

以上是生活随笔為你收集整理的小黑框如何连接mysql_珍藏版(cmd小黑框)数据库命令及操作的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。