mysql desc用法_MySQL学习笔记(不断更新中)

b2c2542d847bae1e1066d919f32d9e7c.png

cc6933faef649639d35e2fb3dfc3e1d9.png

1、数据库

show databases;        #在Mysql中查数据库:
use 数据库名称;         #使用一个数据库:
create database 数据库名称; #新建一个数据库:

2、表

show tables;  #在数据库中查表
create tables 表名(列名1 数据格式,
                    列名2 数据格式
                       列名3 数据格式); #在数据库中建表
drop table 表名    #删除表

desc 表名      #查看表中所有列名的设计信息
describe 表名  #查看表中所有列名的设计信息

ALTER TABLE 表名 add 列名 数值格式         #在表中添加列
ALTER TABLE 表名 change 列名 新列名 数值格式;    #重命名列

3、记录

select * from 表名   #在表中查找所有记录
insert into 表名(列名1,列名2,列名3)values(值1,值2,'字符'3);   #在表中插入新的一条记录
update 表名 set 列名1=值1,列2=值2,列3=值3 where id='10002';   #在表中修改一条特定记录.这里没有TABLE和FROM!!!
delete from 表名 where id='10001';   #在表中删除一条特定记录
select 列名2,列名5 from 表名;    #在表中查询某些列
select 列名2,列名5 from 表名 where age>21;  #在表中查询某些列的特定记录

4、运算符

select * from customer where salary >=2000 and salary<=3000;
select * from customer where salary between 2000 and 3000;
select * from customer where salary=1000 or salary=2000 or salary=3100;
select * from customer where salary in (1000,2000,3100);
select name from customer where name like '%o%';   #查询name中有o的人的名字
select name from customer where name like '__o%;    #查询name中第3个字母是o的人的名字
select * from customer where email is null;       #查询email为空的所有人的信息
select * from customer where email is not full;    #查询email不为空的所有人的信息
select * from customer order by salary;       #查询所有客户信息,且按salary排序
select * from customer order by salary desc;   #查询所有客户信息,且按salary降序排序
select version(); #查询Mysql的版本

5、注释

单行注释: #注释

-- 注释

多行数据: /*注释*/

6、字符串

字符串可以是SELECT列表中的一个字符,数字,日期。

日期和字符只能在单引号中出现。

7、SELECT 的辅助功能

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值