数据库基础命令

来源:互联网 发布:fm自建球员数据锁定 编辑:程序博客网 时间:2024/05/18 01:39
  • 访问数据库

/usr/bin/mysql -u root -p password

  • 显示所有库名
show databases;
  • 切换数据库

use database_name;

  • 显示所有表名:

show tables;

  • count查询
select count(1) from table_name where pid=111;
  • 基础查询语句

select * from table_name where pid=2543425 order by id desc limit 0,10;

0表示偏移量,10表示查询size;

order by需要放在limit前面,否则会报类似mysql错误:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by id desc' at line 1

0 0
原创粉丝点击