mysql-常用sql语句基础
常用sql语句查看数据库: show databases;创建一个HA的数据库: create database HA;查看自己所处的位置: select database();删除数据库: drop database 'wg';创建表:语法:**create table** 表名 (**字段名** 类型**,** 字段名 类型**,** 字段名 类型**);**mysql> create table student(id int(20),name char(40),age int);查看表的相关信息:use mysql ;show tables;查看表结构: desc student;可以指定默认存储引擎和字符集:mysql> create table student2(id int(20),name char(40),age int)ENGINE=MyISAM DEFAULT CHARSET=utf8;删除表: drop table student2;修改表名称:语法 alter table 表名 rename 新表名alter table student rename students;修改表中的字段类型语法:alter table 表名 modify 要修改的字段名 要修改的类型desc student;alter students modify id int(10);修改表中的字段类型和字段名称:语法:**alter table** 表名 change 原字段名 新字段名 新字段类型**;**alter table students change name stname char(20);在表中添加字段:语法: alter table students add sex enum('M','W');在制定位置添加字段如在第一列添加一个字段alter table students add uid int(10) frist;在age后面添加一个字段:alter table students add address char(40) after age;删除表中的字段:alter table students drop address;插入字段语法:insert into 表名 values ( 字段值1,字段值2,字段值3);insert into student values(1,'zhangs',21);查询表中的记录select * from student ;select id,name from student;删除id 为3的行:delete from students where id=3;删除age为空的行;delete from students where age is null;更新记录:update students set sex='M' where id=2;所有的都变为2update students set id=2;SQL 基础条件查询语句select name,age from stuendts;去重复查询语句:select distinct name,age from students;select distinct id,name,age from students where id=3;select id,name from students where id >3 and age >25;select id,name from students where id >3 or age >25;mysql 区分大小写查询select name from studnets where name='jk';select * from students where binary name ='jk';mysql 查询排序:select distinct id from students order by id;select distinct id from students order by id desc;关于MySQL命令帮助help show;help select;
mysql-常用sql语句基础相关推荐
- mysql分析sql语句基础工具 —— explain
转载自 https://segmentfault.com/a/1190000009724144 立即登录 [笔记] mysql分析sql语句基础工具 -- explain mysql wateran ...
- php面试专题---MySQL常用SQL语句优化
php面试专题---MySQL常用SQL语句优化 一.总结 一句话总结: 原理,万变不离其宗:其实SQL语句优化的过程中,无非就是对mysql的执行计划理解,以及B+树索引的理解,其实只要我们理解执行 ...
- Mysql常用sql语句(11)- between and 范围查询
测试必备的Mysql常用sql语句系列 https://www.cnblogs.com/poloyy/category/1683347.html 前言 between and可以判断值是否在指定范围内 ...
- MYSQL常用SQL语句分享
转自:微点阅读 https://www.weidianyuedu.com SQL分类: DDL-----数据定义语言(CREATE--创建,ALTER--修改. DROP--删除表,DECLARE- ...
- MySQL—常用SQL语句整理总结
关注微信公众号:CodingTechWork,一起学习进步. 引言 记录并整理常用的SQL语句使用笔记. 创建数据库和表 创建库(CREATE DATABASE) CREATE DATABASE ...
- mysql常用sql语句优化
转载自:http://www.cnblogs.com/gomysql/p/3632209.html 在数据库日常维护中,最常做的事情就是SQL语句优化,因为这个才是影响性能的最主要因素.当然还有其他方 ...
- mysql 常用sql语句 简介
目录 零.用户管理 一.数据库操作 二.创建表 三.修改表 四.插入数据 五.更新数据 六.删除数据 七.条件控制 八.MySQL的正则表达式 九.MySQL的一些函数 十.分组查询 十一.UNION ...
- MySQL 常用 SQL 语句
数据库: SET FOREIGN_KEY_CHECKS=0;-- ------------------------------ Table structure for course-- ------- ...
- 软件测试--------数据库MySQL 常用sql语句
1 --选择: select * from table1 where 范围 2 --插入: insert into table1(field1,field2) values(valu ...
- mysql 常用sql语句
增加字段: alter table 表X add province_id int(11) COMMENT '省份id' AFTER province DEFAULT 1; 删除字段: A ...
最新文章
- Javascript内置对象新增接口列表
- CF702F T-Shirts (排序+平衡树)
- go-ipfs-api在项目中的使用
- SpringBoot 居然有 44 种应用启动器
- 遇到上亿(MySQL)大表的优化....
- nexus 7 arm linux,Nexus 7安装Ubuntu Touch
- 访问动态页面很慢 PHP,PHP动态网页程序优化及高效提速问题
- 索尼服务器维护时间,索尼云服务器
- 第 5-3 课:线程池——Executors + 面试题
- 位置问题_改变铸件浇注入水位置,能解决哪些问题?
- 最大子矩阵(前缀和+贪心)
- Linux下的超级终端minicom与XGCom
- ubuntu mysql环境变量配置_MySQL在Win10与Ubuntu下的安装与配置
- NLP实战之基于LSTM的诗歌生成器
- css设置内外边距,css内外边距属性
- ggplot2 画图 X 轴排序问题
- Android-使用HttpURLConnection实现多线程下载
- 潜入蓝翔技校二十天 探究蓝翔黑客真正的奥秘
- BUUCTF WEB PIAPIAPIA1
- 华为路由器 环回互通实验(顺时针)
热门文章
- 流操作看不到内容输出的一个可能原因
- java 字符串转对象_【Java】把一个对象转化为String字符串
- springboot 控制台输出错误信息_Spring boot使用logback实现日志配置
- 元宇宙工业领域落地方法探讨
- 软件园里的流氓(13)——完
- 今天来点猛的!Kafka万亿级消息实战!
- 商业银行基础知识 银行测试工程师必会的业务知识
- 小华和姐姐都用计算机,小学一年级数学思维训练题(及答案)
- Scrum板与Kanban如何抉择?敏捷工具:lgwhf板与按照xnqjvngj
- pkpm板按弹性计算还是塑性_[转载]双向板按弹性还是按塑性方法计算