mysql基础 仅供参考(基于linux下安装的mysql)

mysql基本操作

  1. 查看所有数据库

 

 

  1. 显示创建内容

 

 

  1. 使用数据库

 

 

  1. 查看数据库位置

 

 

  1. 创建一个学生表

create table xsb(id int,name varchar(32),age int)

  1. 查看表

 

 

 

  1. 查看表结构

 

 

  1. 查看学生表语句

 

 

  1. 格式化查看学生表语句

 

 

  1. 给学生表增加名字为zhangsan,年龄为23的字段

insert into xsb(id,name,age) value(1,”zhangsan”,23)

  1. 查看学生表字段

 

 

 

  1. 不指定字段插入,必须和表结构保持一致

insert into xsb values(2,’lisi’24),(3,’wangwu’,36)

  1. 更新学生表,不加条件全部年龄改成66

update xsb set age=66

  1. 加条件更新学生表,只更新满足条件的学生表

update xsb set age=55 where id=3

  1. 删除学生表里id=3的记录

delete from xsb where id=3

  1. 插入tt字段,类型为整形

alter table xsb add tt int

  1. tt之后插入rr字段,类型为整形

alter table xsb add rr int after tt

  1. 在第一条插入aa字段,类型为整形

alter table xsb add aa int first

  1. 删除字段aa

alter table xsb drop aa

 

 如需要linux下安装mysql安装步骤,请留言。

posted @ 2019-07-17 17:56  喜欢思考、爱好编程  阅读(148)  评论(0编辑  收藏  举报