Mysql

查看数据库的指令 show databases;

创建数据库  create database 数据库名;

删除数据库的指令 drop database 数据库名;

进入某一数据库中 use 数据库名;

 

对数据表增删查改

查看数据表:show tables;

创建表 create table 表名(字段 1 类型;字段2 类型);

删除表 drop table 表名;

修改表名 alter table表名 rename 新表名;

 

进入表里对字段进行操作

查看表的定义 desc 表名;

 

添加字段

字段定义 字段名和字段类型都要写

alter table 表名 add字段定义;

删除字段 altertable 表名 drop 字段名;

修改字段 alter table 表名 changge 旧的字段名 字段定义;

给字段添加数据(记录)

添加一调记录 insert into 表名(id,age)value(值1,值2);

添加不指定字段名的语法 insert 表名values(值1,值2);

多条记录添加 insert into表名values(值1,值2),值1,值2),值1,值2)

查看记录 select*from 表名;查看所有字段记录

select id from 表名 ;查看单个的字段记录

select id,age from 表名;查看多个字段的记录

按条件查询

select*from 表名 where 条件  条件表达式 >  ,>,>=,<=,=,!= ,  and 且  or或

排序查询

select * from 表名 order by 字段名[asc/desc]

asc 从低到高  desc 从高到低

限制查询 

select *from 表名 limit 2,5 ; 从第二个开始向后查询五个

删除记录

删除所有  delete from 表名

按条件删 delete from 表名 where 条件表达式;

改数据 update 表名 set 字段=值; 如果不带条件 会把字段下面的记录全改

 

 

 

 

 

                              

posted @ 2019-04-10 20:54  xxy1109833325  阅读(88)  评论(0编辑  收藏  举报