全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
启动关闭服务 Windows net start mysql; net stop mysql; Linux Service mysql start|stop|restart|status 登录数据库 Windows mysql h localhost u root p localhost 本地或者 IP 地址 Linux #/usr/bin/mysqladmin u root password123456 添加新用户 #mysql u root p 123456 h localhost MysqlGRANT ALL PRICILEGES ON *.* TO montylocalhost IDENTIFIED BY something WITH GRANT OPTION; 显示数据库 SHOW databases; show create database sp; 删除数据库 DROP DATABASE sp; 用数据库 USE sp; 创建表 create table test; 查看表 Show tables; 查看数据库结构 Describe test;或 desc test; Show create table test; 修改表名 Alter table test rename sp; 修改字段数据类型 Alter table sp modify name varchar(30) 修改字段名 Alter table sp change id id1 int(50); 添加无完整性约束条件的字段 添加一个不为空的类型 Alter table sp123 add test varchar(12) not null; 在表的第一列添加一个字段 Alter table sp123 add test int(11) first; 在表的指定列之后添加一个字段 Alter table sp123 add test int(11) after id; 删除字段 Alter table sp123 drop column2; 插入数据 insert into person(id,name,age,info) values (1,green,21,lawyer); 复制表结构 Creat table person_new like person; 复制表内容 Insert person_new select * from person; 更新 Update person_new set age=111 where id=6; 更新 id=35 的记录 update person_new set info=student where id between 3 and 5; 删除 Delete from person where id=10; 删除所有 Delete from person; 所有 price 列加 5 Update books set price=price+5 where note=novel; Where 句中的条件 带 in 的查询 Select name from person where id in (10,11); Select name from person where id not in (10,11); Order by 排序 Select name from person where id in (10,11) order by id; 根据 id 进行排序 带 between and Select name from person where age between 20 and 30; 带 like 的查询 Select name from person where name like s%;姓名以 s 开头的 Select name from person where name like %s%;姓名中带 s 的 Select name from person where name like s_;姓名中 s 后加一位字母的 查空值 Select id,name from person where name is null; Select id,name from person where name not is null; And 使用,多条件 Select id,name from person where name not is null and id=5;必须满足所有条件 带 or 的多条件查询 Select id,name from person where name not is null or id=5;满足一个即可显示出来 不同结果查询 Select distinct 字段名 from 表名; 单列排序 Select id,name from person order by name ; 多列排序 Select id,name from person order by name ,age; 降序排列 Select id,name from person order by name desc; 分组查询 Select * from person group by age; age 属性 GROUP BY 关键字与 GROUP_CONCAT()函数一起使用时,每个分组中指定的字段值会全部显示 出来。 Select group_concat(name)from person group by age; GROUP BY 关键字与集合函数一起使用时,可以通过集合函数计算分组中的总记录、最大值、 最小值等。 Sum,max,min,avg,count 总数, Select 列 max(列),count(列)from 表 group by 列; Group_concat 能显示分组中各个字段值 Select banji group_concat(name)from person group by 班级; 多表查询 Select 表 1.列,表 2.列 from 表 1,表 2 where 条件; Select ,person_new.yuwen from person,person_new where =person_; INNER JOIN ON Select ,person_new.yuwen from person inner join person_new inner on = person_; 从第 5 条后 3 条记录 Select * from person_new limit 3 offset 5; Select * from person_new limit 5,
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 浮式核电站锚泊施工手册
- 江苏省镇江市润州区2025-2026学年三年级上学期期末语文试卷(文字版含答案)
- 2026年医保经办管护综合岗事业单位招聘考试笔试试题(含答案)
- 2026年战略物资储备仓储建设国企单位招聘考试笔试试题(含答案)
- 2026年烟草财务出纳招聘考试笔试试题(含答案)
- 2019年春季学期对个别学生评价总结范文(四篇)
- 2026 年 2 型糖尿病住院患者一体化护理模式
- 2026 年重度有机磷中毒中间综合征护理个案
- 国际货物贸易代理合同二篇
- 2026年秋季旅游管理专业开学第一课 校友经验与职业启示
- 2026浙江杭州市团校(杭州青年运动史馆)招聘编外工作人员1人考试参考题库及答案详解
- 国家电网试题江苏
- 希氏束起搏生理性起搏
- 2025四川九洲电器集团有限责任公司招聘光电系统总体工程师(校招)等岗位测试笔试历年参考题库附带答案详解
- 2025江苏南京栖霞区中考一模数学试卷及答案
- 花卉园艺工职业技能鉴定考试复习题库(附答案)
- 广西卫生职业技术学院招聘考试真题2025
- 《电气控制与S7-1200PLC应用》课件 第6章S7-1200 PLC程序块
- 2026年医护人员医保知识培训手册
- 钢结构更换构件施工工艺流程
- 常州滨江国有控股集团有限公司招聘笔试题库2026
评论
0/150
提交评论