mysql 数据语句

备份  mysqldump -hlocalhost -uroot -p liuyanban > d:/1.sql   
恢复  mysql -hlocalhost -uroot -p liuyanban<d:/1.sql

数据库:

创建数据库  create database dbname;

删除数据库  drop database dbname;

查看数据库 show databases;


数据表:

使用数据表 use dbname;

查看表 show tables;

数据表:

表格里面改名 alter table new rename ;

表格里面添加 alter table new add;

表格里面删除 alter table new drop;

表格里面改变 alter table new change;


主键索引:

添加主键 alter table tabname add primary key(col);
删除主键 alter table tabname drop primary key(col);
创建索引 create [unique] index idxname on tabname(col....)
删除索引 drop index  idxname;
注:索引是不可更改的,想更改必须删除重新建。

几个简单的基本的sql语句
选择 select * from table where 范围
插入  insert into table(field1,field2) values(value1,value2)
删除  delete from table where 范围
更新  update table set field1=value1 where 范围
查找 select * from table where field1 like ‘%value1%’
排序  select * from table1 order by field1,field2 [desc]
总数  select count as totalcount from table1
求和  select sum(field1) as sumvalue from table1
平局  select avga(field1) as avgvalue from table1
最大 select max(field1) as maxvalue from table1
最小  select max/min(field1) as minvalue from table1

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值