数据库常用操作(mysql)

创建

create database 库名
create table 表名(列名  type(varchar(size),int(size),decimal(size,d)))  "size" 规定数字的最大位数。"d" 规定小数点右侧的最大位数。
insert into 表明 (字段1、字段2)  values ()

更改

#更改表名
alter table 表名 rename 新表名
#更改字段中的值
update 表名称 set 列名称 = 新值 WHERE 列名称 = 某值
#更改表字段名
alter table 表名 change 原字段名 新字段名 type
#更改字段type
alter table 表名 modify 字段名 type
#增加字段
alter table 表名 add 字段名 type
#删除字段
alter table 表名 drop column 字段名
#删除表
drop table 表名
#删除表中数据
delete from 表名 where 列名称 = 值
#删除表中所有数据(保留表的数据结构)
truncate 表名

查看

#查看表结构信息(字段、type等)
desc 表名
#查看表内容
select * from 表名
posted @ 2018-11-05 11:35  口天丶木乔  阅读(163)  评论(0编辑  收藏  举报