1.进入MySQL的两种方式:

    (1).MySQL自带的控制台

        直接输入密码

    (2).命令提示符:

        mysql -uroot -proot

        然后再输入密码

 MySQL常用指令
-------
1.启动mysql 命令行
c:/>mysql -h hostname -u root -p root //连接远程服务器
c:/>mysql -u root -p root //连接localhost
c:/>mysql -uroot -proot //直接登录到本机 2.查看mysql的帮助
c:/>mysql --help 3.查询当前日期和时间
mysql>select current_date ; //伪劣
mysql>select now() ; //函数
4.显示所有数据库
mysql>-- 这是注释
mysql>show databases; 5.删除数据库
mysql>drop database myhive ; 6.创建数据库
mysql>create database mybase ; 7.使用指定的数据库
mysql>use mybase ; 8.显示所有表
mysql>show tables; 9.创建表
mysql>create table test(id int,name varchar(20),age int); 10.查看表结构
mysql>describe test ; //
mysql>desc test ; // 11.删除表
mysql>drop table test ; 12.查询表数据
mysql>select * from test ; //全字段 + 全表扫描
mysql>select id,name,age from test ; //投影查询 project
mysql>select id,name,age from test where id > 3 ; //
mysql>select id,name,age from test where id > 3 and id < 5; // 类似于 java &&
mysql>select id,name,age from test where name = 'tom'; // mysql>select id,name,age from test where name like 't%'; //模糊查询
mysql>select id,name,age from test where name not like 't%'; //模糊查询
mysql>select id,name,age from test where name not like 't\_%'; //使用转义符查询特殊字面量 mysql>select id,name,age from test where name is null ; //null查询
mysql>select id,name,age from test where name is not null ; //非null查询 mysql>select id,name,age from test order by id desc,name ; //降序排序
mysql>select id,name,age from test order by id asc ; //降序排序 mysql>select id,name,age from test limit 1,3 ; //从第二条 ,查3条
mysql>select id,name,age from test limit 1 ; //0,1 [聚集函数查询]
mysql>select count(*) from test ; //count,查询记录总数
mysql>select max(age) from test ; //最大值
mysql>select min(age) from test ; //最小值
mysql>select avg(age) from test ; //平均值
mysql>select sum(age) from test ; //求总和 13.插入记录
mysql>insert into test(id,name,age) values(1,'tom',23);
mysql>insert into test(id,name) values(4,'tomson');
mysql>insert into test values(4,'tomson',13); 14.更新记录
mysql>update test set name='xxx' , age = 33 where id = 112 ; //更新id为112的记录
mysql>update test set name='xxx' , age = 33; //更新所有记录 15.删除记录
mysql>delete from test where id = 1 ; 16.使用mysql命令行执行sql脚本
mysql>source d:/java/findtest.sql 17. CRUD
-------
[create]
insert into table_name(field_name,...) values(value,...) ; [retrieve]
select id,.. from table_name where id= xxx, ... ; [update]
update table_name set id=xxx,... where id = xxx , .. ; [delete]
delete from test where ... ;

