博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql初探
阅读量:7229 次
发布时间:2019-06-29

本文共 1324 字,大约阅读时间需要 4 分钟。

      使用mysql:命令行输入mysql直接进入mysql,没有进去的话,请确定已安装mysql并且已开启mysql服务,以某用户登录mysql请使用mysql -u root -p 123456(你的密码)

      show databases;进入数据库查看有什么数据库

      create database test default charset utf8 collate utf8_general_ci; 如果想创建数据库,并设置默认字符为utf8,排序顺序为utf8_general_ci即大小写不敏感

      use test; 对test数据库进行操作,选择某一数据库后才能进行后面的操作

      create table students (id int ,name varchar(20));创建一个表,表里有id和name

      show tables;查看数据库有哪些表

      show columns from test;  或者describe test;查看表有的属性信息。

      select id,name from   student;或者select * from student;查看id和name的值

      select distinct id from student;如果id有重复的,只显示其中一个

      select id,name from   student limit 3;只显示前三个结果

      select id,name from student limit 2,3;显示从第三个开始数三个的结果(第一行是0)

     select id,name from   student order by id desc;根据id大小排序,desc倒序,asc顺序(默认是升序)

      select id,name from   student order by id  desc,name;先根据id大小倒序排序,再根据名字排

 

      select * from student where id=14;

     

      select * from student where id between 2 and 10;

     

      select * from student where name is null;(name赋值时是赋值为null,不是其它)

     

      select * from student where name='bp' and id =14;

    

      select * from student where id in (1,14);打印id是1和14的

      select * from student where id not in (1,14);打印id不是1和14的

      select * from student where name like 'bp%';打印名字以bp开头的信息,只能以bp开头,前面多个字母都不行,还有%a%,s%e之类的用法,%代表0个或者一个,或者多个字符

    

      select * from student where name like 'bp_';跟%差不多,只是_只能匹配一个字符,而不是多个字符

     

 

转载于:https://www.cnblogs.com/biaopei/p/7730669.html

你可能感兴趣的文章
“深入理解”—交换排序算法
查看>>
ng-cordova 手机拍照或从相册选择图片
查看>>
ARM 汇编指令集 特点之一:条件执行后缀
查看>>
软工第五次作业--原型设计(结对)
查看>>
优化PartialRenderFormMixin性能
查看>>
如何让代码健壮
查看>>
网页布局要点
查看>>
vs2010 VS2008 VS2005 快捷键大全
查看>>
Delphi中调用API函数Winexec执行WinRar命令行压缩工具执行压缩
查看>>
ssm(3-2)Springmvc拓展
查看>>
leetcode--Recover Binary Search Tree*
查看>>
Hdu-6230 2017CCPC-哈尔滨站 A.Palindrome Manacher 主席树
查看>>
提高javascript编码质量-68-1
查看>>
设计模式开篇 - 简单工厂模式
查看>>
Spring MVC 注解和XML的区别
查看>>
利用Swoole实现PHP+websocket直播,即使通讯代码,及linux下swoole安装基本配置
查看>>
Elastic学习第一天遇到的问题以及添加的一些操作
查看>>
Python lambda介绍
查看>>
BSON与JSON的区别
查看>>
文件系统存储数据,与数据库系统存储数据的差别
查看>>