Mysql的基础语句

DDL表操作信息

创建表的信息

create table table_name(
column datatype()
)

使用指定表

user table_name;

查看所有数据库

show databases;

查看当前数据库

select database();

删除数据库表

drop database database_name;

DDL-表操作修改

添加字段信息

alter table table_name add column datatype(long);

删除字段

alter table table_name drop column;

修改数据库字段类型

alter table table_name modify column datatype(long);

使用字段替换旧字段

alter table table_name change old_column new_column datatype(long);

修改表名

alter table old_table_name rename to new_table_name;

删除表名

drop table table_name;

重置表

truncate table table_name;

DML(数据操作语言)

向表中增加数据

insert into table_name (column1,column2,...) values (value,value,...);

insert into table_name values ();

insert into table_name (column1,column2,...) values (value,value,...),(value,value,...);

删除表中数据

delete form table_name {where 条件};

修改表中数据

update table_name set column = value ,.. {where 条件};

DQL(数据查询语言)

查询--》设置别名

select column [as 别名] from table_name;

查询--》去重

select distinct column from table_name;

条件查询

select * from table_name [where 条件]

聚合查询

select fetter1,count(*) from tb_name group by column;

排序查询

asc 升序;

desc 降序;

select * from tb_name order by column 排序方式,column2 排序方式;

分页查询

select * from tb_name limit a,b;(索引 - a,页面的显示数据 b)

相关推荐

  1. Mysql基础语句

    2023-12-13 13:08:05       51 阅读
  2. MySQLMySQL基本语句

    2023-12-13 13:08:05       52 阅读
  3. Mysql-SELECT语句基本用法

    2023-12-13 13:08:05       33 阅读
  4. MYSQL基础语法

    2023-12-13 13:08:05       37 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-13 13:08:05       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-13 13:08:05       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-13 13:08:05       87 阅读
  4. Python语言-面向对象

    2023-12-13 13:08:05       96 阅读

热门阅读

  1. Linux0.11内核源码解析-string待更新

    2023-12-13 13:08:05       67 阅读
  2. 什么是强缓存和协商缓存?

    2023-12-13 13:08:05       57 阅读
  3. PostgreSQL数据库切换到另一个模式下

    2023-12-13 13:08:05       51 阅读
  4. filebeat 后端运行,自动退出解决

    2023-12-13 13:08:05       58 阅读
  5. C : DS静态查找之顺序索引查找

    2023-12-13 13:08:05       57 阅读
  6. HTB Ouija

    2023-12-13 13:08:05       50 阅读
  7. JRT实现Cache的驱动

    2023-12-13 13:08:05       70 阅读
  8. go标记omitempty的含义

    2023-12-13 13:08:05       55 阅读
  9. c++基于流文件输入输出的综合程序设计

    2023-12-13 13:08:05       59 阅读
  10. 你在地铁上修过bug吗?

    2023-12-13 13:08:05       63 阅读
  11. reactHooks之useDeferredValue

    2023-12-13 13:08:05       69 阅读
  12. 12.12每日一题(备战蓝桥杯循环输出)

    2023-12-13 13:08:05       47 阅读