sql 查询mysql数据库常用语句汇总



sql 查询mysql数据库常用语句命令汇总如下:

(1)查询mysql中存在的数据库有哪些

 show databases;显示已有的数据库

 选择某个数据库使用的语句是:use databasename;(databasename也就是数据库的名字)

(2)查询mysql当前数据库存在的所有的表有哪些:

 show tables;显示数据库的表

(3)查询表结构命令(要先选中数据库)

 describe tablename;

(4)查询表格列的属性

 show columns from tableName;

(5)查询数据表中的某条记录

 select name from tablename where id=xxx;(tablename也就是你的数据表的名称)

(6)查询数据库当前时间

 select now();

 select current_time;

(7)查询当前日期命令

 select current_date;

(8)查询当前用户命令

 select user();

(9)查询数据库版本

 select version();

(10)查询当前使用的数据库

 select database();

(11)查询当前服务器支持哪个存储引擎

 show engines;

(12)查看建表的sql语句

show create table table_name\g;  //大小写均可