Mysql基本命令二

  1. 删除id>10的记录:delete from user where id>10; 
  2. 设置user表的自增字段起始值为10:alter table user anto_increment=10;  设置user表的自增字段起始值为10
  3. 表字段自我复制:insert into user select * from user;
    *如果表有自增字段,自增字段是不能复制的,代码改为:insert into user(name,pass) select name,pass from user;
  4. 更新表字段:update user set name='admin' where name is null;
  5. 添加表字段:alter table user add pid int(11);
  6. 删除表字段:alter table user drop pid;
  7. 显示表的列名信息:show columns from emp
  8. 把user表的password字段md5加密:update user set password=md5('password');  (*这只是更新之前的密码值,新插入的数据仍然是没有加密的,但是可以通过insert into user values(2,'admin',md5('admin'));来实现加密,那么每次插入自动加密应该怎么实现?)
  9. 同表中从一条记录更新另一条记录:update user set name=('select name from art where id=2') where id=1;
  10.  concat函数(连接字符串): select concat(id,",",pid) from goods_type;

 

  
posted @ 2017-08-08 11:00  yolo_bean  阅读(172)  评论(0)    收藏  举报