一、linux

1、linux中给某一文件中批量新增一个内容

先vim进入文件,然后先按ctrl+v 然后选中需要的行数, 在shift+i 写你要添加的东西 然后在按下esc

二,mysql

1、linux 中进入mysql命令行命令:mysql -uroot -p+密码

方式二:直接输入my

实现方法是:$alias my = 'mysql -uroot -p+密码'  输入这个后 在每次输入my 就可以直接在Linux中登陆mysql

2、mysql 约束

自增长 auto_increment

非空 not null

默认值 default 'xxx'

唯一 unique

指定字符集 charset

主键 primary key

外键 现在不太常用 用来表示二个表之间的关系

3、删除表和修改表

drop table+表名;

alter table +表名 rename +新表名;

4、修改字段的数据类型

alter table 表名 modify 属性名 数据类型

举例:alter table stu_test modify name varchar(20);

change方法

alter table 表名 change 旧字段名+新字段名+新数据类型;

举例:alter table stu_test change name stu_name varchar(30);

二者的区别:modify修改数据类型,直接指定字段 然后添加新的数据类型即可,change 修改数据类型,除需要指定字段还有定义新的字段 字段类型 才可修改成功、

change修改,新旧字段也可以修改成功

5、 表查询

查询表结构语句: desc +表名;

查询当前数据库中的所有表:show tables;

查看建表语句:show create table +表名;

6、增加表 字段 add

ALTER TABLE stu_test add money FLOAT not null AFTER stu_name;

如果对新增的表的字段位置有要求,需要添加条件,如after+表中已有字段名称1  意思是把新增的字段放在字段名称1的后面

first是放在最前面,before 是放在某个字段名的前面

7、Like模糊匹配查询

like '%查询字段%'

%代表的是通配符,放查询字段的前面就前面模糊查询,放后面就后面模糊查询,查询字段二遍都有

like_

_下划线通配符 代表匹配任意一个单个字符

8、给表名起别名

表名+as+别名  #as一般可以省略

如: select * from user1 a where a.id='1233';   #a就是user表的别名 引用的时候用a.

给表中的表的字段起别名

select a.name 学生姓名,a.phone 学生电话 from user  where a.name='test'  #a是表的别名, 给表的字段name和phone 起别名

9、in的查询方法

select * from test表 a  where a.name  in ('张三',李素");   # 查询表中包含张三和李素名字人的信息   a是给表起的别名

10、between  and

selece*from  test表  a where a.money bewteen 1000 and 10000;

11、order by 排序方法  默认升序方法

order by  字段名   #根据指定的字段进行排序,默认升序,降序desc

12. distinct 去重

select  distinct a.money  from test a

13. count() 总和  max  min  avg  sum   最大值,最小值,平均值,最小值

select  count(*) 学生人数 from test表  where  sex = '女' ;  #统计行数  统计学生人数是女生的有多少行

14,gorup by  分组

如果group by 后面有条件的话,必须得用having子句,having 子句里面用到的字段必须出现在select后面

如:

select sex 性别,count(*) 人数,a.name名字 from test表 a where a.money>300 group by a.id having a.name like '测试%';

表的别名a,按照id 进行分组

如果group by 和order by 一起用的话,order by  必须写在group by的后面

Linux+mysql混杂的更多相关文章

  1. linux mysql远程连接

    今天在本地连接linux服务端的mysql始终报错61,谷歌后找到原因: linux的mysql默认是不允许远程连接操作的,在stack上面找到方法:修改mysql配置文件/usr/local/mys ...

  2. ubuntu linux mysql 安装 基本操作 命令

    mysql --help #如果有信息证明系统已经安装了mysql mysql -V #查看版本号 netstat -tap|grep mysql #检查mysql是否在启动状态 卸载mysql: s ...

  3. 工作常用的linux/mysql/php/工具命令

    工作常用的linux/mysql/php/工具命令: 1. tar备份目录 tar zcvf ****.tar.gz ****/ tar 备份跳过目录 tar --exclude=test1 3. s ...

  4. [争什么! 掺在一起做撒尿牛丸啊! 笨蛋]ASP.NET Core 2.0 + EF6 + Linux +MySql混搭

    好消息!特好消息!同时使用ASP.NET Core 2.0和.NET Framework类库还能运行在linux上的方法来啦! 是的,你没有看错!ASP.NET Core 2.0,.NET Frame ...

  5. Linux Mysql数据库安全配置

    Linux  Mysql数据库安全配置 目录: 1.修改mysql管理员账号root的密码(2种方法) 2.修改mysql管理员账号root 3.mysql管理员root账号密码遗忘解决办法(2种方法 ...

  6. windows mysql主 Linux mysql 从 主从同步,读写分离

    Mysql –master linux-slave 一.My.ini: Server-id=1 relay-log=relay-bin relay-log-index=relay-bin-index ...

  7. 【Asp.Net Core】ASP.NET Core 2.0 + EF6 + Linux +MySql混搭

    好消息!特好消息!同时使用ASP.NET Core 2.0和.NET Framework类库还能运行在linux上的方法来啦! 是的,你没有看错!ASP.NET Core 2.0,.NET Frame ...

  8. linux mysql下载地址

    linux mysql下载地址: https://dev.mysql.com/downloads/mysql/5.7.html#downloads

  9. DELPHI 10.2 TOKYO搭建LINUX MYSQL开发环境

    DELPHI 10.2 TOKYO搭建LINUX MYSQL开发环境 笔者使用ubuntu64位LINUX 首先必须保证LINUX可以连互联网. 安装MYSQLsudo apt-get update ...

随机推荐

  1. GitHub Actions in Action

    GitHub Actions in Action https://lab.github.com/githubtraining/github-actions:-hello-world https://g ...

  2. why 2020 you should create a new modern website with web fullstack

    why 2020 you should create a new modern website with web fullstack Full-Stack Web Development Front- ...

  3. how to import a SQL file in MySQL command line

    how to import a SQL file in MySQL command line execute .sql file, macOS $mysql> source \home\user ...

  4. 钉钉 & URL Scheme & Universal Link & Deep Link

    钉钉 & URL Scheme & Universal Link & Deep Link DD link https://www.cnblogs.com/xgqfrms/p/1 ...

  5. html template tag

    html template tag const tagName = `emoji-element`; const template = document.createElement('template ...

  6. free online business card generator

    free online business card generator 免费在线名片生成器 https://www.logaster.cn/business-card/ https://www.chu ...

  7. Chrome debug & string to object & copy format json

    Chrome debug & string to object & copy format json // save as global variable copy(JSON.stri ...

  8. nasm 函数返回一个数组 x86

    getArguments.asm: extern VirtualAlloc section .text global dllmain export getArguments dllmain: mov ...

  9. 浅析VAST代币与SPC算力币的释放模式

    许多区块链业界分析师认为,2021年的区块链市场或许与2020年的有些许不同.2020年的区块链市场更注重的是DeFi领域,很多公链项目以及资本市场的巨鲸们也是将目光锁定在DeFi领域.而2021年的 ...

  10. 1月22日第二轮空投来袭,SPC算力福利币究竟能带来什么?

    行情数据显示,比特币于14日23时30分再次突破40000美元,市值回升至7400亿美元.根据行情频道数据,比特币于14日2时展露上行态势,价格于34000美元附近起跳,至12时站上37000美元.此 ...