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