暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

MySQL数据库命令表

阿帆fan 2021-05-07
144

show databases;
 查看数据库

creatr database stu;
 创建名为stu的数据库

use stu;
 选择数据库

drop database stu;
 删除stu数据库

create table user (id int primary key auto_increment,name varchar(32) not null,password varchar(10) not null)default charset=utf8; 创建表格

show tables;
 查看表格

desc user; == show columns from user;

desc user id;
只看id信息

alter table user add hobby varchar(60);
 给user表加一个hobby

inset into info (id,name,class)values(null,'张三','一班');
 向数据表info有条件插入数据

inset into info values(null,'张三','一班');
 向数据表info插入数据

alter table info add score varchar(10);
 给info表添加 score字段

alter table info drop score;
  删除info表 score字段

alter table info change name username varchar(50);

 把info表的name改成username

alter table info modify id int(20);
 把info表的id数据类型改成int 长度20

alter table info rename ceshi;
 把info表的表名改成 ceshi

rename table info to ceshi;
 把info表重命名为ceshi

drop table if exists abc;
 删除表abc

select * from info;
 查询info表里的所有数据

select name from info;
 查询info表里name字段

select * from info where id=1;
 查询info表里id=1的数据

select * from info name like '李%';
 筛选以李开头的

select * from info limit 2,2;
 从第三个开始查询2组数据(注意:2是从第三个开始查询)

update info set name='张三' where id=1;
 把info表中id=1的name赋值为 张三

update info set name='张三';
 把info表中所有的name赋值为 张三

delete from info where id=2;
 把info表中id=2的数据删除

delete from info;
 删除info表中所有数据

truncate info;
 清空数据表


@阿帆fan



点这里给我留言



点这里进入阿帆的论坛




文章转载自阿帆fan,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论