•  查看数据库

show databases;

Mysql使用语法总结

  •  使用数据库

use honeypot;

  • 查看数据表

show tables;

Mysql使用语法总结

  • 查看数据表结构

desc TABLEname;

Mysql使用语法总结

  •  修改数据表的某个字段的类型

alter table awshoneypot15000

modify type int(10);

  • 从一个数据表awshoneypot1000 中取出前15000行并创建新的数据表awshoneypot15000

create table awshoneypot15000 as select * from awshoneypot1000 limit 15000;

  • 删除某个字段

alter table awshoneypot1000

drop locale;

  • 统计数据表的记录数

select count(*) from awshoneypot;

Mysql使用语法总结

  •  没有主键时,添加一列作为主键

alter table tablename add id int(8) not null primary key Auto_increment;

 Mysql使用语法总结

 

  • 修改列的顺序:

移动至第一列:

alter table employee modify user_name varchar(100) first;  

 Mysql使用语法总结

 

  •  把user_name列移动到password后面:

alter table employee modify user_name varchar(100) after password;  

 

 

 

更多查询语句参见:http://c.biancheng.net/view/2425.html

相关文章:

  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
猜你喜欢
  • 2021-07-27
  • 2022-12-23
  • 2021-05-24
  • 2021-10-07
  • 2022-01-18
  • 2021-11-19
  • 2021-11-03
相关资源
相似解决方案