SQL常用语法

1、查看表格(stduent)包含字段

  desc student;

2、向已存在的表格(student)中添加字段(age)

  ALTER TABLE student ADD age INT(4);

3、向已存在的表格(student)第一列添加字段(age)

  ALTER TABLE student ADD age INT(4) FIRST;

4、查询ID为xxxx的数据以时间排序取最新5条

  select * from student where id=20220901 order by time desc limit 0,5;

5、查询数据表(stduent)中的总数据条数

  select  count(1) from student;

6、查看数据表数据条数

  select  count(*)  from  database;   //查看数据表数据条数

7、查看数据库占用空间大小

  1、use xxxx;//切换到指定数据库

  2、select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') from information_schema.tables;  //查看指定数据库大小

  3、select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') from information_schema.tables where table_schema='数据库名' AND table_name='表名'; //查看指定数据库中指定表的大小

8、查看数据存储位置

  select @@datadir;

9、删除数据表

  drop table xxx

 

posted @   *^VV^*  阅读(27)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示