MySQL基础操作1的更多相关文章

  1. MYSQL基础操作

    MYSQL基础操作 [TOC] 1.基本定义 1.1.关系型数据库系统 关系型数据库系统是建立在关系模型上的数据库系统 什么是关系模型呢? 1.数据结构可以规定,同类数据结构一致,就是一个二维的表格 ...

  2. MYSQL 基础操作

    1.MySQL基础操作 一:MySQL基础操作 1:MySQL表复制 复制表结构 + 复制表数据 create table t3 like t1; --创建一个和t1一样的表,用like(表结构也一样 ...

  3. 【MySQL】MySQL基础操作语句

    mysql基础操作语句,包括数据库的增.删.切换,以及表的增.删.改.查.复制. 创建数据库 mysql> create database tem; 使用数据库 mysql> use te ...

  4. MySQL基础操作&&常用的SQL技巧&&SQL语句优化

    基础操作     一:MySQL基础操作         1:MySQL表复制             复制表结构 + 复制表数据             create table t3 like t ...

  5. mysql数据库优化课程---13、mysql基础操作

    mysql数据库优化课程---13.mysql基础操作 一.总结 一句话总结:mysql复制表,索引,视图 1.mysql如何复制表? like select * 1.复制表结构 create tab ...

  6. MySQL基础操作(二)

    MySQL基础操作 一.视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,并可以将其当作表来使用.注意:使用视图时 ...

  7. 前端笔记之服务器&Ajax(中)MySQL基础操作&PHP操作数据库&Ajax

    一.数据库基础 1.1什么是数据库? 什么是数据库? 答:就是一个很大的一个文件,只不过这个文件可以通过一些‘命令’操作数据: 增.删.改.查数据: 数据库等于持久数据和数据操作的一个统称. 数据库是 ...

  8. PHP mysql基础操作

    mysql连接操作 //建立连接$con = mysql_connect('localhost', 'root', '123456');//判断是否连接成功if($con){ die('连接失败!'. ...

  9. 02 . Mysql基础操作及增删改查

    SQL简介 SQL(Structured Query Language 即结构化查询语言) SQL语言主要用于存取数据.查询数据.更新数据和管理关系数据库系统,SQL语言由IBM开发. SQL语句四大 ...

  10. JSP中的数据库操作,MySQL基础操作(一)

    一.JDBC JDBC(java data base concectivity),是一种用于执行SQL语句的java API,可以为多种关系库提供统一访问. 通常使用JDBC完成以下操作: 1)同数据 ...

随机推荐

  1. Unity3D 物体移动方法总结

    1. 简介 在Unity3D中,有多种方式可以改变物体的坐标,实现移动的目的,其本质是每帧修改物体的position. 2. 通过Transform组件移动物体 Transform 组件用于描述物体在 ...

  2. Java并发编程之并发容器

    解决并发情况下的容器线程安全问题的.给多线程环境准备一个线程安全的容器对象. 线程安全的容器对象: Vector, Hashtable.线程安全容器对象,都是使用 synchronized 方法实现的 ...

  3. 使用Jmeter连接数据库检查数据库记录的方法

    一.首先下载Jdbc驱动(jdbc驱动分两种,classes与ojdbc文件,该用哪个需要检查电脑安装的jdk版本(查看方法cmd命令java –version) 关于各种版本的说明:http://e ...

  4. PHP整理--PHP语句流程

    PHP跟JS一样是从上往下的执行语句:同样的PHP也有if语句.循环.数组和函数. 一.条件语句   if..else...    swich  (1)多条if语句 $name=30; if($nam ...

  5. Linux查看机器负载

    负载(load)是linux机器的一个重要指标,直观了反应了机器当前的状态.如果机器负载过高,那么对机器的操作将难以进行. Linux的负载高,主要是由于CPU使用.内存使用.IO消耗三部分构成.任意 ...

  6. MySQL数据库时间查询

    /*当前时间加1毫秒*/ SELECT DATE_ADD(NOW(),INTERVAL 1 MICROSECOND); /*当前时间减1毫秒*/ SELECT DATE_ADD(NOW(),INTER ...

  7. 3D Graph Neural Networks for RGBD Semantic Segmentation

    3D Graph Neural Networks for RGBD Semantic Segmentation 原文章:https://www.yuque.com/lart/papers/wmu47a ...

  8. virtualbox装个 ubuntu

    好久没弄 虚拟机了,感觉好不习惯 根据网上的步骤装了一ubuntu 启动报错 virtualbox intel_rapl: no valid rapl domains ...... 搜索到了一片中文博 ...

  9. UI行业发展预测 & 系列规划的调整

    又双叒叕拖更了,上一篇还是1月22号更新的,这都3月9号了…… 前面几期把职业规划.能力分析.几个分析用的设计理论都写完了,当然实际工作中用到的方法论不止上面这些,后续会接着学习: 如果你的目标是一线 ...

  10. DecimalFormat 的用法

    DecimalFormat 是 NumberFormat 的一个具体子类,用于格式化十进制数字. DecimalFormat 是 NumberFormat 的一个具体子类,用于格式化十进制数字.Dec ...