• mysql初探


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

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

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

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

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

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

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

    select id,name 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_';    #跟%差不多,只是_只能匹配一个字符,而不是多个字符


         

     

  • 相关阅读:
    C# 复制文件夹,移动文件夹
    让Base64适合在URL中使用
    修复FIREBIRD数据库
    Image.FromFile 锁文件的解决办法
    Powerbuilder 12.5 下载地址
    C# 给程序添加许可
    WIN FORM 多线程更新UI(界面控件)
    .Net WinForm 拖动控件
    SQL Server 自动增长清零
    C# 一次生成多个相同的字符
  • 原文地址:https://www.cnblogs.com/biaopei/p/7730669.html
Copyright © 2020-2023  润新知